OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / tools / side_chain_tool / web / node_modules / bootstrap / js / dist / tooltip.js
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';
6
7   $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8   Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
9   Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
10
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);
18     }
19   }
20
21   function _createClass(Constructor, protoProps, staticProps) {
22     if (protoProps) _defineProperties(Constructor.prototype, protoProps);
23     if (staticProps) _defineProperties(Constructor, staticProps);
24     return Constructor;
25   }
26
27   function _defineProperty(obj, key, value) {
28     if (key in obj) {
29       Object.defineProperty(obj, key, {
30         value: value,
31         enumerable: true,
32         configurable: true,
33         writable: true
34       });
35     } else {
36       obj[key] = value;
37     }
38
39     return obj;
40   }
41
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);
46
47       if (typeof Object.getOwnPropertySymbols === 'function') {
48         ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
49           return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50         }));
51       }
52
53       ownKeys.forEach(function (key) {
54         _defineProperty(target, key, source[key]);
55       });
56     }
57
58     return target;
59   }
60
61   /**
62    * --------------------------------------------------------------------------
63    * Bootstrap (v4.1.3): tooltip.js
64    * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
65    * --------------------------------------------------------------------------
66    */
67
68   var Tooltip = function ($$$1) {
69     /**
70      * ------------------------------------------------------------------------
71      * Constants
72      * ------------------------------------------------------------------------
73      */
74     var NAME = 'tooltip';
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');
81     var DefaultType = {
82       animation: 'boolean',
83       template: 'string',
84       title: '(string|element|function)',
85       trigger: 'string',
86       delay: '(number|object)',
87       html: 'boolean',
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)'
94     };
95     var AttachmentMap = {
96       AUTO: 'auto',
97       TOP: 'top',
98       RIGHT: 'right',
99       BOTTOM: 'bottom',
100       LEFT: 'left'
101     };
102     var Default = {
103       animation: true,
104       template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
105       trigger: 'hover focus',
106       title: '',
107       delay: 0,
108       html: false,
109       selector: false,
110       placement: 'top',
111       offset: 0,
112       container: false,
113       fallbackPlacement: 'flip',
114       boundary: 'scrollParent'
115     };
116     var HoverState = {
117       SHOW: 'show',
118       OUT: 'out'
119     };
120     var Event = {
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
131     };
132     var ClassName = {
133       FADE: 'fade',
134       SHOW: 'show'
135     };
136     var Selector = {
137       TOOLTIP: '.tooltip',
138       TOOLTIP_INNER: '.tooltip-inner',
139       ARROW: '.arrow'
140     };
141     var Trigger = {
142       HOVER: 'hover',
143       FOCUS: 'focus',
144       CLICK: 'click',
145       MANUAL: 'manual'
146       /**
147        * ------------------------------------------------------------------------
148        * Class Definition
149        * ------------------------------------------------------------------------
150        */
151
152     };
153
154     var Tooltip =
155     /*#__PURE__*/
156     function () {
157       function Tooltip(element, config) {
158         /**
159          * Check for Popper dependency
160          * Popper - https://popper.js.org
161          */
162         if (typeof Popper === 'undefined') {
163           throw new TypeError('Bootstrap tooltips require Popper.js (https://popper.js.org)');
164         } // private
165
166
167         this._isEnabled = true;
168         this._timeout = 0;
169         this._hoverState = '';
170         this._activeTrigger = {};
171         this._popper = null; // Protected
172
173         this.element = element;
174         this.config = this._getConfig(config);
175         this.tip = null;
176
177         this._setListeners();
178       } // Getters
179
180
181       var _proto = Tooltip.prototype;
182
183       // Public
184       _proto.enable = function enable() {
185         this._isEnabled = true;
186       };
187
188       _proto.disable = function disable() {
189         this._isEnabled = false;
190       };
191
192       _proto.toggleEnabled = function toggleEnabled() {
193         this._isEnabled = !this._isEnabled;
194       };
195
196       _proto.toggle = function toggle(event) {
197         if (!this._isEnabled) {
198           return;
199         }
200
201         if (event) {
202           var dataKey = this.constructor.DATA_KEY;
203           var context = $$$1(event.currentTarget).data(dataKey);
204
205           if (!context) {
206             context = new this.constructor(event.currentTarget, this._getDelegateConfig());
207             $$$1(event.currentTarget).data(dataKey, context);
208           }
209
210           context._activeTrigger.click = !context._activeTrigger.click;
211
212           if (context._isWithActiveTrigger()) {
213             context._enter(null, context);
214           } else {
215             context._leave(null, context);
216           }
217         } else {
218           if ($$$1(this.getTipElement()).hasClass(ClassName.SHOW)) {
219             this._leave(null, this);
220
221             return;
222           }
223
224           this._enter(null, this);
225         }
226       };
227
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');
233
234         if (this.tip) {
235           $$$1(this.tip).remove();
236         }
237
238         this._isEnabled = null;
239         this._timeout = null;
240         this._hoverState = null;
241         this._activeTrigger = null;
242
243         if (this._popper !== null) {
244           this._popper.destroy();
245         }
246
247         this._popper = null;
248         this.element = null;
249         this.config = null;
250         this.tip = null;
251       };
252
253       _proto.show = function show() {
254         var _this = this;
255
256         if ($$$1(this.element).css('display') === 'none') {
257           throw new Error('Please use show on visible elements');
258         }
259
260         var showEvent = $$$1.Event(this.constructor.Event.SHOW);
261
262         if (this.isWithContent() && this._isEnabled) {
263           $$$1(this.element).trigger(showEvent);
264           var isInTheDom = $$$1.contains(this.element.ownerDocument.documentElement, this.element);
265
266           if (showEvent.isDefaultPrevented() || !isInTheDom) {
267             return;
268           }
269
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);
274           this.setContent();
275
276           if (this.config.animation) {
277             $$$1(tip).addClass(ClassName.FADE);
278           }
279
280           var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
281
282           var attachment = this._getAttachment(placement);
283
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);
287
288           if (!$$$1.contains(this.element.ownerDocument.documentElement, this.tip)) {
289             $$$1(tip).appendTo(container);
290           }
291
292           $$$1(this.element).trigger(this.constructor.Event.INSERTED);
293           this._popper = new Popper(this.element, tip, {
294             placement: attachment,
295             modifiers: {
296               offset: {
297                 offset: this.config.offset
298               },
299               flip: {
300                 behavior: this.config.fallbackPlacement
301               },
302               arrow: {
303                 element: Selector.ARROW
304               },
305               preventOverflow: {
306                 boundariesElement: this.config.boundary
307               }
308             },
309             onCreate: function onCreate(data) {
310               if (data.originalPlacement !== data.placement) {
311                 _this._handlePopperPlacementChange(data);
312               }
313             },
314             onUpdate: function onUpdate(data) {
315               _this._handlePopperPlacementChange(data);
316             }
317           });
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
322
323           if ('ontouchstart' in document.documentElement) {
324             $$$1(document.body).children().on('mouseover', null, $$$1.noop);
325           }
326
327           var complete = function complete() {
328             if (_this.config.animation) {
329               _this._fixTransition();
330             }
331
332             var prevHoverState = _this._hoverState;
333             _this._hoverState = null;
334             $$$1(_this.element).trigger(_this.constructor.Event.SHOWN);
335
336             if (prevHoverState === HoverState.OUT) {
337               _this._leave(null, _this);
338             }
339           };
340
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);
344           } else {
345             complete();
346           }
347         }
348       };
349
350       _proto.hide = function hide(callback) {
351         var _this2 = this;
352
353         var tip = this.getTipElement();
354         var hideEvent = $$$1.Event(this.constructor.Event.HIDE);
355
356         var complete = function complete() {
357           if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
358             tip.parentNode.removeChild(tip);
359           }
360
361           _this2._cleanTipClass();
362
363           _this2.element.removeAttribute('aria-describedby');
364
365           $$$1(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
366
367           if (_this2._popper !== null) {
368             _this2._popper.destroy();
369           }
370
371           if (callback) {
372             callback();
373           }
374         };
375
376         $$$1(this.element).trigger(hideEvent);
377
378         if (hideEvent.isDefaultPrevented()) {
379           return;
380         }
381
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
384
385         if ('ontouchstart' in document.documentElement) {
386           $$$1(document.body).children().off('mouseover', null, $$$1.noop);
387         }
388
389         this._activeTrigger[Trigger.CLICK] = false;
390         this._activeTrigger[Trigger.FOCUS] = false;
391         this._activeTrigger[Trigger.HOVER] = false;
392
393         if ($$$1(this.tip).hasClass(ClassName.FADE)) {
394           var transitionDuration = Util.getTransitionDurationFromElement(tip);
395           $$$1(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
396         } else {
397           complete();
398         }
399
400         this._hoverState = '';
401       };
402
403       _proto.update = function update() {
404         if (this._popper !== null) {
405           this._popper.scheduleUpdate();
406         }
407       }; // Protected
408
409
410       _proto.isWithContent = function isWithContent() {
411         return Boolean(this.getTitle());
412       };
413
414       _proto.addAttachmentClass = function addAttachmentClass(attachment) {
415         $$$1(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
416       };
417
418       _proto.getTipElement = function getTipElement() {
419         this.tip = this.tip || $$$1(this.config.template)[0];
420         return this.tip;
421       };
422
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);
427       };
428
429       _proto.setElementContent = function setElementContent($element, content) {
430         var html = this.config.html;
431
432         if (typeof content === 'object' && (content.nodeType || content.jquery)) {
433           // Content is a DOM node or a jQuery
434           if (html) {
435             if (!$$$1(content).parent().is($element)) {
436               $element.empty().append(content);
437             }
438           } else {
439             $element.text($$$1(content).text());
440           }
441         } else {
442           $element[html ? 'html' : 'text'](content);
443         }
444       };
445
446       _proto.getTitle = function getTitle() {
447         var title = this.element.getAttribute('data-original-title');
448
449         if (!title) {
450           title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
451         }
452
453         return title;
454       }; // Private
455
456
457       _proto._getAttachment = function _getAttachment(placement) {
458         return AttachmentMap[placement.toUpperCase()];
459       };
460
461       _proto._setListeners = function _setListeners() {
462         var _this3 = this;
463
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);
469             });
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);
477             });
478           }
479
480           $$$1(_this3.element).closest('.modal').on('hide.bs.modal', function () {
481             return _this3.hide();
482           });
483         });
484
485         if (this.config.selector) {
486           this.config = _objectSpread({}, this.config, {
487             trigger: 'manual',
488             selector: ''
489           });
490         } else {
491           this._fixTitle();
492         }
493       };
494
495       _proto._fixTitle = function _fixTitle() {
496         var titleType = typeof this.element.getAttribute('data-original-title');
497
498         if (this.element.getAttribute('title') || titleType !== 'string') {
499           this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
500           this.element.setAttribute('title', '');
501         }
502       };
503
504       _proto._enter = function _enter(event, context) {
505         var dataKey = this.constructor.DATA_KEY;
506         context = context || $$$1(event.currentTarget).data(dataKey);
507
508         if (!context) {
509           context = new this.constructor(event.currentTarget, this._getDelegateConfig());
510           $$$1(event.currentTarget).data(dataKey, context);
511         }
512
513         if (event) {
514           context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
515         }
516
517         if ($$$1(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
518           context._hoverState = HoverState.SHOW;
519           return;
520         }
521
522         clearTimeout(context._timeout);
523         context._hoverState = HoverState.SHOW;
524
525         if (!context.config.delay || !context.config.delay.show) {
526           context.show();
527           return;
528         }
529
530         context._timeout = setTimeout(function () {
531           if (context._hoverState === HoverState.SHOW) {
532             context.show();
533           }
534         }, context.config.delay.show);
535       };
536
537       _proto._leave = function _leave(event, context) {
538         var dataKey = this.constructor.DATA_KEY;
539         context = context || $$$1(event.currentTarget).data(dataKey);
540
541         if (!context) {
542           context = new this.constructor(event.currentTarget, this._getDelegateConfig());
543           $$$1(event.currentTarget).data(dataKey, context);
544         }
545
546         if (event) {
547           context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
548         }
549
550         if (context._isWithActiveTrigger()) {
551           return;
552         }
553
554         clearTimeout(context._timeout);
555         context._hoverState = HoverState.OUT;
556
557         if (!context.config.delay || !context.config.delay.hide) {
558           context.hide();
559           return;
560         }
561
562         context._timeout = setTimeout(function () {
563           if (context._hoverState === HoverState.OUT) {
564             context.hide();
565           }
566         }, context.config.delay.hide);
567       };
568
569       _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
570         for (var trigger in this._activeTrigger) {
571           if (this._activeTrigger[trigger]) {
572             return true;
573           }
574         }
575
576         return false;
577       };
578
579       _proto._getConfig = function _getConfig(config) {
580         config = _objectSpread({}, this.constructor.Default, $$$1(this.element).data(), typeof config === 'object' && config ? config : {});
581
582         if (typeof config.delay === 'number') {
583           config.delay = {
584             show: config.delay,
585             hide: config.delay
586           };
587         }
588
589         if (typeof config.title === 'number') {
590           config.title = config.title.toString();
591         }
592
593         if (typeof config.content === 'number') {
594           config.content = config.content.toString();
595         }
596
597         Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
598         return config;
599       };
600
601       _proto._getDelegateConfig = function _getDelegateConfig() {
602         var config = {};
603
604         if (this.config) {
605           for (var key in this.config) {
606             if (this.constructor.Default[key] !== this.config[key]) {
607               config[key] = this.config[key];
608             }
609           }
610         }
611
612         return config;
613       };
614
615       _proto._cleanTipClass = function _cleanTipClass() {
616         var $tip = $$$1(this.getTipElement());
617         var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
618
619         if (tabClass !== null && tabClass.length) {
620           $tip.removeClass(tabClass.join(''));
621         }
622       };
623
624       _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
625         var popperInstance = popperData.instance;
626         this.tip = popperInstance.popper;
627
628         this._cleanTipClass();
629
630         this.addAttachmentClass(this._getAttachment(popperData.placement));
631       };
632
633       _proto._fixTransition = function _fixTransition() {
634         var tip = this.getTipElement();
635         var initConfigAnimation = this.config.animation;
636
637         if (tip.getAttribute('x-placement') !== null) {
638           return;
639         }
640
641         $$$1(tip).removeClass(ClassName.FADE);
642         this.config.animation = false;
643         this.hide();
644         this.show();
645         this.config.animation = initConfigAnimation;
646       }; // Static
647
648
649       Tooltip._jQueryInterface = function _jQueryInterface(config) {
650         return this.each(function () {
651           var data = $$$1(this).data(DATA_KEY);
652
653           var _config = typeof config === 'object' && config;
654
655           if (!data && /dispose|hide/.test(config)) {
656             return;
657           }
658
659           if (!data) {
660             data = new Tooltip(this, _config);
661             $$$1(this).data(DATA_KEY, data);
662           }
663
664           if (typeof config === 'string') {
665             if (typeof data[config] === 'undefined') {
666               throw new TypeError("No method named \"" + config + "\"");
667             }
668
669             data[config]();
670           }
671         });
672       };
673
674       _createClass(Tooltip, null, [{
675         key: "VERSION",
676         get: function get() {
677           return VERSION;
678         }
679       }, {
680         key: "Default",
681         get: function get() {
682           return Default;
683         }
684       }, {
685         key: "NAME",
686         get: function get() {
687           return NAME;
688         }
689       }, {
690         key: "DATA_KEY",
691         get: function get() {
692           return DATA_KEY;
693         }
694       }, {
695         key: "Event",
696         get: function get() {
697           return Event;
698         }
699       }, {
700         key: "EVENT_KEY",
701         get: function get() {
702           return EVENT_KEY;
703         }
704       }, {
705         key: "DefaultType",
706         get: function get() {
707           return DefaultType;
708         }
709       }]);
710
711       return Tooltip;
712     }();
713     /**
714      * ------------------------------------------------------------------------
715      * jQuery
716      * ------------------------------------------------------------------------
717      */
718
719
720     $$$1.fn[NAME] = Tooltip._jQueryInterface;
721     $$$1.fn[NAME].Constructor = Tooltip;
722
723     $$$1.fn[NAME].noConflict = function () {
724       $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
725       return Tooltip._jQueryInterface;
726     };
727
728     return Tooltip;
729   }($, Popper);
730
731   return Tooltip;
732
733 })));
734 //# sourceMappingURL=tooltip.js.map