popover.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*!
  2. * Bootstrap popover.js v4.6.2 (https://getbootstrap.com/)
  3. * Copyright 2011-2022 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('jquery'), require('./tooltip.js')) :
  8. typeof define === 'function' && define.amd ? define(['jquery', './tooltip'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.jQuery, global.Tooltip));
  10. })(this, (function ($, Tooltip) { 'use strict';
  11. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  12. var $__default = /*#__PURE__*/_interopDefaultLegacy($);
  13. var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
  14. function _defineProperties(target, props) {
  15. for (var i = 0; i < props.length; i++) {
  16. var descriptor = props[i];
  17. descriptor.enumerable = descriptor.enumerable || false;
  18. descriptor.configurable = true;
  19. if ("value" in descriptor) descriptor.writable = true;
  20. Object.defineProperty(target, descriptor.key, descriptor);
  21. }
  22. }
  23. function _createClass(Constructor, protoProps, staticProps) {
  24. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  25. if (staticProps) _defineProperties(Constructor, staticProps);
  26. Object.defineProperty(Constructor, "prototype", {
  27. writable: false
  28. });
  29. return Constructor;
  30. }
  31. function _extends() {
  32. _extends = Object.assign ? Object.assign.bind() : function (target) {
  33. for (var i = 1; i < arguments.length; i++) {
  34. var source = arguments[i];
  35. for (var key in source) {
  36. if (Object.prototype.hasOwnProperty.call(source, key)) {
  37. target[key] = source[key];
  38. }
  39. }
  40. }
  41. return target;
  42. };
  43. return _extends.apply(this, arguments);
  44. }
  45. function _inheritsLoose(subClass, superClass) {
  46. subClass.prototype = Object.create(superClass.prototype);
  47. subClass.prototype.constructor = subClass;
  48. _setPrototypeOf(subClass, superClass);
  49. }
  50. function _setPrototypeOf(o, p) {
  51. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
  52. o.__proto__ = p;
  53. return o;
  54. };
  55. return _setPrototypeOf(o, p);
  56. }
  57. /**
  58. * Constants
  59. */
  60. var NAME = 'popover';
  61. var VERSION = '4.6.2';
  62. var DATA_KEY = 'bs.popover';
  63. var EVENT_KEY = "." + DATA_KEY;
  64. var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
  65. var CLASS_PREFIX = 'bs-popover';
  66. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  67. var CLASS_NAME_FADE = 'fade';
  68. var CLASS_NAME_SHOW = 'show';
  69. var SELECTOR_TITLE = '.popover-header';
  70. var SELECTOR_CONTENT = '.popover-body';
  71. var Default = _extends({}, Tooltip__default["default"].Default, {
  72. placement: 'right',
  73. trigger: 'click',
  74. content: '',
  75. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  76. });
  77. var DefaultType = _extends({}, Tooltip__default["default"].DefaultType, {
  78. content: '(string|element|function)'
  79. });
  80. var Event = {
  81. HIDE: "hide" + EVENT_KEY,
  82. HIDDEN: "hidden" + EVENT_KEY,
  83. SHOW: "show" + EVENT_KEY,
  84. SHOWN: "shown" + EVENT_KEY,
  85. INSERTED: "inserted" + EVENT_KEY,
  86. CLICK: "click" + EVENT_KEY,
  87. FOCUSIN: "focusin" + EVENT_KEY,
  88. FOCUSOUT: "focusout" + EVENT_KEY,
  89. MOUSEENTER: "mouseenter" + EVENT_KEY,
  90. MOUSELEAVE: "mouseleave" + EVENT_KEY
  91. };
  92. /**
  93. * Class definition
  94. */
  95. var Popover = /*#__PURE__*/function (_Tooltip) {
  96. _inheritsLoose(Popover, _Tooltip);
  97. function Popover() {
  98. return _Tooltip.apply(this, arguments) || this;
  99. }
  100. var _proto = Popover.prototype;
  101. // Overrides
  102. _proto.isWithContent = function isWithContent() {
  103. return this.getTitle() || this._getContent();
  104. };
  105. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  106. $__default["default"](this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  107. };
  108. _proto.getTipElement = function getTipElement() {
  109. this.tip = this.tip || $__default["default"](this.config.template)[0];
  110. return this.tip;
  111. };
  112. _proto.setContent = function setContent() {
  113. var $tip = $__default["default"](this.getTipElement()); // We use append for html objects to maintain js events
  114. this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle());
  115. var content = this._getContent();
  116. if (typeof content === 'function') {
  117. content = content.call(this.element);
  118. }
  119. this.setElementContent($tip.find(SELECTOR_CONTENT), content);
  120. $tip.removeClass(CLASS_NAME_FADE + " " + CLASS_NAME_SHOW);
  121. } // Private
  122. ;
  123. _proto._getContent = function _getContent() {
  124. return this.element.getAttribute('data-content') || this.config.content;
  125. };
  126. _proto._cleanTipClass = function _cleanTipClass() {
  127. var $tip = $__default["default"](this.getTipElement());
  128. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  129. if (tabClass !== null && tabClass.length > 0) {
  130. $tip.removeClass(tabClass.join(''));
  131. }
  132. } // Static
  133. ;
  134. Popover._jQueryInterface = function _jQueryInterface(config) {
  135. return this.each(function () {
  136. var data = $__default["default"](this).data(DATA_KEY);
  137. var _config = typeof config === 'object' ? config : null;
  138. if (!data && /dispose|hide/.test(config)) {
  139. return;
  140. }
  141. if (!data) {
  142. data = new Popover(this, _config);
  143. $__default["default"](this).data(DATA_KEY, data);
  144. }
  145. if (typeof config === 'string') {
  146. if (typeof data[config] === 'undefined') {
  147. throw new TypeError("No method named \"" + config + "\"");
  148. }
  149. data[config]();
  150. }
  151. });
  152. };
  153. _createClass(Popover, null, [{
  154. key: "VERSION",
  155. get: // Getters
  156. function get() {
  157. return VERSION;
  158. }
  159. }, {
  160. key: "Default",
  161. get: function get() {
  162. return Default;
  163. }
  164. }, {
  165. key: "NAME",
  166. get: function get() {
  167. return NAME;
  168. }
  169. }, {
  170. key: "DATA_KEY",
  171. get: function get() {
  172. return DATA_KEY;
  173. }
  174. }, {
  175. key: "Event",
  176. get: function get() {
  177. return Event;
  178. }
  179. }, {
  180. key: "EVENT_KEY",
  181. get: function get() {
  182. return EVENT_KEY;
  183. }
  184. }, {
  185. key: "DefaultType",
  186. get: function get() {
  187. return DefaultType;
  188. }
  189. }]);
  190. return Popover;
  191. }(Tooltip__default["default"]);
  192. /**
  193. * jQuery
  194. */
  195. $__default["default"].fn[NAME] = Popover._jQueryInterface;
  196. $__default["default"].fn[NAME].Constructor = Popover;
  197. $__default["default"].fn[NAME].noConflict = function () {
  198. $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
  199. return Popover._jQueryInterface;
  200. };
  201. return Popover;
  202. }));
  203. //# sourceMappingURL=popover.js.map