tooltip.js 21 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1
2
3
4
5
/*!
  * Bootstrap tooltip.js v4.1.3 (https://getbootstrap.com/)
  * Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
Mark Otto's avatar
dist    
Mark Otto committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) :
  typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) :
  (global.Tooltip = factory(global.jQuery,global.Popper,global.Util));
}(this, (function ($,Popper,Util) { 'use strict';

  $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;

  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);
    }
  }

  function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
  }

  function _defineProperty(obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
    } else {
      obj[key] = value;
    }

    return obj;
  }
Mark Otto's avatar
dist    
Mark Otto committed
46

Mark Otto's avatar
dist    
Mark Otto committed
47
48
49
50
51
52
53
54
55
56
  function _objectSpread(target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i] != null ? arguments[i] : {};
      var ownKeys = Object.keys(source);

      if (typeof Object.getOwnPropertySymbols === 'function') {
        ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
          return Object.getOwnPropertyDescriptor(source, sym).enumerable;
        }));
      }
Mark Otto's avatar
dist    
Mark Otto committed
57

Mark Otto's avatar
dist    
Mark Otto committed
58
59
60
61
      ownKeys.forEach(function (key) {
        _defineProperty(target, key, source[key]);
      });
    }
Mark Otto's avatar
dist    
Mark Otto committed
62

Mark Otto's avatar
dist    
Mark Otto committed
63
64
    return target;
  }
65
66

  /**
Mark Otto's avatar
dist    
Mark Otto committed
67
   * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
68
   * Bootstrap (v4.1.3): tooltip.js
Mark Otto's avatar
dist    
Mark Otto committed
69
70
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
71
   */
Mark Otto's avatar
dist    
Mark Otto committed
72

XhmikosR's avatar
Dist    
XhmikosR committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tooltip';
  var VERSION = '4.1.3';
  var DATA_KEY = 'bs.tooltip';
  var EVENT_KEY = "." + DATA_KEY;
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var CLASS_PREFIX = 'bs-tooltip';
  var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  var DefaultType = {
    animation: 'boolean',
    template: 'string',
    title: '(string|element|function)',
    trigger: 'string',
    delay: '(number|object)',
    html: 'boolean',
    selector: '(string|boolean)',
    placement: '(string|function)',
    offset: '(number|string)',
    container: '(string|element|boolean)',
    fallbackPlacement: '(string|array)',
    boundary: '(string|element)'
  };
  var AttachmentMap = {
    AUTO: 'auto',
    TOP: 'top',
    RIGHT: 'right',
    BOTTOM: 'bottom',
    LEFT: 'left'
  };
  var Default = {
    animation: true,
    template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: 0,
    container: false,
    fallbackPlacement: 'flip',
    boundary: 'scrollParent'
  };
  var HoverState = {
    SHOW: 'show',
    OUT: 'out'
  };
  var Event = {
    HIDE: "hide" + EVENT_KEY,
    HIDDEN: "hidden" + EVENT_KEY,
    SHOW: "show" + EVENT_KEY,
    SHOWN: "shown" + EVENT_KEY,
    INSERTED: "inserted" + EVENT_KEY,
    CLICK: "click" + EVENT_KEY,
    FOCUSIN: "focusin" + EVENT_KEY,
    FOCUSOUT: "focusout" + EVENT_KEY,
    MOUSEENTER: "mouseenter" + EVENT_KEY,
    MOUSELEAVE: "mouseleave" + EVENT_KEY
  };
  var ClassName = {
    FADE: 'fade',
    SHOW: 'show'
  };
  var Selector = {
    TOOLTIP: '.tooltip',
    TOOLTIP_INNER: '.tooltip-inner',
    ARROW: '.arrow'
  };
  var Trigger = {
    HOVER: 'hover',
    FOCUS: 'focus',
    CLICK: 'click',
    MANUAL: 'manual'
Mark Otto's avatar
dist    
Mark Otto committed
151
152
    /**
     * ------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
153
     * Class Definition
Mark Otto's avatar
dist    
Mark Otto committed
154
155
     * ------------------------------------------------------------------------
     */
XhmikosR's avatar
Dist    
XhmikosR committed
156
157
158
159
160
161
162

  };

  var Tooltip =
  /*#__PURE__*/
  function () {
    function Tooltip(element, config) {
Mark Otto's avatar
dist    
Mark Otto committed
163
      /**
XhmikosR's avatar
Dist    
XhmikosR committed
164
165
       * Check for Popper dependency
       * Popper - https://popper.js.org
Mark Otto's avatar
dist    
Mark Otto committed
166
       */
XhmikosR's avatar
Dist    
XhmikosR committed
167
168
169
      if (typeof Popper === 'undefined') {
        throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
170
171


XhmikosR's avatar
Dist    
XhmikosR committed
172
173
174
175
176
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
177

XhmikosR's avatar
Dist    
XhmikosR committed
178
179
180
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
181

XhmikosR's avatar
Dist    
XhmikosR committed
182
183
      this._setListeners();
    } // Getters
184

Jacob Thornton's avatar
Jacob Thornton committed
185

XhmikosR's avatar
Dist    
XhmikosR committed
186
    var _proto = Tooltip.prototype;
187

XhmikosR's avatar
Dist    
XhmikosR committed
188
189
190
191
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
192

XhmikosR's avatar
Dist    
XhmikosR committed
193
194
195
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
196

XhmikosR's avatar
Dist    
XhmikosR committed
197
198
199
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Mark Otto's avatar
dist    
Mark Otto committed
200

XhmikosR's avatar
Dist    
XhmikosR committed
201
202
203
204
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Mark Otto's avatar
Mark Otto committed
205

XhmikosR's avatar
Dist    
XhmikosR committed
206
207
208
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
        var context = $(event.currentTarget).data(dataKey);
Mark Otto's avatar
Mark Otto committed
209

XhmikosR's avatar
Dist    
XhmikosR committed
210
211
212
        if (!context) {
          context = new this.constructor(event.currentTarget, this._getDelegateConfig());
          $(event.currentTarget).data(dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
213
        }
fat's avatar
fat committed
214

XhmikosR's avatar
Dist    
XhmikosR committed
215
        context._activeTrigger.click = !context._activeTrigger.click;
fat's avatar
fat committed
216

XhmikosR's avatar
Dist    
XhmikosR committed
217
218
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
Mark Otto's avatar
grunt    
Mark Otto committed
219
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
220
221
222
223
224
          context._leave(null, context);
        }
      } else {
        if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
          this._leave(null, this);
225

XhmikosR's avatar
Dist    
XhmikosR committed
226
          return;
Mark Otto's avatar
dist    
Mark Otto committed
227
        }
228

XhmikosR's avatar
Dist    
XhmikosR committed
229
230
231
232
233
234
235
236
237
        this._enter(null, this);
      }
    };

    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
      $.removeData(this.element, this.constructor.DATA_KEY);
      $(this.element).off(this.constructor.EVENT_KEY);
      $(this.element).closest('.modal').off('hide.bs.modal');
238

XhmikosR's avatar
Dist    
XhmikosR committed
239
240
241
      if (this.tip) {
        $(this.tip).remove();
      }
242

XhmikosR's avatar
Dist    
XhmikosR committed
243
244
245
246
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
247

XhmikosR's avatar
Dist    
XhmikosR committed
248
249
250
      if (this._popper !== null) {
        this._popper.destroy();
      }
251

XhmikosR's avatar
Dist    
XhmikosR committed
252
253
254
255
256
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
257

XhmikosR's avatar
Dist    
XhmikosR committed
258
259
    _proto.show = function show() {
      var _this = this;
260

XhmikosR's avatar
Dist    
XhmikosR committed
261
262
263
      if ($(this.element).css('display') === 'none') {
        throw new Error('Please use show on visible elements');
      }
264

XhmikosR's avatar
Dist    
XhmikosR committed
265
      var showEvent = $.Event(this.constructor.Event.SHOW);
266

XhmikosR's avatar
Dist    
XhmikosR committed
267
268
269
      if (this.isWithContent() && this._isEnabled) {
        $(this.element).trigger(showEvent);
        var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
270

XhmikosR's avatar
Dist    
XhmikosR committed
271
272
273
        if (showEvent.isDefaultPrevented() || !isInTheDom) {
          return;
        }
274

XhmikosR's avatar
Dist    
XhmikosR committed
275
276
277
278
279
        var tip = this.getTipElement();
        var tipId = Util.getUID(this.constructor.NAME);
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
280

XhmikosR's avatar
Dist    
XhmikosR committed
281
282
283
        if (this.config.animation) {
          $(tip).addClass(ClassName.FADE);
        }
284

XhmikosR's avatar
Dist    
XhmikosR committed
285
        var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
Mark Otto's avatar
grunt    
Mark Otto committed
286

XhmikosR's avatar
Dist    
XhmikosR committed
287
        var attachment = this._getAttachment(placement);
Mark Otto's avatar
grunt    
Mark Otto committed
288

XhmikosR's avatar
Dist    
XhmikosR committed
289
290
291
        this.addAttachmentClass(attachment);
        var container = this.config.container === false ? document.body : $(document).find(this.config.container);
        $(tip).data(this.constructor.DATA_KEY, this);
Mark Otto's avatar
Mark Otto committed
292

XhmikosR's avatar
Dist    
XhmikosR committed
293
294
295
        if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
          $(tip).appendTo(container);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
296

XhmikosR's avatar
Dist    
XhmikosR committed
297
298
299
300
301
302
        $(this.element).trigger(this.constructor.Event.INSERTED);
        this._popper = new Popper(this.element, tip, {
          placement: attachment,
          modifiers: {
            offset: {
              offset: this.config.offset
Mark Otto's avatar
build    
Mark Otto committed
303
            },
XhmikosR's avatar
Dist    
XhmikosR committed
304
305
            flip: {
              behavior: this.config.fallbackPlacement
Mark Otto's avatar
dist    
Mark Otto committed
306
            },
XhmikosR's avatar
Dist    
XhmikosR committed
307
308
309
310
311
312
313
314
315
            arrow: {
              element: Selector.ARROW
            },
            preventOverflow: {
              boundariesElement: this.config.boundary
            }
          },
          onCreate: function onCreate(data) {
            if (data.originalPlacement !== data.placement) {
Johann-S's avatar
build    
Johann-S committed
316
317
              _this._handlePopperPlacementChange(data);
            }
XhmikosR's avatar
Dist    
XhmikosR committed
318
319
320
          },
          onUpdate: function onUpdate(data) {
            _this._handlePopperPlacementChange(data);
Johann-S's avatar
build    
Johann-S committed
321
          }
XhmikosR's avatar
Dist    
XhmikosR committed
322
323
324
325
326
        });
        $(tip).addClass(ClassName.SHOW); // If this is a touch-enabled device we add extra
        // empty mouseover listeners to the body's immediate children;
        // only needed because of broken event delegation on iOS
        // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
Mark Otto's avatar
grunt    
Mark Otto committed
327

XhmikosR's avatar
Dist    
XhmikosR committed
328
329
330
        if ('ontouchstart' in document.documentElement) {
          $(document.body).children().on('mouseover', null, $.noop);
        }
Mark Otto's avatar
build    
Mark Otto committed
331

XhmikosR's avatar
Dist    
XhmikosR committed
332
333
334
335
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
336

XhmikosR's avatar
Dist    
XhmikosR committed
337
338
339
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
          $(_this.element).trigger(_this.constructor.Event.SHOWN);
340

XhmikosR's avatar
Dist    
XhmikosR committed
341
342
          if (prevHoverState === HoverState.OUT) {
            _this._leave(null, _this);
343
          }
XhmikosR's avatar
Dist    
XhmikosR committed
344
345
346
347
348
349
350
        };

        if ($(this.tip).hasClass(ClassName.FADE)) {
          var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
          $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
        } else {
          complete();
351
        }
XhmikosR's avatar
Dist    
XhmikosR committed
352
353
      }
    };
354

XhmikosR's avatar
Dist    
XhmikosR committed
355
356
    _proto.hide = function hide(callback) {
      var _this2 = this;
357

XhmikosR's avatar
Dist    
XhmikosR committed
358
359
      var tip = this.getTipElement();
      var hideEvent = $.Event(this.constructor.Event.HIDE);
Mark Otto's avatar
dist    
Mark Otto committed
360

XhmikosR's avatar
Dist    
XhmikosR committed
361
362
363
364
      var complete = function complete() {
        if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
          tip.parentNode.removeChild(tip);
        }
365

XhmikosR's avatar
Dist    
XhmikosR committed
366
        _this2._cleanTipClass();
Mark Otto's avatar
grunt    
Mark Otto committed
367

XhmikosR's avatar
Dist    
XhmikosR committed
368
        _this2.element.removeAttribute('aria-describedby');
369

XhmikosR's avatar
Dist    
XhmikosR committed
370
        $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
371

XhmikosR's avatar
Dist    
XhmikosR committed
372
373
374
        if (_this2._popper !== null) {
          _this2._popper.destroy();
        }
375

XhmikosR's avatar
Dist    
XhmikosR committed
376
377
378
379
        if (callback) {
          callback();
        }
      };
Mark Otto's avatar
grunt    
Mark Otto committed
380

XhmikosR's avatar
Dist    
XhmikosR committed
381
      $(this.element).trigger(hideEvent);
Mark Otto's avatar
grunt    
Mark Otto committed
382

XhmikosR's avatar
Dist    
XhmikosR committed
383
384
385
      if (hideEvent.isDefaultPrevented()) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
386

XhmikosR's avatar
Dist    
XhmikosR committed
387
388
      $(tip).removeClass(ClassName.SHOW); // If this is a touch-enabled device we remove the extra
      // empty mouseover listeners we added for iOS support
Mark Otto's avatar
dist    
Mark Otto committed
389

XhmikosR's avatar
Dist    
XhmikosR committed
390
391
392
      if ('ontouchstart' in document.documentElement) {
        $(document.body).children().off('mouseover', null, $.noop);
      }
Mark Otto's avatar
dist    
Mark Otto committed
393

XhmikosR's avatar
Dist    
XhmikosR committed
394
395
396
      this._activeTrigger[Trigger.CLICK] = false;
      this._activeTrigger[Trigger.FOCUS] = false;
      this._activeTrigger[Trigger.HOVER] = false;
Mark Otto's avatar
dist    
Mark Otto committed
397

XhmikosR's avatar
Dist    
XhmikosR committed
398
399
400
401
402
403
      if ($(this.tip).hasClass(ClassName.FADE)) {
        var transitionDuration = Util.getTransitionDurationFromElement(tip);
        $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
      } else {
        complete();
      }
Mark Otto's avatar
dist    
Mark Otto committed
404

XhmikosR's avatar
Dist    
XhmikosR committed
405
406
      this._hoverState = '';
    };
Mark Otto's avatar
dist    
Mark Otto committed
407

XhmikosR's avatar
Dist    
XhmikosR committed
408
409
410
411
412
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
    }; // Protected
Mark Otto's avatar
dist    
Mark Otto committed
413
414


XhmikosR's avatar
Dist    
XhmikosR committed
415
416
417
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Mark Otto's avatar
dist    
Mark Otto committed
418

XhmikosR's avatar
Dist    
XhmikosR committed
419
420
421
    _proto.addAttachmentClass = function addAttachmentClass(attachment) {
      $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
    };
Mark Otto's avatar
dist    
Mark Otto committed
422

XhmikosR's avatar
Dist    
XhmikosR committed
423
424
425
426
    _proto.getTipElement = function getTipElement() {
      this.tip = this.tip || $(this.config.template)[0];
      return this.tip;
    };
Mark Otto's avatar
dist    
Mark Otto committed
427

XhmikosR's avatar
Dist    
XhmikosR committed
428
429
430
431
432
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
      this.setElementContent($(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle());
      $(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW);
    };
Mark Otto's avatar
dist    
Mark Otto committed
433

XhmikosR's avatar
Dist    
XhmikosR committed
434
435
    _proto.setElementContent = function setElementContent($element, content) {
      var html = this.config.html;
Mark Otto's avatar
dist    
Mark Otto committed
436

XhmikosR's avatar
Dist    
XhmikosR committed
437
438
439
440
441
      if (typeof content === 'object' && (content.nodeType || content.jquery)) {
        // Content is a DOM node or a jQuery
        if (html) {
          if (!$(content).parent().is($element)) {
            $element.empty().append(content);
XhmikosR's avatar
XhmikosR committed
442
443
          }
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
444
          $element.text($(content).text());
XhmikosR's avatar
XhmikosR committed
445
        }
XhmikosR's avatar
Dist    
XhmikosR committed
446
447
448
449
      } else {
        $element[html ? 'html' : 'text'](content);
      }
    };
450

XhmikosR's avatar
Dist    
XhmikosR committed
451
452
    _proto.getTitle = function getTitle() {
      var title = this.element.getAttribute('data-original-title');
453

XhmikosR's avatar
Dist    
XhmikosR committed
454
455
456
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
457

XhmikosR's avatar
Dist    
XhmikosR committed
458
459
      return title;
    }; // Private
460

Mark Otto's avatar
grunt    
Mark Otto committed
461

XhmikosR's avatar
Dist    
XhmikosR committed
462
463
464
    _proto._getAttachment = function _getAttachment(placement) {
      return AttachmentMap[placement.toUpperCase()];
    };
Mark Otto's avatar
dist    
Mark Otto committed
465

XhmikosR's avatar
Dist    
XhmikosR committed
466
467
    _proto._setListeners = function _setListeners() {
      var _this3 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
468

XhmikosR's avatar
Dist    
XhmikosR committed
469
470
471
472
473
      var triggers = this.config.trigger.split(' ');
      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
          $(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
            return _this3.toggle(event);
Mark Otto's avatar
dist    
Mark Otto committed
474
          });
XhmikosR's avatar
Dist    
XhmikosR committed
475
476
477
478
479
480
481
        } else if (trigger !== Trigger.MANUAL) {
          var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
          var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
          $(_this3.element).on(eventIn, _this3.config.selector, function (event) {
            return _this3._enter(event);
          }).on(eventOut, _this3.config.selector, function (event) {
            return _this3._leave(event);
Mark Otto's avatar
dist    
Mark Otto committed
482
483
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
484
485
486
487
488
489
      });
      $(this.element).closest('.modal').on('hide.bs.modal', function () {
        if (_this3.element) {
          _this3.hide();
        }
      });
Mark Otto's avatar
dist    
Mark Otto committed
490

XhmikosR's avatar
Dist    
XhmikosR committed
491
492
493
494
495
496
497
498
499
      if (this.config.selector) {
        this.config = _objectSpread({}, this.config, {
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
      }
    };
500

XhmikosR's avatar
Dist    
XhmikosR committed
501
502
    _proto._fixTitle = function _fixTitle() {
      var titleType = typeof this.element.getAttribute('data-original-title');
503

XhmikosR's avatar
Dist    
XhmikosR committed
504
505
506
507
508
      if (this.element.getAttribute('title') || titleType !== 'string') {
        this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
        this.element.setAttribute('title', '');
      }
    };
509

XhmikosR's avatar
Dist    
XhmikosR committed
510
511
512
    _proto._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
      context = context || $(event.currentTarget).data(dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
513

XhmikosR's avatar
Dist    
XhmikosR committed
514
515
516
517
      if (!context) {
        context = new this.constructor(event.currentTarget, this._getDelegateConfig());
        $(event.currentTarget).data(dataKey, context);
      }
Mark Otto's avatar
grunt    
Mark Otto committed
518

XhmikosR's avatar
Dist    
XhmikosR committed
519
520
521
      if (event) {
        context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
      }
522

XhmikosR's avatar
Dist    
XhmikosR committed
523
      if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
Mark Otto's avatar
dist    
Mark Otto committed
524
        context._hoverState = HoverState.SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
525
526
527
528
529
        return;
      }

      clearTimeout(context._timeout);
      context._hoverState = HoverState.SHOW;
Mark Otto's avatar
grunt    
Mark Otto committed
530

XhmikosR's avatar
Dist    
XhmikosR committed
531
532
533
534
535
536
537
      if (!context.config.delay || !context.config.delay.show) {
        context.show();
        return;
      }

      context._timeout = setTimeout(function () {
        if (context._hoverState === HoverState.SHOW) {
538
539
          context.show();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
540
541
      }, context.config.delay.show);
    };
542

XhmikosR's avatar
Dist    
XhmikosR committed
543
544
545
    _proto._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
      context = context || $(event.currentTarget).data(dataKey);
Mark Otto's avatar
dist    
Mark Otto committed
546

XhmikosR's avatar
Dist    
XhmikosR committed
547
548
549
550
      if (!context) {
        context = new this.constructor(event.currentTarget, this._getDelegateConfig());
        $(event.currentTarget).data(dataKey, context);
      }
Mark Otto's avatar
grunt    
Mark Otto committed
551

XhmikosR's avatar
Dist    
XhmikosR committed
552
553
554
      if (event) {
        context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
      }
555

XhmikosR's avatar
Dist    
XhmikosR committed
556
557
558
      if (context._isWithActiveTrigger()) {
        return;
      }
559

XhmikosR's avatar
Dist    
XhmikosR committed
560
561
      clearTimeout(context._timeout);
      context._hoverState = HoverState.OUT;
562

XhmikosR's avatar
Dist    
XhmikosR committed
563
564
565
566
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
567

XhmikosR's avatar
Dist    
XhmikosR committed
568
569
      context._timeout = setTimeout(function () {
        if (context._hoverState === HoverState.OUT) {
Mark Otto's avatar
dist    
Mark Otto committed
570
          context.hide();
571
        }
XhmikosR's avatar
Dist    
XhmikosR committed
572
573
      }, context.config.delay.hide);
    };
574

XhmikosR's avatar
Dist    
XhmikosR committed
575
576
577
578
    _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
Mark Otto's avatar
dist    
Mark Otto committed
579
        }
XhmikosR's avatar
Dist    
XhmikosR committed
580
      }
Mark Otto's avatar
grunt    
Mark Otto committed
581

XhmikosR's avatar
Dist    
XhmikosR committed
582
583
      return false;
    };
fat's avatar
fat committed
584

XhmikosR's avatar
Dist    
XhmikosR committed
585
586
    _proto._getConfig = function _getConfig(config) {
      config = _objectSpread({}, this.constructor.Default, $(this.element).data(), typeof config === 'object' && config ? config : {});
Mark Otto's avatar
grunt    
Mark Otto committed
587

XhmikosR's avatar
Dist    
XhmikosR committed
588
589
590
591
592
593
      if (typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
          hide: config.delay
        };
      }
Mark Otto's avatar
grunt    
Mark Otto committed
594

XhmikosR's avatar
Dist    
XhmikosR committed
595
596
597
      if (typeof config.title === 'number') {
        config.title = config.title.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
598

XhmikosR's avatar
Dist    
XhmikosR committed
599
600
601
      if (typeof config.content === 'number') {
        config.content = config.content.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
602

XhmikosR's avatar
Dist    
XhmikosR committed
603
604
605
      Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
606

XhmikosR's avatar
Dist    
XhmikosR committed
607
608
    _proto._getDelegateConfig = function _getDelegateConfig() {
      var config = {};
Mark Otto's avatar
grunt    
Mark Otto committed
609

XhmikosR's avatar
Dist    
XhmikosR committed
610
611
612
613
      if (this.config) {
        for (var key in this.config) {
          if (this.constructor.Default[key] !== this.config[key]) {
            config[key] = this.config[key];
614
615
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
616
      }
Mark Otto's avatar
dist    
Mark Otto committed
617

XhmikosR's avatar
Dist    
XhmikosR committed
618
619
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
620

XhmikosR's avatar
Dist    
XhmikosR committed
621
622
623
    _proto._cleanTipClass = function _cleanTipClass() {
      var $tip = $(this.getTipElement());
      var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
Mark Otto's avatar
dist    
Mark Otto committed
624

XhmikosR's avatar
Dist    
XhmikosR committed
625
626
627
628
      if (tabClass !== null && tabClass.length) {
        $tip.removeClass(tabClass.join(''));
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
629

XhmikosR's avatar
Dist    
XhmikosR committed
630
631
632
    _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
      var popperInstance = popperData.instance;
      this.tip = popperInstance.popper;
Mark Otto's avatar
dist    
Mark Otto committed
633

XhmikosR's avatar
Dist    
XhmikosR committed
634
      this._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
635

XhmikosR's avatar
Dist    
XhmikosR committed
636
637
      this.addAttachmentClass(this._getAttachment(popperData.placement));
    };
Mark Otto's avatar
dist    
Mark Otto committed
638

XhmikosR's avatar
Dist    
XhmikosR committed
639
640
641
    _proto._fixTransition = function _fixTransition() {
      var tip = this.getTipElement();
      var initConfigAnimation = this.config.animation;
Mark Otto's avatar
dist    
Mark Otto committed
642

XhmikosR's avatar
Dist    
XhmikosR committed
643
644
645
      if (tip.getAttribute('x-placement') !== null) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
646

XhmikosR's avatar
Dist    
XhmikosR committed
647
648
649
650
651
652
      $(tip).removeClass(ClassName.FADE);
      this.config.animation = false;
      this.hide();
      this.show();
      this.config.animation = initConfigAnimation;
    }; // Static
Mark Otto's avatar
dist    
Mark Otto committed
653
654


XhmikosR's avatar
Dist    
XhmikosR committed
655
656
657
    Tooltip._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
Mark Otto's avatar
dist    
Mark Otto committed
658

XhmikosR's avatar
Dist    
XhmikosR committed
659
        var _config = typeof config === 'object' && config;
Mark Otto's avatar
dist    
Mark Otto committed
660

XhmikosR's avatar
Dist    
XhmikosR committed
661
662
663
        if (!data && /dispose|hide/.test(config)) {
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
664

XhmikosR's avatar
Dist    
XhmikosR committed
665
666
667
668
        if (!data) {
          data = new Tooltip(this, _config);
          $(this).data(DATA_KEY, data);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
669

XhmikosR's avatar
Dist    
XhmikosR committed
670
671
672
        if (typeof config === 'string') {
          if (typeof data[config] === 'undefined') {
            throw new TypeError("No method named \"" + config + "\"");
Mark Otto's avatar
dist    
Mark Otto committed
673
674
          }

XhmikosR's avatar
Dist    
XhmikosR committed
675
          data[config]();
Mark Otto's avatar
dist    
Mark Otto committed
676
        }
XhmikosR's avatar
Dist    
XhmikosR committed
677
678
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
679

XhmikosR's avatar
Dist    
XhmikosR committed
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
    _createClass(Tooltip, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default;
      }
    }, {
      key: "NAME",
      get: function get() {
        return NAME;
      }
    }, {
      key: "DATA_KEY",
      get: function get() {
        return DATA_KEY;
      }
    }, {
      key: "Event",
      get: function get() {
        return Event;
      }
    }, {
      key: "EVENT_KEY",
      get: function get() {
        return EVENT_KEY;
      }
    }, {
      key: "DefaultType",
      get: function get() {
        return DefaultType;
      }
    }]);
716

XhmikosR's avatar
Dist    
XhmikosR committed
717
718
719
720
721
722
723
    return Tooltip;
  }();
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
724

Mark Otto's avatar
dist    
Mark Otto committed
725

XhmikosR's avatar
Dist    
XhmikosR committed
726
727
  $.fn[NAME] = Tooltip._jQueryInterface;
  $.fn[NAME].Constructor = Tooltip;
Mark Otto's avatar
dist    
Mark Otto committed
728

XhmikosR's avatar
Dist    
XhmikosR committed
729
730
731
732
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Tooltip._jQueryInterface;
  };
733
734

  return Tooltip;
Mark Otto's avatar
dist    
Mark Otto committed
735
736
737

})));
//# sourceMappingURL=tooltip.js.map