tooltip.js 22.1 KB
Newer Older
Mark Otto's avatar
dist    
Mark Otto committed
1
2
3
4
5
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
(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
41

Mark Otto's avatar
dist    
Mark Otto committed
42
43
44
45
46
47
48
49
50
51
  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
52

Mark Otto's avatar
dist    
Mark Otto committed
53
54
55
56
      ownKeys.forEach(function (key) {
        _defineProperty(target, key, source[key]);
      });
    }
Mark Otto's avatar
dist    
Mark Otto committed
57

Mark Otto's avatar
dist    
Mark Otto committed
58
59
    return target;
  }
60
61

  /**
Mark Otto's avatar
dist    
Mark Otto committed
62
   * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
63
   * Bootstrap (v4.1.3): tooltip.js
Mark Otto's avatar
dist    
Mark Otto committed
64
65
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
66
   */
Mark Otto's avatar
dist    
Mark Otto committed
67
68

  var Tooltip = function ($$$1) {
Mark Otto's avatar
dist    
Mark Otto committed
69
70
    /**
     * ------------------------------------------------------------------------
Mark Otto's avatar
dist    
Mark Otto committed
71
     * Constants
Mark Otto's avatar
dist    
Mark Otto committed
72
73
     * ------------------------------------------------------------------------
     */
Mark Otto's avatar
dist    
Mark Otto committed
74
    var NAME = 'tooltip';
Mark Otto's avatar
Mark Otto committed
75
    var VERSION = '4.1.3';
Mark Otto's avatar
dist    
Mark Otto committed
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
    var DATA_KEY = 'bs.tooltip';
    var EVENT_KEY = "." + DATA_KEY;
    var JQUERY_NO_CONFLICT = $$$1.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
146
      /**
Mark Otto's avatar
dist    
Mark Otto committed
147
148
149
       * ------------------------------------------------------------------------
       * Class Definition
       * ------------------------------------------------------------------------
Mark Otto's avatar
dist    
Mark Otto committed
150
151
       */

Mark Otto's avatar
dist    
Mark Otto committed
152
    };
Mark Otto's avatar
dist    
Mark Otto committed
153

Mark Otto's avatar
dist    
Mark Otto committed
154
155
156
157
158
159
160
161
162
163
164
    var Tooltip =
    /*#__PURE__*/
    function () {
      function Tooltip(element, config) {
        /**
         * Check for Popper dependency
         * Popper - https://popper.js.org
         */
        if (typeof Popper === 'undefined') {
          throw new TypeError('Bootstrap tooltips require Popper.js (https://popper.js.org)');
        } // private
165
166


Mark Otto's avatar
dist    
Mark Otto committed
167
168
169
170
171
        this._isEnabled = true;
        this._timeout = 0;
        this._hoverState = '';
        this._activeTrigger = {};
        this._popper = null; // Protected
172

Mark Otto's avatar
dist    
Mark Otto committed
173
174
175
        this.element = element;
        this.config = this._getConfig(config);
        this.tip = null;
Jacob Thornton's avatar
Jacob Thornton committed
176

Mark Otto's avatar
dist    
Mark Otto committed
177
178
        this._setListeners();
      } // Getters
179
180


Mark Otto's avatar
dist    
Mark Otto committed
181
      var _proto = Tooltip.prototype;
182

Mark Otto's avatar
dist    
Mark Otto committed
183
184
185
186
      // Public
      _proto.enable = function enable() {
        this._isEnabled = true;
      };
Mark Otto's avatar
dist    
Mark Otto committed
187

Mark Otto's avatar
dist    
Mark Otto committed
188
189
190
      _proto.disable = function disable() {
        this._isEnabled = false;
      };
Mark Otto's avatar
Mark Otto committed
191

Mark Otto's avatar
dist    
Mark Otto committed
192
193
194
      _proto.toggleEnabled = function toggleEnabled() {
        this._isEnabled = !this._isEnabled;
      };
Mark Otto's avatar
Mark Otto committed
195

Mark Otto's avatar
dist    
Mark Otto committed
196
197
198
      _proto.toggle = function toggle(event) {
        if (!this._isEnabled) {
          return;
Mark Otto's avatar
dist    
Mark Otto committed
199
        }
fat's avatar
fat committed
200

Mark Otto's avatar
dist    
Mark Otto committed
201
202
203
        if (event) {
          var dataKey = this.constructor.DATA_KEY;
          var context = $$$1(event.currentTarget).data(dataKey);
fat's avatar
fat committed
204

Mark Otto's avatar
dist    
Mark Otto committed
205
206
207
208
209
210
211
212
213
214
215
216
          if (!context) {
            context = new this.constructor(event.currentTarget, this._getDelegateConfig());
            $$$1(event.currentTarget).data(dataKey, context);
          }

          context._activeTrigger.click = !context._activeTrigger.click;

          if (context._isWithActiveTrigger()) {
            context._enter(null, context);
          } else {
            context._leave(null, context);
          }
Mark Otto's avatar
grunt    
Mark Otto committed
217
        } else {
Mark Otto's avatar
dist    
Mark Otto committed
218
219
          if ($$$1(this.getTipElement()).hasClass(ClassName.SHOW)) {
            this._leave(null, this);
fat's avatar
fat committed
220

Mark Otto's avatar
dist    
Mark Otto committed
221
222
            return;
          }
223

Mark Otto's avatar
dist    
Mark Otto committed
224
225
226
          this._enter(null, this);
        }
      };
227

Mark Otto's avatar
dist    
Mark Otto committed
228
229
230
231
232
      _proto.dispose = function dispose() {
        clearTimeout(this._timeout);
        $$$1.removeData(this.element, this.constructor.DATA_KEY);
        $$$1(this.element).off(this.constructor.EVENT_KEY);
        $$$1(this.element).closest('.modal').off('hide.bs.modal');
233

Mark Otto's avatar
dist    
Mark Otto committed
234
235
236
        if (this.tip) {
          $$$1(this.tip).remove();
        }
237

Mark Otto's avatar
dist    
Mark Otto committed
238
239
240
241
        this._isEnabled = null;
        this._timeout = null;
        this._hoverState = null;
        this._activeTrigger = null;
242

Mark Otto's avatar
dist    
Mark Otto committed
243
244
245
        if (this._popper !== null) {
          this._popper.destroy();
        }
246

Mark Otto's avatar
dist    
Mark Otto committed
247
248
249
250
251
        this._popper = null;
        this.element = null;
        this.config = null;
        this.tip = null;
      };
252

Mark Otto's avatar
dist    
Mark Otto committed
253
254
      _proto.show = function show() {
        var _this = this;
255

Mark Otto's avatar
dist    
Mark Otto committed
256
257
258
        if ($$$1(this.element).css('display') === 'none') {
          throw new Error('Please use show on visible elements');
        }
259

Mark Otto's avatar
dist    
Mark Otto committed
260
        var showEvent = $$$1.Event(this.constructor.Event.SHOW);
261

Mark Otto's avatar
dist    
Mark Otto committed
262
263
264
        if (this.isWithContent() && this._isEnabled) {
          $$$1(this.element).trigger(showEvent);
          var isInTheDom = $$$1.contains(this.element.ownerDocument.documentElement, this.element);
265

Mark Otto's avatar
dist    
Mark Otto committed
266
267
268
          if (showEvent.isDefaultPrevented() || !isInTheDom) {
            return;
          }
269

Mark Otto's avatar
dist    
Mark Otto committed
270
271
272
273
274
          var tip = this.getTipElement();
          var tipId = Util.getUID(this.constructor.NAME);
          tip.setAttribute('id', tipId);
          this.element.setAttribute('aria-describedby', tipId);
          this.setContent();
275

Mark Otto's avatar
dist    
Mark Otto committed
276
277
278
          if (this.config.animation) {
            $$$1(tip).addClass(ClassName.FADE);
          }
279

Mark Otto's avatar
dist    
Mark Otto committed
280
          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
281

Mark Otto's avatar
dist    
Mark Otto committed
282
          var attachment = this._getAttachment(placement);
Mark Otto's avatar
grunt    
Mark Otto committed
283

Mark Otto's avatar
dist    
Mark Otto committed
284
285
286
          this.addAttachmentClass(attachment);
          var container = this.config.container === false ? document.body : $$$1(document).find(this.config.container);
          $$$1(tip).data(this.constructor.DATA_KEY, this);
Mark Otto's avatar
Mark Otto committed
287

Mark Otto's avatar
dist    
Mark Otto committed
288
289
290
          if (!$$$1.contains(this.element.ownerDocument.documentElement, this.tip)) {
            $$$1(tip).appendTo(container);
          }
Mark Otto's avatar
grunt    
Mark Otto committed
291

Mark Otto's avatar
dist    
Mark Otto committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
          $$$1(this.element).trigger(this.constructor.Event.INSERTED);
          this._popper = new Popper(this.element, tip, {
            placement: attachment,
            modifiers: {
              offset: {
                offset: this.config.offset
              },
              flip: {
                behavior: this.config.fallbackPlacement
              },
              arrow: {
                element: Selector.ARROW
              },
              preventOverflow: {
                boundariesElement: this.config.boundary
              }
Mark Otto's avatar
build    
Mark Otto committed
308
            },
Mark Otto's avatar
dist    
Mark Otto committed
309
310
311
312
            onCreate: function onCreate(data) {
              if (data.originalPlacement !== data.placement) {
                _this._handlePopperPlacementChange(data);
              }
Mark Otto's avatar
dist    
Mark Otto committed
313
            },
Mark Otto's avatar
dist    
Mark Otto committed
314
            onUpdate: function onUpdate(data) {
Johann-S's avatar
build    
Johann-S committed
315
316
              _this._handlePopperPlacementChange(data);
            }
Mark Otto's avatar
dist    
Mark Otto committed
317
318
319
320
321
322
323
324
          });
          $$$1(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

          if ('ontouchstart' in document.documentElement) {
            $$$1(document.body).children().on('mouseover', null, $$$1.noop);
Johann-S's avatar
build    
Johann-S committed
325
          }
Mark Otto's avatar
grunt    
Mark Otto committed
326

Mark Otto's avatar
dist    
Mark Otto committed
327
328
329
330
          var complete = function complete() {
            if (_this.config.animation) {
              _this._fixTransition();
            }
Mark Otto's avatar
build    
Mark Otto committed
331

Mark Otto's avatar
dist    
Mark Otto committed
332
333
334
            var prevHoverState = _this._hoverState;
            _this._hoverState = null;
            $$$1(_this.element).trigger(_this.constructor.Event.SHOWN);
335

Mark Otto's avatar
dist    
Mark Otto committed
336
337
338
339
            if (prevHoverState === HoverState.OUT) {
              _this._leave(null, _this);
            }
          };
340

Mark Otto's avatar
dist    
Mark Otto committed
341
342
343
344
345
          if ($$$1(this.tip).hasClass(ClassName.FADE)) {
            var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
            $$$1(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
          } else {
            complete();
346
347
          }
        }
Mark Otto's avatar
dist    
Mark Otto committed
348
      };
349

Mark Otto's avatar
dist    
Mark Otto committed
350
351
      _proto.hide = function hide(callback) {
        var _this2 = this;
352

Mark Otto's avatar
dist    
Mark Otto committed
353
354
        var tip = this.getTipElement();
        var hideEvent = $$$1.Event(this.constructor.Event.HIDE);
Mark Otto's avatar
dist    
Mark Otto committed
355

Mark Otto's avatar
dist    
Mark Otto committed
356
357
358
359
        var complete = function complete() {
          if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
            tip.parentNode.removeChild(tip);
          }
360

Mark Otto's avatar
dist    
Mark Otto committed
361
          _this2._cleanTipClass();
Mark Otto's avatar
grunt    
Mark Otto committed
362

Mark Otto's avatar
dist    
Mark Otto committed
363
          _this2.element.removeAttribute('aria-describedby');
364

Mark Otto's avatar
dist    
Mark Otto committed
365
          $$$1(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
366

Mark Otto's avatar
dist    
Mark Otto committed
367
368
369
          if (_this2._popper !== null) {
            _this2._popper.destroy();
          }
370

Mark Otto's avatar
dist    
Mark Otto committed
371
372
373
374
          if (callback) {
            callback();
          }
        };
Mark Otto's avatar
grunt    
Mark Otto committed
375

Mark Otto's avatar
dist    
Mark Otto committed
376
        $$$1(this.element).trigger(hideEvent);
Mark Otto's avatar
grunt    
Mark Otto committed
377

Mark Otto's avatar
dist    
Mark Otto committed
378
379
380
        if (hideEvent.isDefaultPrevented()) {
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
381

Mark Otto's avatar
dist    
Mark Otto committed
382
383
        $$$1(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
384

Mark Otto's avatar
dist    
Mark Otto committed
385
386
387
        if ('ontouchstart' in document.documentElement) {
          $$$1(document.body).children().off('mouseover', null, $$$1.noop);
        }
Mark Otto's avatar
dist    
Mark Otto committed
388

Mark Otto's avatar
dist    
Mark Otto committed
389
390
391
        this._activeTrigger[Trigger.CLICK] = false;
        this._activeTrigger[Trigger.FOCUS] = false;
        this._activeTrigger[Trigger.HOVER] = false;
Mark Otto's avatar
dist    
Mark Otto committed
392

Mark Otto's avatar
dist    
Mark Otto committed
393
394
395
396
397
398
        if ($$$1(this.tip).hasClass(ClassName.FADE)) {
          var transitionDuration = Util.getTransitionDurationFromElement(tip);
          $$$1(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
        } else {
          complete();
        }
Mark Otto's avatar
dist    
Mark Otto committed
399

Mark Otto's avatar
dist    
Mark Otto committed
400
401
        this._hoverState = '';
      };
Mark Otto's avatar
dist    
Mark Otto committed
402

Mark Otto's avatar
dist    
Mark Otto committed
403
404
405
406
407
      _proto.update = function update() {
        if (this._popper !== null) {
          this._popper.scheduleUpdate();
        }
      }; // Protected
Mark Otto's avatar
dist    
Mark Otto committed
408
409


Mark Otto's avatar
dist    
Mark Otto committed
410
411
412
      _proto.isWithContent = function isWithContent() {
        return Boolean(this.getTitle());
      };
Mark Otto's avatar
dist    
Mark Otto committed
413

Mark Otto's avatar
dist    
Mark Otto committed
414
415
416
      _proto.addAttachmentClass = function addAttachmentClass(attachment) {
        $$$1(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
      };
Mark Otto's avatar
dist    
Mark Otto committed
417

Mark Otto's avatar
dist    
Mark Otto committed
418
419
420
421
      _proto.getTipElement = function getTipElement() {
        this.tip = this.tip || $$$1(this.config.template)[0];
        return this.tip;
      };
Mark Otto's avatar
dist    
Mark Otto committed
422

Mark Otto's avatar
dist    
Mark Otto committed
423
424
425
426
427
      _proto.setContent = function setContent() {
        var tip = this.getTipElement();
        this.setElementContent($$$1(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle());
        $$$1(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW);
      };
Mark Otto's avatar
dist    
Mark Otto committed
428

Mark Otto's avatar
dist    
Mark Otto committed
429
430
      _proto.setElementContent = function setElementContent($element, content) {
        var html = this.config.html;
Mark Otto's avatar
dist    
Mark Otto committed
431

Mark Otto's avatar
dist    
Mark Otto committed
432
433
434
435
436
437
438
439
        if (typeof content === 'object' && (content.nodeType || content.jquery)) {
          // Content is a DOM node or a jQuery
          if (html) {
            if (!$$$1(content).parent().is($element)) {
              $element.empty().append(content);
            }
          } else {
            $element.text($$$1(content).text());
XhmikosR's avatar
XhmikosR committed
440
441
          }
        } else {
Mark Otto's avatar
dist    
Mark Otto committed
442
          $element[html ? 'html' : 'text'](content);
XhmikosR's avatar
XhmikosR committed
443
        }
Mark Otto's avatar
dist    
Mark Otto committed
444
      };
445

Mark Otto's avatar
dist    
Mark Otto committed
446
447
      _proto.getTitle = function getTitle() {
        var title = this.element.getAttribute('data-original-title');
448

Mark Otto's avatar
dist    
Mark Otto committed
449
450
451
        if (!title) {
          title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
        }
452

Mark Otto's avatar
dist    
Mark Otto committed
453
454
        return title;
      }; // Private
455

Mark Otto's avatar
grunt    
Mark Otto committed
456

Mark Otto's avatar
dist    
Mark Otto committed
457
458
459
      _proto._getAttachment = function _getAttachment(placement) {
        return AttachmentMap[placement.toUpperCase()];
      };
Mark Otto's avatar
dist    
Mark Otto committed
460

Mark Otto's avatar
dist    
Mark Otto committed
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
      _proto._setListeners = function _setListeners() {
        var _this3 = this;

        var triggers = this.config.trigger.split(' ');
        triggers.forEach(function (trigger) {
          if (trigger === 'click') {
            $$$1(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
              return _this3.toggle(event);
            });
          } 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;
            $$$1(_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
grunt    
Mark Otto committed
479

Mark Otto's avatar
dist    
Mark Otto committed
480
481
          $$$1(_this3.element).closest('.modal').on('hide.bs.modal', function () {
            return _this3.hide();
Mark Otto's avatar
dist    
Mark Otto committed
482
          });
Mark Otto's avatar
dist    
Mark Otto committed
483
484
485
486
487
488
        });

        if (this.config.selector) {
          this.config = _objectSpread({}, this.config, {
            trigger: 'manual',
            selector: ''
Mark Otto's avatar
dist    
Mark Otto committed
489
          });
Mark Otto's avatar
dist    
Mark Otto committed
490
491
        } else {
          this._fixTitle();
Mark Otto's avatar
dist    
Mark Otto committed
492
        }
Mark Otto's avatar
dist    
Mark Otto committed
493
      };
Mark Otto's avatar
dist    
Mark Otto committed
494

Mark Otto's avatar
dist    
Mark Otto committed
495
496
      _proto._fixTitle = function _fixTitle() {
        var titleType = typeof this.element.getAttribute('data-original-title');
497

Mark Otto's avatar
dist    
Mark Otto committed
498
499
500
501
502
        if (this.element.getAttribute('title') || titleType !== 'string') {
          this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
          this.element.setAttribute('title', '');
        }
      };
503

Mark Otto's avatar
dist    
Mark Otto committed
504
505
506
      _proto._enter = function _enter(event, context) {
        var dataKey = this.constructor.DATA_KEY;
        context = context || $$$1(event.currentTarget).data(dataKey);
507

Mark Otto's avatar
dist    
Mark Otto committed
508
509
510
511
        if (!context) {
          context = new this.constructor(event.currentTarget, this._getDelegateConfig());
          $$$1(event.currentTarget).data(dataKey, context);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
512

Mark Otto's avatar
dist    
Mark Otto committed
513
514
515
        if (event) {
          context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
        }
Mark Otto's avatar
grunt    
Mark Otto committed
516

Mark Otto's avatar
dist    
Mark Otto committed
517
518
519
520
        if ($$$1(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
          context._hoverState = HoverState.SHOW;
          return;
        }
521

Mark Otto's avatar
dist    
Mark Otto committed
522
        clearTimeout(context._timeout);
Mark Otto's avatar
dist    
Mark Otto committed
523
        context._hoverState = HoverState.SHOW;
Mark Otto's avatar
grunt    
Mark Otto committed
524

Mark Otto's avatar
dist    
Mark Otto committed
525
        if (!context.config.delay || !context.config.delay.show) {
526
          context.show();
Mark Otto's avatar
dist    
Mark Otto committed
527
          return;
528
529
        }

Mark Otto's avatar
dist    
Mark Otto committed
530
531
532
533
534
535
        context._timeout = setTimeout(function () {
          if (context._hoverState === HoverState.SHOW) {
            context.show();
          }
        }, context.config.delay.show);
      };
Mark Otto's avatar
dist    
Mark Otto committed
536

Mark Otto's avatar
dist    
Mark Otto committed
537
538
539
      _proto._leave = function _leave(event, context) {
        var dataKey = this.constructor.DATA_KEY;
        context = context || $$$1(event.currentTarget).data(dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
540

Mark Otto's avatar
dist    
Mark Otto committed
541
542
543
544
        if (!context) {
          context = new this.constructor(event.currentTarget, this._getDelegateConfig());
          $$$1(event.currentTarget).data(dataKey, context);
        }
545

Mark Otto's avatar
dist    
Mark Otto committed
546
547
548
        if (event) {
          context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
        }
549

Mark Otto's avatar
dist    
Mark Otto committed
550
551
552
        if (context._isWithActiveTrigger()) {
          return;
        }
553

Mark Otto's avatar
dist    
Mark Otto committed
554
555
        clearTimeout(context._timeout);
        context._hoverState = HoverState.OUT;
Mark Otto's avatar
dist    
Mark Otto committed
556

Mark Otto's avatar
dist    
Mark Otto committed
557
        if (!context.config.delay || !context.config.delay.hide) {
Mark Otto's avatar
dist    
Mark Otto committed
558
          context.hide();
Mark Otto's avatar
dist    
Mark Otto committed
559
          return;
560
561
        }

Mark Otto's avatar
dist    
Mark Otto committed
562
563
564
565
566
567
568
569
570
571
572
573
        context._timeout = setTimeout(function () {
          if (context._hoverState === HoverState.OUT) {
            context.hide();
          }
        }, context.config.delay.hide);
      };

      _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
        for (var trigger in this._activeTrigger) {
          if (this._activeTrigger[trigger]) {
            return true;
          }
Mark Otto's avatar
dist    
Mark Otto committed
574
        }
Mark Otto's avatar
grunt    
Mark Otto committed
575

Mark Otto's avatar
dist    
Mark Otto committed
576
577
        return false;
      };
fat's avatar
fat committed
578

Mark Otto's avatar
dist    
Mark Otto committed
579
580
      _proto._getConfig = function _getConfig(config) {
        config = _objectSpread({}, this.constructor.Default, $$$1(this.element).data(), typeof config === 'object' && config ? config : {});
Mark Otto's avatar
grunt    
Mark Otto committed
581

Mark Otto's avatar
dist    
Mark Otto committed
582
583
584
585
586
587
        if (typeof config.delay === 'number') {
          config.delay = {
            show: config.delay,
            hide: config.delay
          };
        }
Mark Otto's avatar
grunt    
Mark Otto committed
588

Mark Otto's avatar
dist    
Mark Otto committed
589
590
591
        if (typeof config.title === 'number') {
          config.title = config.title.toString();
        }
Mark Otto's avatar
grunt    
Mark Otto committed
592

Mark Otto's avatar
dist    
Mark Otto committed
593
594
595
        if (typeof config.content === 'number') {
          config.content = config.content.toString();
        }
Mark Otto's avatar
grunt    
Mark Otto committed
596

Mark Otto's avatar
dist    
Mark Otto committed
597
598
599
        Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
        return config;
      };
Mark Otto's avatar
grunt    
Mark Otto committed
600

Mark Otto's avatar
dist    
Mark Otto committed
601
602
      _proto._getDelegateConfig = function _getDelegateConfig() {
        var config = {};
Mark Otto's avatar
grunt    
Mark Otto committed
603

Mark Otto's avatar
dist    
Mark Otto committed
604
605
606
607
608
        if (this.config) {
          for (var key in this.config) {
            if (this.constructor.Default[key] !== this.config[key]) {
              config[key] = this.config[key];
            }
609
610
          }
        }
Mark Otto's avatar
dist    
Mark Otto committed
611

Mark Otto's avatar
dist    
Mark Otto committed
612
613
        return config;
      };
Mark Otto's avatar
dist    
Mark Otto committed
614

Mark Otto's avatar
dist    
Mark Otto committed
615
616
617
      _proto._cleanTipClass = function _cleanTipClass() {
        var $tip = $$$1(this.getTipElement());
        var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
Mark Otto's avatar
dist    
Mark Otto committed
618

Mark Otto's avatar
dist    
Mark Otto committed
619
620
621
622
        if (tabClass !== null && tabClass.length) {
          $tip.removeClass(tabClass.join(''));
        }
      };
Mark Otto's avatar
dist    
Mark Otto committed
623

Mark Otto's avatar
dist    
Mark Otto committed
624
625
626
      _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
        var popperInstance = popperData.instance;
        this.tip = popperInstance.popper;
Mark Otto's avatar
dist    
Mark Otto committed
627

Mark Otto's avatar
dist    
Mark Otto committed
628
        this._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
629

Mark Otto's avatar
dist    
Mark Otto committed
630
631
        this.addAttachmentClass(this._getAttachment(popperData.placement));
      };
Mark Otto's avatar
dist    
Mark Otto committed
632

Mark Otto's avatar
dist    
Mark Otto committed
633
634
635
      _proto._fixTransition = function _fixTransition() {
        var tip = this.getTipElement();
        var initConfigAnimation = this.config.animation;
Mark Otto's avatar
dist    
Mark Otto committed
636

Mark Otto's avatar
dist    
Mark Otto committed
637
638
639
        if (tip.getAttribute('x-placement') !== null) {
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
640

Mark Otto's avatar
dist    
Mark Otto committed
641
642
643
644
645
646
        $$$1(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
647
648


Mark Otto's avatar
dist    
Mark Otto committed
649
650
651
      Tooltip._jQueryInterface = function _jQueryInterface(config) {
        return this.each(function () {
          var data = $$$1(this).data(DATA_KEY);
Mark Otto's avatar
dist    
Mark Otto committed
652

Mark Otto's avatar
dist    
Mark Otto committed
653
          var _config = typeof config === 'object' && config;
Mark Otto's avatar
dist    
Mark Otto committed
654

Mark Otto's avatar
dist    
Mark Otto committed
655
656
657
          if (!data && /dispose|hide/.test(config)) {
            return;
          }
Mark Otto's avatar
dist    
Mark Otto committed
658

Mark Otto's avatar
dist    
Mark Otto committed
659
660
661
662
663
664
665
666
667
          if (!data) {
            data = new Tooltip(this, _config);
            $$$1(this).data(DATA_KEY, data);
          }

          if (typeof config === 'string') {
            if (typeof data[config] === 'undefined') {
              throw new TypeError("No method named \"" + config + "\"");
            }
Mark Otto's avatar
grunt    
Mark Otto committed
668

Mark Otto's avatar
dist    
Mark Otto committed
669
            data[config]();
Mark Otto's avatar
dist    
Mark Otto committed
670
          }
Mark Otto's avatar
dist    
Mark Otto committed
671
672
        });
      };
Mark Otto's avatar
dist    
Mark Otto committed
673

Mark Otto's avatar
dist    
Mark Otto committed
674
675
676
677
      _createClass(Tooltip, null, [{
        key: "VERSION",
        get: function get() {
          return VERSION;
Mark Otto's avatar
dist    
Mark Otto committed
678
        }
Mark Otto's avatar
dist    
Mark Otto committed
679
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
      }, {
        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;
        }
      }]);
Mark Otto's avatar
grunt    
Mark Otto committed
710

Mark Otto's avatar
dist    
Mark Otto committed
711
712
713
714
715
716
717
      return Tooltip;
    }();
    /**
     * ------------------------------------------------------------------------
     * jQuery
     * ------------------------------------------------------------------------
     */
718
719


Mark Otto's avatar
dist    
Mark Otto committed
720
721
    $$$1.fn[NAME] = Tooltip._jQueryInterface;
    $$$1.fn[NAME].Constructor = Tooltip;
Mark Otto's avatar
dist    
Mark Otto committed
722

Mark Otto's avatar
dist    
Mark Otto committed
723
724
725
726
    $$$1.fn[NAME].noConflict = function () {
      $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
      return Tooltip._jQueryInterface;
    };
Mark Otto's avatar
dist    
Mark Otto committed
727

Mark Otto's avatar
dist    
Mark Otto committed
728
729
    return Tooltip;
  }($, Popper);
730
731

  return Tooltip;
Mark Otto's avatar
dist    
Mark Otto committed
732
733
734

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