You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
5.3 KiB

  1. /*!
  2. * Bootstrap popover.js v5.1.3 (https://getbootstrap.com/)
  3. * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./tooltip.js')) :
  8. typeof define === 'function' && define.amd ? define(['./tooltip'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Tooltip));
  10. })(this, (function (Tooltip) { 'use strict';
  11. const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
  12. const Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
  13. /**
  14. * --------------------------------------------------------------------------
  15. * Bootstrap (v5.1.3): util/index.js
  16. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  17. * --------------------------------------------------------------------------
  18. */
  19. const getjQuery = () => {
  20. const {
  21. jQuery
  22. } = window;
  23. if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  24. return jQuery;
  25. }
  26. return null;
  27. };
  28. const DOMContentLoadedCallbacks = [];
  29. const onDOMContentLoaded = callback => {
  30. if (document.readyState === 'loading') {
  31. // add listener on the first call when the document is in loading state
  32. if (!DOMContentLoadedCallbacks.length) {
  33. document.addEventListener('DOMContentLoaded', () => {
  34. DOMContentLoadedCallbacks.forEach(callback => callback());
  35. });
  36. }
  37. DOMContentLoadedCallbacks.push(callback);
  38. } else {
  39. callback();
  40. }
  41. };
  42. const defineJQueryPlugin = plugin => {
  43. onDOMContentLoaded(() => {
  44. const $ = getjQuery();
  45. /* istanbul ignore if */
  46. if ($) {
  47. const name = plugin.NAME;
  48. const JQUERY_NO_CONFLICT = $.fn[name];
  49. $.fn[name] = plugin.jQueryInterface;
  50. $.fn[name].Constructor = plugin;
  51. $.fn[name].noConflict = () => {
  52. $.fn[name] = JQUERY_NO_CONFLICT;
  53. return plugin.jQueryInterface;
  54. };
  55. }
  56. });
  57. };
  58. /**
  59. * --------------------------------------------------------------------------
  60. * Bootstrap (v5.1.3): popover.js
  61. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  62. * --------------------------------------------------------------------------
  63. */
  64. /**
  65. * ------------------------------------------------------------------------
  66. * Constants
  67. * ------------------------------------------------------------------------
  68. */
  69. const NAME = 'popover';
  70. const DATA_KEY = 'bs.popover';
  71. const EVENT_KEY = `.${DATA_KEY}`;
  72. const CLASS_PREFIX = 'bs-popover';
  73. const Default = { ...Tooltip__default.default.Default,
  74. placement: 'right',
  75. offset: [0, 8],
  76. trigger: 'click',
  77. content: '',
  78. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>'
  79. };
  80. const DefaultType = { ...Tooltip__default.default.DefaultType,
  81. content: '(string|element|function)'
  82. };
  83. const Event = {
  84. HIDE: `hide${EVENT_KEY}`,
  85. HIDDEN: `hidden${EVENT_KEY}`,
  86. SHOW: `show${EVENT_KEY}`,
  87. SHOWN: `shown${EVENT_KEY}`,
  88. INSERTED: `inserted${EVENT_KEY}`,
  89. CLICK: `click${EVENT_KEY}`,
  90. FOCUSIN: `focusin${EVENT_KEY}`,
  91. FOCUSOUT: `focusout${EVENT_KEY}`,
  92. MOUSEENTER: `mouseenter${EVENT_KEY}`,
  93. MOUSELEAVE: `mouseleave${EVENT_KEY}`
  94. };
  95. const SELECTOR_TITLE = '.popover-header';
  96. const SELECTOR_CONTENT = '.popover-body';
  97. /**
  98. * ------------------------------------------------------------------------
  99. * Class Definition
  100. * ------------------------------------------------------------------------
  101. */
  102. class Popover extends Tooltip__default.default {
  103. // Getters
  104. static get Default() {
  105. return Default;
  106. }
  107. static get NAME() {
  108. return NAME;
  109. }
  110. static get Event() {
  111. return Event;
  112. }
  113. static get DefaultType() {
  114. return DefaultType;
  115. } // Overrides
  116. isWithContent() {
  117. return this.getTitle() || this._getContent();
  118. }
  119. setContent(tip) {
  120. this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE);
  121. this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT);
  122. } // Private
  123. _getContent() {
  124. return this._resolvePossibleFunction(this._config.content);
  125. }
  126. _getBasicClassPrefix() {
  127. return CLASS_PREFIX;
  128. } // Static
  129. static jQueryInterface(config) {
  130. return this.each(function () {
  131. const data = Popover.getOrCreateInstance(this, config);
  132. if (typeof config === 'string') {
  133. if (typeof data[config] === 'undefined') {
  134. throw new TypeError(`No method named "${config}"`);
  135. }
  136. data[config]();
  137. }
  138. });
  139. }
  140. }
  141. /**
  142. * ------------------------------------------------------------------------
  143. * jQuery
  144. * ------------------------------------------------------------------------
  145. * add .Popover to jQuery only if jQuery is present
  146. */
  147. defineJQueryPlugin(Popover);
  148. return Popover;
  149. }));
  150. //# sourceMappingURL=popover.js.map