]>
Commit | Line | Data |
---|---|---|
91e44d91 S |
1 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
2 | ||
3 | 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; }; }(); | |
4 | ||
5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
6 | ||
7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | |
8 | ||
9 | 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; } | |
10 | ||
11 | /** | |
12 | * -------------------------------------------------------------------------- | |
13 | * Bootstrap (v4.0.0-alpha.6): popover.js | |
14 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | |
15 | * -------------------------------------------------------------------------- | |
16 | */ | |
17 | ||
18 | var Popover = function ($) { | |
19 | ||
20 | /** | |
21 | * ------------------------------------------------------------------------ | |
22 | * Constants | |
23 | * ------------------------------------------------------------------------ | |
24 | */ | |
25 | ||
26 | var NAME = 'popover'; | |
27 | var VERSION = '4.0.0-alpha.6'; | |
28 | var DATA_KEY = 'bs.popover'; | |
29 | var EVENT_KEY = '.' + DATA_KEY; | |
30 | var JQUERY_NO_CONFLICT = $.fn[NAME]; | |
31 | ||
32 | var Default = $.extend({}, Tooltip.Default, { | |
33 | placement: 'right', | |
34 | trigger: 'click', | |
35 | content: '', | |
36 | template: '<div class="popover" role="tooltip">' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>' | |
37 | }); | |
38 | ||
39 | var DefaultType = $.extend({}, Tooltip.DefaultType, { | |
40 | content: '(string|element|function)' | |
41 | }); | |
42 | ||
43 | var ClassName = { | |
44 | FADE: 'fade', | |
45 | SHOW: 'show' | |
46 | }; | |
47 | ||
48 | var Selector = { | |
49 | TITLE: '.popover-title', | |
50 | CONTENT: '.popover-content' | |
51 | }; | |
52 | ||
53 | var Event = { | |
54 | HIDE: 'hide' + EVENT_KEY, | |
55 | HIDDEN: 'hidden' + EVENT_KEY, | |
56 | SHOW: 'show' + EVENT_KEY, | |
57 | SHOWN: 'shown' + EVENT_KEY, | |
58 | INSERTED: 'inserted' + EVENT_KEY, | |
59 | CLICK: 'click' + EVENT_KEY, | |
60 | FOCUSIN: 'focusin' + EVENT_KEY, | |
61 | FOCUSOUT: 'focusout' + EVENT_KEY, | |
62 | MOUSEENTER: 'mouseenter' + EVENT_KEY, | |
63 | MOUSELEAVE: 'mouseleave' + EVENT_KEY | |
64 | }; | |
65 | ||
66 | /** | |
67 | * ------------------------------------------------------------------------ | |
68 | * Class Definition | |
69 | * ------------------------------------------------------------------------ | |
70 | */ | |
71 | ||
72 | var Popover = function (_Tooltip) { | |
73 | _inherits(Popover, _Tooltip); | |
74 | ||
75 | function Popover() { | |
76 | _classCallCheck(this, Popover); | |
77 | ||
78 | return _possibleConstructorReturn(this, _Tooltip.apply(this, arguments)); | |
79 | } | |
80 | ||
81 | // overrides | |
82 | ||
83 | Popover.prototype.isWithContent = function isWithContent() { | |
84 | return this.getTitle() || this._getContent(); | |
85 | }; | |
86 | ||
87 | Popover.prototype.getTipElement = function getTipElement() { | |
88 | return this.tip = this.tip || $(this.config.template)[0]; | |
89 | }; | |
90 | ||
91 | Popover.prototype.setContent = function setContent() { | |
92 | var $tip = $(this.getTipElement()); | |
93 | ||
94 | // we use append for html objects to maintain js events | |
95 | this.setElementContent($tip.find(Selector.TITLE), this.getTitle()); | |
96 | this.setElementContent($tip.find(Selector.CONTENT), this._getContent()); | |
97 | ||
98 | $tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW); | |
99 | ||
100 | this.cleanupTether(); | |
101 | }; | |
102 | ||
103 | // private | |
104 | ||
105 | Popover.prototype._getContent = function _getContent() { | |
106 | return this.element.getAttribute('data-content') || (typeof this.config.content === 'function' ? this.config.content.call(this.element) : this.config.content); | |
107 | }; | |
108 | ||
109 | // static | |
110 | ||
111 | Popover._jQueryInterface = function _jQueryInterface(config) { | |
112 | return this.each(function () { | |
113 | var data = $(this).data(DATA_KEY); | |
114 | var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' ? config : null; | |
115 | ||
116 | if (!data && /destroy|hide/.test(config)) { | |
117 | return; | |
118 | } | |
119 | ||
120 | if (!data) { | |
121 | data = new Popover(this, _config); | |
122 | $(this).data(DATA_KEY, data); | |
123 | } | |
124 | ||
125 | if (typeof config === 'string') { | |
126 | if (data[config] === undefined) { | |
127 | throw new Error('No method named "' + config + '"'); | |
128 | } | |
129 | data[config](); | |
130 | } | |
131 | }); | |
132 | }; | |
133 | ||
134 | _createClass(Popover, null, [{ | |
135 | key: 'VERSION', | |
136 | ||
137 | ||
138 | // getters | |
139 | ||
140 | get: function get() { | |
141 | return VERSION; | |
142 | } | |
143 | }, { | |
144 | key: 'Default', | |
145 | get: function get() { | |
146 | return Default; | |
147 | } | |
148 | }, { | |
149 | key: 'NAME', | |
150 | get: function get() { | |
151 | return NAME; | |
152 | } | |
153 | }, { | |
154 | key: 'DATA_KEY', | |
155 | get: function get() { | |
156 | return DATA_KEY; | |
157 | } | |
158 | }, { | |
159 | key: 'Event', | |
160 | get: function get() { | |
161 | return Event; | |
162 | } | |
163 | }, { | |
164 | key: 'EVENT_KEY', | |
165 | get: function get() { | |
166 | return EVENT_KEY; | |
167 | } | |
168 | }, { | |
169 | key: 'DefaultType', | |
170 | get: function get() { | |
171 | return DefaultType; | |
172 | } | |
173 | }]); | |
174 | ||
175 | return Popover; | |
176 | }(Tooltip); | |
177 | ||
178 | /** | |
179 | * ------------------------------------------------------------------------ | |
180 | * jQuery | |
181 | * ------------------------------------------------------------------------ | |
182 | */ | |
183 | ||
184 | $.fn[NAME] = Popover._jQueryInterface; | |
185 | $.fn[NAME].Constructor = Popover; | |
186 | $.fn[NAME].noConflict = function () { | |
187 | $.fn[NAME] = JQUERY_NO_CONFLICT; | |
188 | return Popover._jQueryInterface; | |
189 | }; | |
190 | ||
191 | return Popover; | |
192 | }(jQuery); | |
193 | //# sourceMappingURL=popover.js.map |