6217c27695d951d662bc097fb8efa5c31ae8a433.svn-base 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. (function (global, factory) {
  2. if (typeof define === 'function' && define.amd) {
  3. define(['exports', 'module', './tooltip'], factory);
  4. } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
  5. factory(exports, module, require('./tooltip'));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, mod, global.Tooltip);
  11. global.popover = mod.exports;
  12. }
  13. })(this, function (exports, module, _tooltip) {
  14. 'use strict';
  15. var _createClass = (function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  16. var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
  17. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  18. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  19. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  20. var _Tooltip2 = _interopRequireDefault(_tooltip);
  21. /**
  22. * --------------------------------------------------------------------------
  23. * Bootstrap (v4.0.0): popover.js
  24. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  25. * --------------------------------------------------------------------------
  26. */
  27. var Popover = (function ($) {
  28. /**
  29. * ------------------------------------------------------------------------
  30. * Constants
  31. * ------------------------------------------------------------------------
  32. */
  33. var NAME = 'popover';
  34. var VERSION = '4.0.0';
  35. var DATA_KEY = 'bs.popover';
  36. var EVENT_KEY = '.' + DATA_KEY;
  37. var JQUERY_NO_CONFLICT = $.fn[NAME];
  38. var Default = $.extend({}, _Tooltip2['default'].Default, {
  39. placement: 'right',
  40. trigger: 'click',
  41. content: '',
  42. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>'
  43. });
  44. var DefaultType = $.extend({}, _Tooltip2['default'].DefaultType, {
  45. content: '(string|function)'
  46. });
  47. var ClassName = {
  48. FADE: 'fade',
  49. IN: 'in'
  50. };
  51. var Selector = {
  52. TITLE: '.popover-title',
  53. CONTENT: '.popover-content',
  54. ARROW: '.popover-arrow'
  55. };
  56. var Event = {
  57. HIDE: 'hide' + EVENT_KEY,
  58. HIDDEN: 'hidden' + EVENT_KEY,
  59. SHOW: 'show' + EVENT_KEY,
  60. SHOWN: 'shown' + EVENT_KEY,
  61. INSERTED: 'inserted' + EVENT_KEY,
  62. CLICK: 'click' + EVENT_KEY,
  63. FOCUSIN: 'focusin' + EVENT_KEY,
  64. FOCUSOUT: 'focusout' + EVENT_KEY,
  65. MOUSEENTER: 'mouseenter' + EVENT_KEY,
  66. MOUSELEAVE: 'mouseleave' + EVENT_KEY
  67. };
  68. /**
  69. * ------------------------------------------------------------------------
  70. * Class Definition
  71. * ------------------------------------------------------------------------
  72. */
  73. var Popover = (function (_Tooltip) {
  74. _inherits(Popover, _Tooltip);
  75. function Popover() {
  76. _classCallCheck(this, Popover);
  77. _get(Object.getPrototypeOf(Popover.prototype), 'constructor', this).apply(this, arguments);
  78. }
  79. /**
  80. * ------------------------------------------------------------------------
  81. * jQuery
  82. * ------------------------------------------------------------------------
  83. */
  84. _createClass(Popover, [{
  85. key: 'isWithContent',
  86. // overrides
  87. value: function isWithContent() {
  88. return this.getTitle() || this._getContent();
  89. }
  90. }, {
  91. key: 'getTipElement',
  92. value: function getTipElement() {
  93. return this.tip = this.tip || $(this.config.template)[0];
  94. }
  95. }, {
  96. key: 'setContent',
  97. value: function setContent() {
  98. var tip = this.getTipElement();
  99. var title = this.getTitle();
  100. var content = this._getContent();
  101. var titleElement = $(tip).find(Selector.TITLE)[0];
  102. if (titleElement) {
  103. titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title;
  104. }
  105. // we use append for html objects to maintain js events
  106. $(tip).find(Selector.CONTENT).children().detach().end()[this.config.html ? typeof content === 'string' ? 'html' : 'append' : 'text'](content);
  107. $(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);
  108. this.cleanupTether();
  109. }
  110. // private
  111. }, {
  112. key: '_getContent',
  113. value: function _getContent() {
  114. return this.element.getAttribute('data-content') || (typeof this.config.content === 'function' ? this.config.content.call(this.element) : this.config.content);
  115. }
  116. // static
  117. }], [{
  118. key: '_jQueryInterface',
  119. value: function _jQueryInterface(config) {
  120. return this.each(function () {
  121. var data = $(this).data(DATA_KEY);
  122. var _config = typeof config === 'object' ? config : null;
  123. if (!data && /destroy|hide/.test(config)) {
  124. return;
  125. }
  126. if (!data) {
  127. data = new Popover(this, _config);
  128. $(this).data(DATA_KEY, data);
  129. }
  130. if (typeof config === 'string') {
  131. data[config]();
  132. }
  133. });
  134. }
  135. }, {
  136. key: 'VERSION',
  137. // getters
  138. get: function get() {
  139. return VERSION;
  140. }
  141. }, {
  142. key: 'Default',
  143. get: function get() {
  144. return Default;
  145. }
  146. }, {
  147. key: 'NAME',
  148. get: function get() {
  149. return NAME;
  150. }
  151. }, {
  152. key: 'DATA_KEY',
  153. get: function get() {
  154. return DATA_KEY;
  155. }
  156. }, {
  157. key: 'Event',
  158. get: function get() {
  159. return Event;
  160. }
  161. }, {
  162. key: 'EVENT_KEY',
  163. get: function get() {
  164. return EVENT_KEY;
  165. }
  166. }, {
  167. key: 'DefaultType',
  168. get: function get() {
  169. return DefaultType;
  170. }
  171. }]);
  172. return Popover;
  173. })(_Tooltip2['default']);
  174. $.fn[NAME] = Popover._jQueryInterface;
  175. $.fn[NAME].Constructor = Popover;
  176. $.fn[NAME].noConflict = function () {
  177. $.fn[NAME] = JQUERY_NO_CONFLICT;
  178. return Popover._jQueryInterface;
  179. };
  180. return Popover;
  181. })(jQuery);
  182. module.exports = Popover;
  183. });