1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) :
3 typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) :
4 (global.Tooltip = factory(global.jQuery,global.Popper,global.Util));
5 }(this, (function ($,Popper,Util) { 'use strict';
7 $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8 Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
9 Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
11 function _defineProperties(target, props) {
12 for (var i = 0; i < props.length; i++) {
13 var descriptor = props[i];
14 descriptor.enumerable = descriptor.enumerable || false;
15 descriptor.configurable = true;
16 if ("value" in descriptor) descriptor.writable = true;
17 Object.defineProperty(target, descriptor.key, descriptor);
21 function _createClass(Constructor, protoProps, staticProps) {
22 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
23 if (staticProps) _defineProperties(Constructor, staticProps);
27 function _defineProperty(obj, key, value) {
29 Object.defineProperty(obj, key, {
42 function _objectSpread(target) {
43 for (var i = 1; i < arguments.length; i++) {
44 var source = arguments[i] != null ? arguments[i] : {};
45 var ownKeys = Object.keys(source);
47 if (typeof Object.getOwnPropertySymbols === 'function') {
48 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
49 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53 ownKeys.forEach(function (key) {
54 _defineProperty(target, key, source[key]);
62 * --------------------------------------------------------------------------
63 * Bootstrap (v4.1.3): tooltip.js
64 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
65 * --------------------------------------------------------------------------
68 var Tooltip = function ($$$1) {
70 * ------------------------------------------------------------------------
72 * ------------------------------------------------------------------------
75 var VERSION = '4.1.3';
76 var DATA_KEY = 'bs.tooltip';
77 var EVENT_KEY = "." + DATA_KEY;
78 var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
79 var CLASS_PREFIX = 'bs-tooltip';
80 var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
84 title: '(string|element|function)',
86 delay: '(number|object)',
88 selector: '(string|boolean)',
89 placement: '(string|function)',
90 offset: '(number|string)',
91 container: '(string|element|boolean)',
92 fallbackPlacement: '(string|array)',
93 boundary: '(string|element)'
104 template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
105 trigger: 'hover focus',
113 fallbackPlacement: 'flip',
114 boundary: 'scrollParent'
121 HIDE: "hide" + EVENT_KEY,
122 HIDDEN: "hidden" + EVENT_KEY,
123 SHOW: "show" + EVENT_KEY,
124 SHOWN: "shown" + EVENT_KEY,
125 INSERTED: "inserted" + EVENT_KEY,
126 CLICK: "click" + EVENT_KEY,
127 FOCUSIN: "focusin" + EVENT_KEY,
128 FOCUSOUT: "focusout" + EVENT_KEY,
129 MOUSEENTER: "mouseenter" + EVENT_KEY,
130 MOUSELEAVE: "mouseleave" + EVENT_KEY
138 TOOLTIP_INNER: '.tooltip-inner',
147 * ------------------------------------------------------------------------
149 * ------------------------------------------------------------------------
157 function Tooltip(element, config) {
159 * Check for Popper dependency
160 * Popper - https://popper.js.org
162 if (typeof Popper === 'undefined') {
163 throw new TypeError('Bootstrap tooltips require Popper.js (https://popper.js.org)');
167 this._isEnabled = true;
169 this._hoverState = '';
170 this._activeTrigger = {};
171 this._popper = null; // Protected
173 this.element = element;
174 this.config = this._getConfig(config);
177 this._setListeners();
181 var _proto = Tooltip.prototype;
184 _proto.enable = function enable() {
185 this._isEnabled = true;
188 _proto.disable = function disable() {
189 this._isEnabled = false;
192 _proto.toggleEnabled = function toggleEnabled() {
193 this._isEnabled = !this._isEnabled;
196 _proto.toggle = function toggle(event) {
197 if (!this._isEnabled) {
202 var dataKey = this.constructor.DATA_KEY;
203 var context = $$$1(event.currentTarget).data(dataKey);
206 context = new this.constructor(event.currentTarget, this._getDelegateConfig());
207 $$$1(event.currentTarget).data(dataKey, context);
210 context._activeTrigger.click = !context._activeTrigger.click;
212 if (context._isWithActiveTrigger()) {
213 context._enter(null, context);
215 context._leave(null, context);
218 if ($$$1(this.getTipElement()).hasClass(ClassName.SHOW)) {
219 this._leave(null, this);
224 this._enter(null, this);
228 _proto.dispose = function dispose() {
229 clearTimeout(this._timeout);
230 $$$1.removeData(this.element, this.constructor.DATA_KEY);
231 $$$1(this.element).off(this.constructor.EVENT_KEY);
232 $$$1(this.element).closest('.modal').off('hide.bs.modal');
235 $$$1(this.tip).remove();
238 this._isEnabled = null;
239 this._timeout = null;
240 this._hoverState = null;
241 this._activeTrigger = null;
243 if (this._popper !== null) {
244 this._popper.destroy();
253 _proto.show = function show() {
256 if ($$$1(this.element).css('display') === 'none') {
257 throw new Error('Please use show on visible elements');
260 var showEvent = $$$1.Event(this.constructor.Event.SHOW);
262 if (this.isWithContent() && this._isEnabled) {
263 $$$1(this.element).trigger(showEvent);
264 var isInTheDom = $$$1.contains(this.element.ownerDocument.documentElement, this.element);
266 if (showEvent.isDefaultPrevented() || !isInTheDom) {
270 var tip = this.getTipElement();
271 var tipId = Util.getUID(this.constructor.NAME);
272 tip.setAttribute('id', tipId);
273 this.element.setAttribute('aria-describedby', tipId);
276 if (this.config.animation) {
277 $$$1(tip).addClass(ClassName.FADE);
280 var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
282 var attachment = this._getAttachment(placement);
284 this.addAttachmentClass(attachment);
285 var container = this.config.container === false ? document.body : $$$1(document).find(this.config.container);
286 $$$1(tip).data(this.constructor.DATA_KEY, this);
288 if (!$$$1.contains(this.element.ownerDocument.documentElement, this.tip)) {
289 $$$1(tip).appendTo(container);
292 $$$1(this.element).trigger(this.constructor.Event.INSERTED);
293 this._popper = new Popper(this.element, tip, {
294 placement: attachment,
297 offset: this.config.offset
300 behavior: this.config.fallbackPlacement
303 element: Selector.ARROW
306 boundariesElement: this.config.boundary
309 onCreate: function onCreate(data) {
310 if (data.originalPlacement !== data.placement) {
311 _this._handlePopperPlacementChange(data);
314 onUpdate: function onUpdate(data) {
315 _this._handlePopperPlacementChange(data);
318 $$$1(tip).addClass(ClassName.SHOW); // If this is a touch-enabled device we add extra
319 // empty mouseover listeners to the body's immediate children;
320 // only needed because of broken event delegation on iOS
321 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
323 if ('ontouchstart' in document.documentElement) {
324 $$$1(document.body).children().on('mouseover', null, $$$1.noop);
327 var complete = function complete() {
328 if (_this.config.animation) {
329 _this._fixTransition();
332 var prevHoverState = _this._hoverState;
333 _this._hoverState = null;
334 $$$1(_this.element).trigger(_this.constructor.Event.SHOWN);
336 if (prevHoverState === HoverState.OUT) {
337 _this._leave(null, _this);
341 if ($$$1(this.tip).hasClass(ClassName.FADE)) {
342 var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
343 $$$1(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
350 _proto.hide = function hide(callback) {
353 var tip = this.getTipElement();
354 var hideEvent = $$$1.Event(this.constructor.Event.HIDE);
356 var complete = function complete() {
357 if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
358 tip.parentNode.removeChild(tip);
361 _this2._cleanTipClass();
363 _this2.element.removeAttribute('aria-describedby');
365 $$$1(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
367 if (_this2._popper !== null) {
368 _this2._popper.destroy();
376 $$$1(this.element).trigger(hideEvent);
378 if (hideEvent.isDefaultPrevented()) {
382 $$$1(tip).removeClass(ClassName.SHOW); // If this is a touch-enabled device we remove the extra
383 // empty mouseover listeners we added for iOS support
385 if ('ontouchstart' in document.documentElement) {
386 $$$1(document.body).children().off('mouseover', null, $$$1.noop);
389 this._activeTrigger[Trigger.CLICK] = false;
390 this._activeTrigger[Trigger.FOCUS] = false;
391 this._activeTrigger[Trigger.HOVER] = false;
393 if ($$$1(this.tip).hasClass(ClassName.FADE)) {
394 var transitionDuration = Util.getTransitionDurationFromElement(tip);
395 $$$1(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
400 this._hoverState = '';
403 _proto.update = function update() {
404 if (this._popper !== null) {
405 this._popper.scheduleUpdate();
410 _proto.isWithContent = function isWithContent() {
411 return Boolean(this.getTitle());
414 _proto.addAttachmentClass = function addAttachmentClass(attachment) {
415 $$$1(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
418 _proto.getTipElement = function getTipElement() {
419 this.tip = this.tip || $$$1(this.config.template)[0];
423 _proto.setContent = function setContent() {
424 var tip = this.getTipElement();
425 this.setElementContent($$$1(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle());
426 $$$1(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW);
429 _proto.setElementContent = function setElementContent($element, content) {
430 var html = this.config.html;
432 if (typeof content === 'object' && (content.nodeType || content.jquery)) {
433 // Content is a DOM node or a jQuery
435 if (!$$$1(content).parent().is($element)) {
436 $element.empty().append(content);
439 $element.text($$$1(content).text());
442 $element[html ? 'html' : 'text'](content);
446 _proto.getTitle = function getTitle() {
447 var title = this.element.getAttribute('data-original-title');
450 title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
457 _proto._getAttachment = function _getAttachment(placement) {
458 return AttachmentMap[placement.toUpperCase()];
461 _proto._setListeners = function _setListeners() {
464 var triggers = this.config.trigger.split(' ');
465 triggers.forEach(function (trigger) {
466 if (trigger === 'click') {
467 $$$1(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
468 return _this3.toggle(event);
470 } else if (trigger !== Trigger.MANUAL) {
471 var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
472 var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
473 $$$1(_this3.element).on(eventIn, _this3.config.selector, function (event) {
474 return _this3._enter(event);
475 }).on(eventOut, _this3.config.selector, function (event) {
476 return _this3._leave(event);
480 $$$1(_this3.element).closest('.modal').on('hide.bs.modal', function () {
481 return _this3.hide();
485 if (this.config.selector) {
486 this.config = _objectSpread({}, this.config, {
495 _proto._fixTitle = function _fixTitle() {
496 var titleType = typeof this.element.getAttribute('data-original-title');
498 if (this.element.getAttribute('title') || titleType !== 'string') {
499 this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
500 this.element.setAttribute('title', '');
504 _proto._enter = function _enter(event, context) {
505 var dataKey = this.constructor.DATA_KEY;
506 context = context || $$$1(event.currentTarget).data(dataKey);
509 context = new this.constructor(event.currentTarget, this._getDelegateConfig());
510 $$$1(event.currentTarget).data(dataKey, context);
514 context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
517 if ($$$1(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
518 context._hoverState = HoverState.SHOW;
522 clearTimeout(context._timeout);
523 context._hoverState = HoverState.SHOW;
525 if (!context.config.delay || !context.config.delay.show) {
530 context._timeout = setTimeout(function () {
531 if (context._hoverState === HoverState.SHOW) {
534 }, context.config.delay.show);
537 _proto._leave = function _leave(event, context) {
538 var dataKey = this.constructor.DATA_KEY;
539 context = context || $$$1(event.currentTarget).data(dataKey);
542 context = new this.constructor(event.currentTarget, this._getDelegateConfig());
543 $$$1(event.currentTarget).data(dataKey, context);
547 context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
550 if (context._isWithActiveTrigger()) {
554 clearTimeout(context._timeout);
555 context._hoverState = HoverState.OUT;
557 if (!context.config.delay || !context.config.delay.hide) {
562 context._timeout = setTimeout(function () {
563 if (context._hoverState === HoverState.OUT) {
566 }, context.config.delay.hide);
569 _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
570 for (var trigger in this._activeTrigger) {
571 if (this._activeTrigger[trigger]) {
579 _proto._getConfig = function _getConfig(config) {
580 config = _objectSpread({}, this.constructor.Default, $$$1(this.element).data(), typeof config === 'object' && config ? config : {});
582 if (typeof config.delay === 'number') {
589 if (typeof config.title === 'number') {
590 config.title = config.title.toString();
593 if (typeof config.content === 'number') {
594 config.content = config.content.toString();
597 Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
601 _proto._getDelegateConfig = function _getDelegateConfig() {
605 for (var key in this.config) {
606 if (this.constructor.Default[key] !== this.config[key]) {
607 config[key] = this.config[key];
615 _proto._cleanTipClass = function _cleanTipClass() {
616 var $tip = $$$1(this.getTipElement());
617 var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
619 if (tabClass !== null && tabClass.length) {
620 $tip.removeClass(tabClass.join(''));
624 _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
625 var popperInstance = popperData.instance;
626 this.tip = popperInstance.popper;
628 this._cleanTipClass();
630 this.addAttachmentClass(this._getAttachment(popperData.placement));
633 _proto._fixTransition = function _fixTransition() {
634 var tip = this.getTipElement();
635 var initConfigAnimation = this.config.animation;
637 if (tip.getAttribute('x-placement') !== null) {
641 $$$1(tip).removeClass(ClassName.FADE);
642 this.config.animation = false;
645 this.config.animation = initConfigAnimation;
649 Tooltip._jQueryInterface = function _jQueryInterface(config) {
650 return this.each(function () {
651 var data = $$$1(this).data(DATA_KEY);
653 var _config = typeof config === 'object' && config;
655 if (!data && /dispose|hide/.test(config)) {
660 data = new Tooltip(this, _config);
661 $$$1(this).data(DATA_KEY, data);
664 if (typeof config === 'string') {
665 if (typeof data[config] === 'undefined') {
666 throw new TypeError("No method named \"" + config + "\"");
674 _createClass(Tooltip, null, [{
676 get: function get() {
681 get: function get() {
686 get: function get() {
691 get: function get() {
696 get: function get() {
701 get: function get() {
706 get: function get() {
714 * ------------------------------------------------------------------------
716 * ------------------------------------------------------------------------
720 $$$1.fn[NAME] = Tooltip._jQueryInterface;
721 $$$1.fn[NAME].Constructor = Tooltip;
723 $$$1.fn[NAME].noConflict = function () {
724 $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
725 return Tooltip._jQueryInterface;
734 //# sourceMappingURL=tooltip.js.map