PageSourceSearch

https://www.n-ergie.de/public/assets/dist/js/app/vendor/bootstrap/tooltip.js

js n-ergie.de collected 2026-10-02 06:49:06 UTC 23,667 bytes, 682 lines download raw bytes

1var _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
3var _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
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7/**
8 * --------------------------------------------------------------------------
9 * Bootstrap (v4.0.0-beta): tooltip.js
10 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11 * --------------------------------------------------------------------------
12 */
13
14var Tooltip = function ($) {
15
16    /**
17     * Check for Popper dependency
18     * Popper - https://popper.js.org
19     */
20    if (typeof Popper === 'undefined') {
21        // throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)');
22    }
23
24    /**
25     * ------------------------------------------------------------------------
26     * Constants
27     * ------------------------------------------------------------------------
28     */
29
30    var NAME = 'tooltip';
31    var VERSION = '4.0.0-beta';
32    var DATA_KEY = 'bs.tooltip';
33    var EVENT_KEY = '.' + DATA_KEY;
34    var JQUERY_NO_CONFLICT = $.fn[NAME];
35    var TRANSITION_DURATION = 150;
36    var CLASS_PREFIX = 'bs-tooltip';
37    var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g');
38
39    var DefaultType = {
40        animation: 'boolean',
41        template: 'string',
42        title: '(string|element|function)',
43        trigger: 'string',
44        delay: '(number|object)',
45        html: 'boolean',
46        selector: '(string|boolean)',
47        placement: '(string|function)',
48        offset: '(number|string)',
49        container: '(string|element|boolean)',
50        fallbackPlacement: '(string|array)'
51    };
52
53    var AttachmentMap = {
54        AUTO: 'auto',
55        TOP: 'top',
56        RIGHT: 'right',
57        BOTTOM: 'bottom',
58        LEFT: 'left'
59    };
60
61    var Default = {
62        animation: true,
63        template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
64        trigger: 'hover focus',
65        title: '',
66        delay: 0,
67        html: false,
68        selector: false,
69        placement: 'top',
70        offset: 0,
71        container: false,
72        fallbackPlacement: 'flip'
73    };
74
75    var HoverState = {
76        SHOW: 'show',
77        OUT: 'out'
78    };
79
80    var Event = {
81        HIDE: 'hide' + EVENT_KEY,
82        HIDDEN: 'hidden' + EVENT_KEY,
83        SHOW: 'show' + EVENT_KEY,
84        SHOWN: 'shown' + EVENT_KEY,
85        INSERTED: 'inserted' + EVENT_KEY,
86        CLICK: 'click' + EVENT_KEY,
87        FOCUSIN: 'focusin' + EVENT_KEY,
88        FOCUSOUT: 'focusout' + EVENT_KEY,
89        MOUSEENTER: 'mouseenter' + EVENT_KEY,
90        MOUSELEAVE: 'mouseleave' + EVENT_KEY
91    };
92
93    var ClassName = {
94        FADE: 'fade',
95        SHOW: 'show'
96    };
97
98    var Selector = {
99        TOOLTIP: '.tooltip',
100        TOOLTIP_INNER: '.tooltip-inner',
101        ARROW: '.arrow'
102    };
103
104    var Trigger = {
105        HOVER: 'hover',
106        FOCUS: 'focus',
107        CLICK: 'click',
108        MANUAL: 'manual'
109
110        /**
111         * ------------------------------------------------------------------------
112         * Class Definition
113         * ------------------------------------------------------------------------
114         */
115
116    };
117    var Tooltip = function () {
118        function Tooltip(element, config) {
119            _classCallCheck(this, Tooltip);
120
121            // private
122            this._isEnabled = true;
123            this._timeout = 0;
124            this._hoverState = '';
125            this._activeTrigger = {};
126            this._popper = null;
127
128            // protected
129            this.element = element;
130            this.config = this._getConfig(config);
131            this.tip = null;
132
133            this._setListeners();
134        }
135
136        // getters
137
138        // public
139
140        Tooltip.prototype.enable = function enable() {
141            this._isEnabled = true;
142        };
143
144        Tooltip.prototype.disable = function disable() {
145            this._isEnabled = false;
146        };
147
148        Tooltip.prototype.toggleEnabled = function toggleEnabled() {
149            this._isEnabled = !this._isEnabled;
150        };
151
152        Tooltip.prototype.toggle = function toggle(event) {
153            if (event) {
154                var dataKey = this.constructor.DATA_KEY;
155                var context = $(event.currentTarget).data(dataKey);
156
157                if (!context) {
158                    context = new this.constructor(event.currentTarget, this._getDelegateConfig());
159                    $(event.currentTarget).data(dataKey, context);
160                }
161
162                context._activeTrigger.click = !context._activeTrigger.click;
163
164                if (context._isWithActiveTrigger()) {
165                    context._enter(null, context);
166                } else {
167                    context._leave(null, context);
168                }
169            } else {
170
171                if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
172                    this._leave(null, this);
173                    return;
174                }
175
176                this._enter(null, this);
177            }
178        };
179
180        Tooltip.prototype.dispose = function dispose() {
181            clearTimeout(this._timeout);
182
183            $.removeData(this.element, this.constructor.DATA_KEY);
184
185            $(this.element).off(this.constructor.EVENT_KEY);
186            $(this.element).closest('.modal').off('hide.bs.modal');
187
188            if (this.tip) {
189                $(this.tip).remove();
190            }
191
192            this._isEnabled = null;
193            this._timeout = null;
194            this._hoverState = null;
195            this._activeTrigger = null;
196            if (this._popper !== null) {
197                this._popper.destroy();
198            }
199            this._popper = null;
200
201            this.element = null;
202            this.config = null;
203            this.tip = null;
204        };
205
206        Tooltip.prototype.show = function show() {
207            var _this = this;
208
209            if ($(this.element).css('display') === 'none') {
210                throw new Error('Please use show on visible elements');
211            }
212
213            var showEvent = $.Event(this.constructor.Event.SHOW);
214            if (this.isWithContent() && this._isEnabled) {
215                $(this.element).trigger(showEvent);
216
217                var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
218
219                if (showEvent.isDefaultPrevented() || !isInTheDom) {
220                    return;
221                }
222
223                var tip = this.getTipElement();
224                var tipId = Util.getUID(this.constructor.NAME);
225
226                tip.setAttribute('id', tipId);
227                this.element.setAttribute('aria-describedby', tipId);
228
229                this.setContent();
230
231                if (this.config.animation) {
232                    $(tip).addClass(ClassName.FADE);
233                }
234
235                var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
236
237                var attachment = this._getAttachment(placement);
238                this.addAttachmentClass(attachment);
239
240                var container = this.config.container === false ? document.body : $(this.config.container);
241
242                $(tip).data(this.constructor.DATA_KEY, this);
243
244                if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
245                    $(tip).appendTo(container);
246                }
247
248                $(this.element).trigger(this.constructor.Event.INSERTED);
249
250                this._popper = new Popper(this.element, tip, {
251                    placement: attachment,
252                    modifiers: {
253                        offset: {
254                            offset: this.config.offset
255                        },
256                        flip: {
257                            behavior: this.config.fallbackPlacement
258                        },
259                        preventOverflow: {
260                            escapeWithReference: true
261                        },
262                        arrow: {
263                            element: Selector.ARROW
264                        }
265                    },
266                    onCreate: function onCreate(data) {
267                        if (data.originalPlacement !== data.placement) {
268                            _this._handlePopperPlacementChange(data);
269                        }
270                    },
271                    onUpdate: function onUpdate(data) {
272                        _this._handlePopperPlacementChange(data);
273                    }
274                });
275
276                $(tip).addClass(ClassName.SHOW);
277
278                // if this is a touch-enabled device we add extra
279                // empty mouseover listeners to the body's immediate children;
280                // only needed because of broken event delegation on iOS
281                // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
282                if ('ontouchstart' in document.documentElement) {
283                    $('body').children().on('mouseover', null, $.noop);
284                }
285
286                var complete = function complete() {
287                    if (_this.config.animation) {
288                        _this._fixTransition();
289                    }
290                    var prevHoverState = _this._hoverState;
291                    _this._hoverState = null;
292
293                    $(_this.element).trigger(_this.constructor.Event.SHOWN);
294
295                    if (prevHoverState === HoverState.OUT) {
296                        _this._leave(null, _this);
297                    }
298                };
299
300                if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
301                    $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
302                } else {
303                    complete();
304                }
305            }
306        };
307
308        Tooltip.prototype.hide = function hide(callback) {
309            var _this2 = this;
310
311            var tip = this.getTipElement();
312            var hideEvent = $.Event(this.constructor.Event.HIDE);
313            var complete = function complete() {
314                if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
315                    tip.parentNode.removeChild(tip);
316                }
317
318                _this2._cleanTipClass();
319                _this2.element.removeAttribute('aria-describedby');
320                $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
321                if (_this2._popper !== null) {
322                    _this2._popper.destroy();
323                }
324
325                if (callback) {
326                    callback();
327                }
328            };
329
330            $(this.element).trigger(hideEvent);
331
332            if (hideEvent.isDefaultPrevented()) {
333                return;
334            }
335
336            $(tip).removeClass(ClassName.SHOW);
337
338            // if this is a touch-enabled device we remove the extra
339            // empty mouseover listeners we added for iOS support
340            if ('ontouchstart' in document.documentElement) {
341                $('body').children().off('mouseover', null, $.noop);
342            }
343
344            this._activeTrigger[Trigger.CLICK] = false;
345            this._activeTrigger[Trigger.FOCUS] = false;
346            this._activeTrigger[Trigger.HOVER] = false;
347
348            if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
349
350                $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
351            } else {
352                complete();
353            }
354
355            this._hoverState = '';
356        };
357
358        Tooltip.prototype.update = function update() {
359            if (this._popper !== null) {
360                this._popper.scheduleUpdate();
361            }
362        };
363
364        // protected
365
366        Tooltip.prototype.isWithContent = function isWithContent() {
367            return Boolean(this.getTitle());
368        };
369
370        Tooltip.prototype.addAttachmentClass = function addAttachmentClass(attachment) {
371            $(this.getTipElement()).addClass(CLASS_PREFIX + '-' + attachment);
372        };
373
374        Tooltip.prototype.getTipElement = function getTipElement() {
375            return this.tip = this.tip || $(this.config.template)[0];
376        };
377
378        Tooltip.prototype.setContent = function setContent() {
379            var $tip = $(this.getTipElement());
380            this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle());
381            $tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW);
382        };
383
384        Tooltip.prototype.setElementContent = function setElementContent($element, content) {
385            var html = this.config.html;
386            if ((typeof content === 'undefined' ? 'undefined' : _typeof(content)) === 'object' && (content.nodeType || content.jquery)) {
387                // content is a DOM node or a jQuery
388                if (html) {
389                    if (!$(content).parent().is($element)) {
390                        $element.empty().append(content);
391                    }
392                } else {
393                    $element.text($(content).text());
394                }
395            } else {
396                $element[html ? 'html' : 'text'](content);
397            }
398        };
399
400        Tooltip.prototype.getTitle = function getTitle() {
401            var title = this.element.getAttribute('data-original-title');
402
403            if (!title) {
404                title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
405            }
406
407            return title;
408        };
409
410        // private
411
412        Tooltip.prototype._getAttachment = function _getAttachment(placement) {
413            return AttachmentMap[placement.toUpperCase()];
414        };
415
416        Tooltip.prototype._setListeners = function _setListeners() {
417            var _this3 = this;
418
419            var triggers = this.config.trigger.split(' ');
420
421            triggers.forEach(function (trigger) {
422                if (trigger === 'click') {
423                    $(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
424                        return _this3.toggle(event);
425                    });
426                } else if (trigger !== Trigger.MANUAL) {
427                    var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
428                    var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
429
430                    $(_this3.element).on(eventIn, _this3.config.selector, function (event) {
431                        return _this3._enter(event);
432                    }).on(eventOut, _this3.config.selector, function (event) {
433                        return _this3._leave(event);
434                    });
435                }
436
437                $(_this3.element).closest('.modal').on('hide.bs.modal', function () {
438                    return _this3.hide();
439                });
440            });
441
442            if (this.config.selector) {
443                this.config = $.extend({}, this.config, {
444                    trigger: 'manual',
445                    selector: ''
446                });
447            } else {
448                this._fixTitle();
449            }
450        };
451
452        Tooltip.prototype._fixTitle = function _fixTitle() {
453            var titleType = _typeof(this.element.getAttribute('data-original-title'));
454            if (this.element.getAttribute('title') || titleType !== 'string') {
455                this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
456                this.element.setAttribute('title', '');
457            }
458        };
459
460        Tooltip.prototype._enter = function _enter(event, context) {
461            var dataKey = this.constructor.DATA_KEY;
462
463            context = context || $(event.currentTarget).data(dataKey);
464
465            if (!context) {
466                context = new this.constructor(event.currentTarget, this._getDelegateConfig());
467                $(event.currentTarget).data(dataKey, context);
468            }
469
470            if (event) {
471                context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
472            }
473
474            if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
475                context._hoverState = HoverState.SHOW;
476                return;
477            }
478
479            clearTimeout(context._timeout);
480
481            context._hoverState = HoverState.SHOW;
482
483            if (!context.config.delay || !context.config.delay.show) {
484                context.show();
485                return;
486            }
487
488            context._timeout = setTimeout(function () {
489                if (context._hoverState === HoverState.SHOW) {
490                    context.show();
491                }
492            }, context.config.delay.show);
493        };
494
495        Tooltip.prototype._leave = function _leave(event, context) {
496            var dataKey = this.constructor.DATA_KEY;
497
498            context = context || $(event.currentTarget).data(dataKey);
499
500            if (!context) {
501                context = new this.constructor(event.currentTarget, this._getDelegateConfig());
502                $(event.currentTarget).data(dataKey, context);
503            }
504
505            if (event) {
506                context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
507            }
508
509            if (context._isWithActiveTrigger()) {
510                return;
511            }
512
513            clearTimeout(context._timeout);
514
515            context._hoverState = HoverState.OUT;
516
517            if (!context.config.delay || !context.config.delay.hide) {
518                context.hide();
519                return;
520            }
521
522            context._timeout = setTimeout(function () {
523                if (context._hoverState === HoverState.OUT) {
524                    context.hide();
525                }
526            }, context.config.delay.hide);
527        };
528
529        Tooltip.prototype._isWithActiveTrigger = function _isWithActiveTrigger() {
530            for (var trigger in this._activeTrigger) {
531                if (this._activeTrigger[trigger]) {
532                    return true;
533                }
534            }
535
536            return false;
537        };
538
539        Tooltip.prototype._getConfig = function _getConfig(config) {
540            config = $.extend({}, this.constructor.Default, $(this.element).data(), config);
541
542            if (config.delay && typeof config.delay === 'number') {
543                config.delay = {
544                    show: config.delay,
545                    hide: config.delay
546                };
547            }
548
549            if (config.title && typeof config.title === 'number') {
550                config.title = config.title.toString();
551            }
552
553            if (config.content && typeof config.content === 'number') {
554                config.content = config.content.toString();
555            }
556
557            Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
558
559            return config;
560        };
561
562        Tooltip.prototype._getDelegateConfig = function _getDelegateConfig() {
563            var config = {};
564
565            if (this.config) {
566                for (var key in this.config) {
567                    if (this.constructor.Default[key] !== this.config[key]) {
568                        config[key] = this.config[key];
569                    }
570                }
571            }
572
573            return config;
574        };
575
576        Tooltip.prototype._cleanTipClass = function _cleanTipClass() {
577            var $tip = $(this.getTipElement());
578            var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
579            if (tabClass !== null && tabClass.length > 0) {
580                $tip.removeClass(tabClass.join(''));
581            }
582        };
583
584        Tooltip.prototype._handlePopperPlacementChange = function _handlePopperPlacementChange(data) {
585            this._cleanTipClass();
586            this.addAttachmentClass(this._getAttachment(data.placement));
587        };
588
589        Tooltip.prototype._fixTransition = function _fixTransition() {
590            var tip = this.getTipElement();
591            var initConfigAnimation = this.config.animation;
592            if (tip.getAttribute('x-placement') !== null) {
593                return;
594            }
595            $(tip).removeClass(ClassName.FADE);
596            this.config.animation = false;
597            this.hide();
598            this.show();
599            this.config.animation = initConfigAnimation;
600        };
601
602        // static
603
604        Tooltip._jQueryInterface = function _jQueryInterface(config) {
605            return this.each(function () {
606                var data = $(this).data(DATA_KEY);
607                var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config;
608
609                if (!data && /dispose|hide/.test(config)) {
610                    return;
611                }
612
613                if (!data) {
614                    data = new Tooltip(this, _config);
615                    $(this).data(DATA_KEY, data);
616                }
617
618                if (typeof config === 'string') {
619                    if (data[config] === undefined) {
620                        throw new Error('No method named "' + config + '"');
621                    }
622                    data[config]();
623                }
624            });
625        };
626
627        _createClass(Tooltip, null, [{
628            key: 'VERSION',
629            get: function get() {
630                return VERSION;
631            }
632        }, {
633            key: 'Default',
634            get: function get() {
635                return Default;
636            }
637        }, {
638            key: 'NAME',
639            get: function get() {
640                return NAME;
641            }
642        }, {
643            key: 'DATA_KEY',
644            get: function get() {
645                return DATA_KEY;
646            }
647        }, {
648            key: 'Event',
649            get: function get() {
650                return Event;
651            }
652        }, {
653            key: 'EVENT_KEY',
654            get: function get() {
655                return EVENT_KEY;
656            }
657        }, {
658            key: 'DefaultType',
659            get: function get() {
660                return DefaultType;
661            }
662        }]);
663
664        return Tooltip;
665    }();
666
667    /**
668     * ------------------------------------------------------------------------
669     * jQuery
670     * ------------------------------------------------------------------------
671     */
672
673    $.fn[NAME] = Tooltip._jQueryInterface;
674    $.fn[NAME].Constructor = Tooltip;
675    $.fn[NAME].noConflict = function () {
676        $.fn[NAME] = JQUERY_NO_CONFLICT;
677        return Tooltip._jQueryInterface;
678    };
679
680    return Tooltip;
681}(jQuery); /* global Popper */
682//# sourceMappingURL=tooltip.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.