popover.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  5. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6. /**
  7. * --------------------------------------------------------------------------
  8. * Bootstrap (v4.1.1): popover.js
  9. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10. * --------------------------------------------------------------------------
  11. */
  12. var Popover = function ($) {
  13. /**
  14. * ------------------------------------------------------------------------
  15. * Constants
  16. * ------------------------------------------------------------------------
  17. */
  18. var NAME = 'popover';
  19. var VERSION = '4.1.1';
  20. var DATA_KEY = 'bs.popover';
  21. var EVENT_KEY = "." + DATA_KEY;
  22. var JQUERY_NO_CONFLICT = $.fn[NAME];
  23. var CLASS_PREFIX = 'bs-popover';
  24. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  25. var Default = _objectSpread({}, Tooltip.Default, {
  26. placement: 'right',
  27. trigger: 'click',
  28. content: '',
  29. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  30. });
  31. var DefaultType = _objectSpread({}, Tooltip.DefaultType, {
  32. content: '(string|element|function)'
  33. });
  34. var ClassName = {
  35. FADE: 'fade',
  36. SHOW: 'show'
  37. };
  38. var Selector = {
  39. TITLE: '.popover-header',
  40. CONTENT: '.popover-body'
  41. };
  42. var Event = {
  43. HIDE: "hide" + EVENT_KEY,
  44. HIDDEN: "hidden" + EVENT_KEY,
  45. SHOW: "show" + EVENT_KEY,
  46. SHOWN: "shown" + EVENT_KEY,
  47. INSERTED: "inserted" + EVENT_KEY,
  48. CLICK: "click" + EVENT_KEY,
  49. FOCUSIN: "focusin" + EVENT_KEY,
  50. FOCUSOUT: "focusout" + EVENT_KEY,
  51. MOUSEENTER: "mouseenter" + EVENT_KEY,
  52. MOUSELEAVE: "mouseleave" + EVENT_KEY
  53. /**
  54. * ------------------------------------------------------------------------
  55. * Class Definition
  56. * ------------------------------------------------------------------------
  57. */
  58. };
  59. var Popover =
  60. /*#__PURE__*/
  61. function (_Tooltip) {
  62. _inheritsLoose(Popover, _Tooltip);
  63. function Popover() {
  64. return _Tooltip.apply(this, arguments) || this;
  65. }
  66. var _proto = Popover.prototype;
  67. // Overrides
  68. _proto.isWithContent = function isWithContent() {
  69. return this.getTitle() || this._getContent();
  70. };
  71. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  72. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  73. };
  74. _proto.getTipElement = function getTipElement() {
  75. this.tip = this.tip || $(this.config.template)[0];
  76. return this.tip;
  77. };
  78. _proto.setContent = function setContent() {
  79. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  80. this.setElementContent($tip.find(Selector.TITLE), this.getTitle());
  81. var content = this._getContent();
  82. if (typeof content === 'function') {
  83. content = content.call(this.element);
  84. }
  85. this.setElementContent($tip.find(Selector.CONTENT), content);
  86. $tip.removeClass(ClassName.FADE + " " + ClassName.SHOW);
  87. }; // Private
  88. _proto._getContent = function _getContent() {
  89. return this.element.getAttribute('data-content') || this.config.content;
  90. };
  91. _proto._cleanTipClass = function _cleanTipClass() {
  92. var $tip = $(this.getTipElement());
  93. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  94. if (tabClass !== null && tabClass.length > 0) {
  95. $tip.removeClass(tabClass.join(''));
  96. }
  97. }; // Static
  98. Popover._jQueryInterface = function _jQueryInterface(config) {
  99. return this.each(function () {
  100. var data = $(this).data(DATA_KEY);
  101. var _config = typeof config === 'object' ? config : null;
  102. if (!data && /destroy|hide/.test(config)) {
  103. return;
  104. }
  105. if (!data) {
  106. data = new Popover(this, _config);
  107. $(this).data(DATA_KEY, data);
  108. }
  109. if (typeof config === 'string') {
  110. if (typeof data[config] === 'undefined') {
  111. throw new TypeError("No method named \"" + config + "\"");
  112. }
  113. data[config]();
  114. }
  115. });
  116. };
  117. _createClass(Popover, null, [{
  118. key: "VERSION",
  119. // Getters
  120. get: function get() {
  121. return VERSION;
  122. }
  123. }, {
  124. key: "Default",
  125. get: function get() {
  126. return Default;
  127. }
  128. }, {
  129. key: "NAME",
  130. get: function get() {
  131. return NAME;
  132. }
  133. }, {
  134. key: "DATA_KEY",
  135. get: function get() {
  136. return DATA_KEY;
  137. }
  138. }, {
  139. key: "Event",
  140. get: function get() {
  141. return Event;
  142. }
  143. }, {
  144. key: "EVENT_KEY",
  145. get: function get() {
  146. return EVENT_KEY;
  147. }
  148. }, {
  149. key: "DefaultType",
  150. get: function get() {
  151. return DefaultType;
  152. }
  153. }]);
  154. return Popover;
  155. }(Tooltip);
  156. /**
  157. * ------------------------------------------------------------------------
  158. * jQuery
  159. * ------------------------------------------------------------------------
  160. */
  161. $.fn[NAME] = Popover._jQueryInterface;
  162. $.fn[NAME].Constructor = Popover;
  163. $.fn[NAME].noConflict = function () {
  164. $.fn[NAME] = JQUERY_NO_CONFLICT;
  165. return Popover._jQueryInterface;
  166. };
  167. return Popover;
  168. }($);
  169. //# sourceMappingURL=popover.js.map