tooltip.js 31.8 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1
/*!
XhmikosR's avatar
XhmikosR committed
2
  * Bootstrap tooltip.js v4.3.1 (https://getbootstrap.com/)
Mark Otto's avatar
Mark Otto committed
3
  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
XhmikosR's avatar
Dist    
XhmikosR committed
4
5
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
Mark Otto's avatar
dist    
Mark Otto committed
6
(function (global, factory) {
7
8
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('popper.js'), require('./dom/selector-engine.js')) :
  typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', 'popper.js', './dom/selector-engine.js'], factory) :
XhmikosR's avatar
XhmikosR committed
9
10
11
12
13
14
  (global = global || self, global.Tooltip = factory(global.Data, global.EventHandler, global.Manipulator, global.Popper, global.SelectorEngine));
}(this, function (Data, EventHandler, Manipulator, Popper, SelectorEngine) { 'use strict';

  Data = Data && Data.hasOwnProperty('default') ? Data['default'] : Data;
  EventHandler = EventHandler && EventHandler.hasOwnProperty('default') ? EventHandler['default'] : EventHandler;
  Manipulator = Manipulator && Manipulator.hasOwnProperty('default') ? Manipulator['default'] : Manipulator;
Mark Otto's avatar
dist    
Mark Otto committed
15
  Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
XhmikosR's avatar
XhmikosR committed
16
  SelectorEngine = SelectorEngine && SelectorEngine.hasOwnProperty('default') ? SelectorEngine['default'] : SelectorEngine;
Mark Otto's avatar
dist    
Mark Otto committed
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
46
47

  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
48

Mark Otto's avatar
dist    
Mark Otto committed
49
50
51
52
53
54
55
56
57
58
  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
59

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

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

XhmikosR's avatar
XhmikosR committed
68
69
  /**
   * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
70
71
72
73
74
75
76
   * Bootstrap (v4.3.1): util/index.js
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;
  var MILLISECONDS_MULTIPLIER = 1000;
  var TRANSITION_END = 'transitionend';
XhmikosR's avatar
Dist.    
XhmikosR committed
77
78
  var _window = window,
      jQuery = _window.jQuery; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
XhmikosR's avatar
XhmikosR committed
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

  var toType = function toType(obj) {
    return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  };
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
      // eslint-disable-next-line no-bitwise
      prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
    } while (document.getElementById(prefix));

    return prefix;
  };

  var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
    if (!element) {
      return 0;
    } // Get transition-duration of the element


    var _window$getComputedSt = window.getComputedStyle(element),
        transitionDuration = _window$getComputedSt.transitionDuration,
        transitionDelay = _window$getComputedSt.transitionDelay;

    var floatTransitionDuration = parseFloat(transitionDuration);
    var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found

    if (!floatTransitionDuration && !floatTransitionDelay) {
      return 0;
    } // If multiple durations are defined, take the first


    transitionDuration = transitionDuration.split(',')[0];
    transitionDelay = transitionDelay.split(',')[0];
    return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  };

  var triggerTransitionEnd = function triggerTransitionEnd(element) {
XhmikosR's avatar
XhmikosR committed
123
124
125
    var evt = document.createEvent('HTMLEvents');
    evt.initEvent(TRANSITION_END, true, true);
    element.dispatchEvent(evt);
XhmikosR's avatar
XhmikosR committed
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
  };

  var isElement = function isElement(obj) {
    return (obj[0] || obj).nodeType;
  };

  var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
    var called = false;
    var durationPadding = 5;
    var emulatedDuration = duration + durationPadding;

    function listener() {
      called = true;
      element.removeEventListener(TRANSITION_END, listener);
    }

    element.addEventListener(TRANSITION_END, listener);
    setTimeout(function () {
      if (!called) {
        triggerTransitionEnd(element);
      }
    }, emulatedDuration);
  };

  var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
    Object.keys(configTypes).forEach(function (property) {
      var expectedTypes = configTypes[property];
      var value = config[property];
      var valueType = value && isElement(value) ? 'element' : toType(value);

      if (!new RegExp(expectedTypes).test(valueType)) {
        throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
      }
    });
  };

  var makeArray = function makeArray(nodeList) {
    if (!nodeList) {
      return [];
    }

    return [].slice.call(nodeList);
  };

  var findShadowRoot = function findShadowRoot(element) {
    if (!document.documentElement.attachShadow) {
      return null;
    } // Can find the shadow root otherwise it'll return the document


    if (typeof element.getRootNode === 'function') {
      var root = element.getRootNode();
      return root instanceof ShadowRoot ? root : null;
    }

    if (element instanceof ShadowRoot) {
      return element;
    } // when we don't find a shadow root


    if (!element.parentNode) {
      return null;
    }

    return findShadowRoot(element.parentNode);
  }; // eslint-disable-next-line no-empty-function


  var noop = function noop() {
    return function () {};
  };

  /**
   * --------------------------------------------------------------------------
   * Bootstrap (v4.3.1): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
201
202
203
204
205
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
XhmikosR committed
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  /**
   * A pattern that recognizes a commonly useful subset of URLs that are safe.
   *
   * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
   */

  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  /**
   * A pattern that matches safe data URLs. Only matches image, video and audio types.
   *
   * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
   */

  var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;

  var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) {
    var attrName = attr.nodeName.toLowerCase();

    if (allowedAttributeList.indexOf(attrName) !== -1) {
      if (uriAttrs.indexOf(attrName) !== -1) {
        return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
      }

      return true;
    }

    var regExp = allowedAttributeList.filter(function (attrRegex) {
      return attrRegex instanceof RegExp;
    }); // Check if a regular expression validates the attribute.

    for (var i = 0, l = regExp.length; i < l; i++) {
      if (attrName.match(regExp[i])) {
        return true;
      }
    }

    return false;
  };

XhmikosR's avatar
XhmikosR committed
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
  var DefaultWhitelist = {
    // Global attributes allowed on any supplied element below.
    '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
    a: ['target', 'href', 'title', 'rel'],
    area: [],
    b: [],
    br: [],
    col: [],
    code: [],
    div: [],
    em: [],
    hr: [],
    h1: [],
    h2: [],
    h3: [],
    h4: [],
    h5: [],
    h6: [],
    i: [],
    img: ['src', 'alt', 'title', 'width', 'height'],
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  };
  function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
279
    if (!unsafeHtml.length) {
XhmikosR's avatar
XhmikosR committed
280
281
282
283
284
285
286
287
288
289
      return unsafeHtml;
    }

    if (sanitizeFn && typeof sanitizeFn === 'function') {
      return sanitizeFn(unsafeHtml);
    }

    var domParser = new window.DOMParser();
    var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
    var whitelistKeys = Object.keys(whiteList);
XhmikosR's avatar
XhmikosR committed
290
    var elements = makeArray(createdDocument.body.querySelectorAll('*'));
XhmikosR's avatar
XhmikosR committed
291
292
293
294
295

    var _loop = function _loop(i, len) {
      var el = elements[i];
      var elName = el.nodeName.toLowerCase();

XhmikosR's avatar
XhmikosR committed
296
      if (whitelistKeys.indexOf(elName) === -1) {
XhmikosR's avatar
XhmikosR committed
297
298
299
300
        el.parentNode.removeChild(el);
        return "continue";
      }

XhmikosR's avatar
XhmikosR committed
301
      var attributeList = makeArray(el.attributes);
XhmikosR's avatar
XhmikosR committed
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
      var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
      attributeList.forEach(function (attr) {
        if (!allowedAttribute(attr, whitelistedAttributes)) {
          el.removeAttribute(attr.nodeName);
        }
      });
    };

    for (var i = 0, len = elements.length; i < len; i++) {
      var _ret = _loop(i, len);

      if (_ret === "continue") continue;
    }

    return createdDocument.body.innerHTML;
  }

XhmikosR's avatar
Dist    
XhmikosR committed
319
320
321
322
323
324
325
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tooltip';
XhmikosR's avatar
XhmikosR committed
326
  var VERSION = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
327
328
329
330
  var DATA_KEY = 'bs.tooltip';
  var EVENT_KEY = "." + DATA_KEY;
  var CLASS_PREFIX = 'bs-tooltip';
  var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
XhmikosR's avatar
XhmikosR committed
331
  var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
XhmikosR's avatar
Dist    
XhmikosR committed
332
333
334
335
336
337
338
339
340
  var DefaultType = {
    animation: 'boolean',
    template: 'string',
    title: '(string|element|function)',
    trigger: 'string',
    delay: '(number|object)',
    html: 'boolean',
    selector: '(string|boolean)',
    placement: '(string|function)',
Mark Otto's avatar
Mark Otto committed
341
    offset: '(number|string|function)',
XhmikosR's avatar
Dist    
XhmikosR committed
342
343
    container: '(string|element|boolean)',
    fallbackPlacement: '(string|array)',
XhmikosR's avatar
XhmikosR committed
344
345
346
347
    boundary: '(string|element)',
    sanitize: 'boolean',
    sanitizeFn: '(null|function)',
    whiteList: 'object'
XhmikosR's avatar
Dist    
XhmikosR committed
348
349
350
351
352
353
354
355
356
357
  };
  var AttachmentMap = {
    AUTO: 'auto',
    TOP: 'top',
    RIGHT: 'right',
    BOTTOM: 'bottom',
    LEFT: 'left'
  };
  var Default = {
    animation: true,
XhmikosR's avatar
XhmikosR committed
358
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
XhmikosR's avatar
Dist    
XhmikosR committed
359
360
361
362
363
364
365
366
367
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: 0,
    container: false,
    fallbackPlacement: 'flip',
XhmikosR's avatar
XhmikosR committed
368
369
370
371
    boundary: 'scrollParent',
    sanitize: true,
    sanitizeFn: null,
    whiteList: DefaultWhitelist
XhmikosR's avatar
Dist    
XhmikosR committed
372
373
374
375
376
  };
  var HoverState = {
    SHOW: 'show',
    OUT: 'out'
  };
XhmikosR's avatar
XhmikosR committed
377
  var Event = {
XhmikosR's avatar
Dist    
XhmikosR committed
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
    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_INNER: '.tooltip-inner',
XhmikosR's avatar
XhmikosR committed
395
    TOOLTIP_ARROW: '.tooltip-arrow'
XhmikosR's avatar
Dist    
XhmikosR committed
396
397
398
399
400
401
  };
  var Trigger = {
    HOVER: 'hover',
    FOCUS: 'focus',
    CLICK: 'click',
    MANUAL: 'manual'
Mark Otto's avatar
dist    
Mark Otto committed
402
403
    /**
     * ------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
404
     * Class Definition
Mark Otto's avatar
dist    
Mark Otto committed
405
406
     * ------------------------------------------------------------------------
     */
XhmikosR's avatar
Dist    
XhmikosR committed
407
408
409
410
411
412
413

  };

  var Tooltip =
  /*#__PURE__*/
  function () {
    function Tooltip(element, config) {
Mark Otto's avatar
dist    
Mark Otto committed
414
      /**
XhmikosR's avatar
Dist    
XhmikosR committed
415
416
       * Check for Popper dependency
       * Popper - https://popper.js.org
Mark Otto's avatar
dist    
Mark Otto committed
417
       */
XhmikosR's avatar
Dist    
XhmikosR committed
418
      if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
419
        throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)');
XhmikosR's avatar
Dist    
XhmikosR committed
420
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
421
422


XhmikosR's avatar
Dist    
XhmikosR committed
423
424
425
426
427
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
428

XhmikosR's avatar
Dist    
XhmikosR committed
429
430
431
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
432

XhmikosR's avatar
Dist    
XhmikosR committed
433
      this._setListeners();
XhmikosR's avatar
XhmikosR committed
434
435

      Data.setData(element, this.constructor.DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
436
    } // Getters
437

Jacob Thornton's avatar
Jacob Thornton committed
438

XhmikosR's avatar
Dist    
XhmikosR committed
439
    var _proto = Tooltip.prototype;
440

XhmikosR's avatar
Dist    
XhmikosR committed
441
442
443
444
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
445

XhmikosR's avatar
Dist    
XhmikosR committed
446
447
448
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
449

XhmikosR's avatar
Dist    
XhmikosR committed
450
451
452
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Mark Otto's avatar
dist    
Mark Otto committed
453

XhmikosR's avatar
Dist    
XhmikosR committed
454
455
456
457
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Mark Otto's avatar
Mark Otto committed
458

XhmikosR's avatar
Dist    
XhmikosR committed
459
460
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
461
        var context = Data.getData(event.delegateTarget, dataKey);
Mark Otto's avatar
Mark Otto committed
462

XhmikosR's avatar
Dist    
XhmikosR committed
463
        if (!context) {
XhmikosR's avatar
XhmikosR committed
464
465
          context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
          Data.setData(event.delegateTarget, dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
466
        }
fat's avatar
fat committed
467

XhmikosR's avatar
Dist    
XhmikosR committed
468
        context._activeTrigger.click = !context._activeTrigger.click;
fat's avatar
fat committed
469

XhmikosR's avatar
Dist    
XhmikosR committed
470
471
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
Mark Otto's avatar
grunt    
Mark Otto committed
472
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
473
474
475
          context._leave(null, context);
        }
      } else {
XhmikosR's avatar
XhmikosR committed
476
        if (this.getTipElement().classList.contains(ClassName.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
477
          this._leave(null, this);
478

XhmikosR's avatar
Dist    
XhmikosR committed
479
          return;
Mark Otto's avatar
dist    
Mark Otto committed
480
        }
481

XhmikosR's avatar
Dist    
XhmikosR committed
482
483
484
485
486
487
        this._enter(null, this);
      }
    };

    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
XhmikosR's avatar
XhmikosR committed
488
489
490
      Data.removeData(this.element, this.constructor.DATA_KEY);
      EventHandler.off(this.element, this.constructor.EVENT_KEY);
      EventHandler.off(SelectorEngine.closest(this.element, '.modal'), 'hide.bs.modal');
491

XhmikosR's avatar
Dist    
XhmikosR committed
492
      if (this.tip) {
XhmikosR's avatar
XhmikosR committed
493
        this.tip.parentNode.removeChild(this.tip);
XhmikosR's avatar
Dist    
XhmikosR committed
494
      }
495

XhmikosR's avatar
Dist    
XhmikosR committed
496
497
498
499
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
500

XhmikosR's avatar
Dist    
XhmikosR committed
501
502
503
      if (this._popper !== null) {
        this._popper.destroy();
      }
504

XhmikosR's avatar
Dist    
XhmikosR committed
505
506
507
508
509
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
510

XhmikosR's avatar
Dist    
XhmikosR committed
511
512
    _proto.show = function show() {
      var _this = this;
513

XhmikosR's avatar
XhmikosR committed
514
      if (this.element.style.display === 'none') {
XhmikosR's avatar
Dist    
XhmikosR committed
515
516
        throw new Error('Please use show on visible elements');
      }
517

XhmikosR's avatar
Dist    
XhmikosR committed
518
      if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
519
520
        var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
        var shadowRoot = findShadowRoot(this.element);
XhmikosR's avatar
Dist.    
XhmikosR committed
521
        var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
522

XhmikosR's avatar
XhmikosR committed
523
        if (showEvent.defaultPrevented || !isInTheDom) {
XhmikosR's avatar
Dist    
XhmikosR committed
524
525
          return;
        }
526

XhmikosR's avatar
Dist    
XhmikosR committed
527
        var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
528
        var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist    
XhmikosR committed
529
530
531
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
532

XhmikosR's avatar
Dist    
XhmikosR committed
533
        if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
534
          tip.classList.add(ClassName.FADE);
XhmikosR's avatar
Dist    
XhmikosR committed
535
        }
536

XhmikosR's avatar
Dist    
XhmikosR committed
537
        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
538

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

XhmikosR's avatar
Dist    
XhmikosR committed
541
        this.addAttachmentClass(attachment);
Mark Otto's avatar
dist    
Mark Otto committed
542
543
544

        var container = this._getContainer();

XhmikosR's avatar
XhmikosR committed
545
        Data.setData(tip, this.constructor.DATA_KEY, this);
Mark Otto's avatar
Mark Otto committed
546

XhmikosR's avatar
XhmikosR committed
547
548
        if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
          container.appendChild(tip);
XhmikosR's avatar
Dist    
XhmikosR committed
549
        }
Mark Otto's avatar
grunt    
Mark Otto committed
550

XhmikosR's avatar
XhmikosR committed
551
        EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
XhmikosR's avatar
Dist    
XhmikosR committed
552
553
554
        this._popper = new Popper(this.element, tip, {
          placement: attachment,
          modifiers: {
Mark Otto's avatar
Mark Otto committed
555
            offset: this._getOffset(),
XhmikosR's avatar
Dist    
XhmikosR committed
556
557
            flip: {
              behavior: this.config.fallbackPlacement
Mark Otto's avatar
dist    
Mark Otto committed
558
            },
XhmikosR's avatar
Dist    
XhmikosR committed
559
            arrow: {
XhmikosR's avatar
XhmikosR committed
560
              element: Selector.TOOLTIP_ARROW
XhmikosR's avatar
Dist    
XhmikosR committed
561
562
563
564
565
566
567
            },
            preventOverflow: {
              boundariesElement: this.config.boundary
            }
          },
          onCreate: function onCreate(data) {
            if (data.originalPlacement !== data.placement) {
Johann-S's avatar
build    
Johann-S committed
568
569
              _this._handlePopperPlacementChange(data);
            }
XhmikosR's avatar
Dist    
XhmikosR committed
570
571
          },
          onUpdate: function onUpdate(data) {
XhmikosR's avatar
Dist    
XhmikosR committed
572
            return _this._handlePopperPlacementChange(data);
Johann-S's avatar
build    
Johann-S committed
573
          }
XhmikosR's avatar
Dist    
XhmikosR committed
574
        });
XhmikosR's avatar
XhmikosR committed
575
        tip.classList.add(ClassName.SHOW); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist    
XhmikosR committed
576
577
578
        // 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
579

XhmikosR's avatar
Dist    
XhmikosR committed
580
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
581
582
583
          makeArray(document.body.children).forEach(function (element) {
            EventHandler.on(element, 'mouseover', noop());
          });
XhmikosR's avatar
Dist    
XhmikosR committed
584
        }
Mark Otto's avatar
build    
Mark Otto committed
585

XhmikosR's avatar
Dist    
XhmikosR committed
586
587
588
589
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
590

XhmikosR's avatar
Dist    
XhmikosR committed
591
592
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
XhmikosR's avatar
XhmikosR committed
593
          EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
594

XhmikosR's avatar
Dist    
XhmikosR committed
595
596
          if (prevHoverState === HoverState.OUT) {
            _this._leave(null, _this);
597
          }
XhmikosR's avatar
Dist    
XhmikosR committed
598
599
        };

XhmikosR's avatar
XhmikosR committed
600
601
602
603
        if (this.tip.classList.contains(ClassName.FADE)) {
          var transitionDuration = getTransitionDurationFromElement(this.tip);
          EventHandler.one(this.tip, TRANSITION_END, complete);
          emulateTransitionEnd(this.tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
604
605
        } else {
          complete();
606
        }
XhmikosR's avatar
Dist    
XhmikosR committed
607
608
      }
    };
609

XhmikosR's avatar
Dist    
XhmikosR committed
610
611
    _proto.hide = function hide(callback) {
      var _this2 = this;
612

XhmikosR's avatar
Dist    
XhmikosR committed
613
      var tip = this.getTipElement();
Mark Otto's avatar
dist    
Mark Otto committed
614

XhmikosR's avatar
Dist    
XhmikosR committed
615
616
617
618
      var complete = function complete() {
        if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
          tip.parentNode.removeChild(tip);
        }
619

XhmikosR's avatar
Dist    
XhmikosR committed
620
        _this2._cleanTipClass();
Mark Otto's avatar
grunt    
Mark Otto committed
621

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

XhmikosR's avatar
XhmikosR committed
624
        EventHandler.trigger(_this2.element, _this2.constructor.Event.HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
625

XhmikosR's avatar
Dist    
XhmikosR committed
626
627
628
        if (_this2._popper !== null) {
          _this2._popper.destroy();
        }
629

XhmikosR's avatar
Dist    
XhmikosR committed
630
631
632
633
        if (callback) {
          callback();
        }
      };
Mark Otto's avatar
grunt    
Mark Otto committed
634

XhmikosR's avatar
XhmikosR committed
635
      var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
Mark Otto's avatar
grunt    
Mark Otto committed
636

XhmikosR's avatar
XhmikosR committed
637
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
638
639
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
640

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

XhmikosR's avatar
Dist    
XhmikosR committed
644
      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
645
646
647
        makeArray(document.body.children).forEach(function (element) {
          return EventHandler.off(element, 'mouseover', noop);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
648
      }
Mark Otto's avatar
dist    
Mark Otto committed
649

XhmikosR's avatar
Dist    
XhmikosR committed
650
651
652
      this._activeTrigger[Trigger.CLICK] = false;
      this._activeTrigger[Trigger.FOCUS] = false;
      this._activeTrigger[Trigger.HOVER] = false;
Mark Otto's avatar
dist    
Mark Otto committed
653

XhmikosR's avatar
XhmikosR committed
654
655
656
657
      if (this.tip.classList.contains(ClassName.FADE)) {
        var transitionDuration = getTransitionDurationFromElement(tip);
        EventHandler.one(tip, TRANSITION_END, complete);
        emulateTransitionEnd(tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
658
659
660
      } else {
        complete();
      }
Mark Otto's avatar
dist    
Mark Otto committed
661

XhmikosR's avatar
Dist    
XhmikosR committed
662
663
      this._hoverState = '';
    };
Mark Otto's avatar
dist    
Mark Otto committed
664

XhmikosR's avatar
Dist    
XhmikosR committed
665
666
667
668
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
669
670
    } // Protected
    ;
Mark Otto's avatar
dist    
Mark Otto committed
671

XhmikosR's avatar
Dist    
XhmikosR committed
672
673
674
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Mark Otto's avatar
dist    
Mark Otto committed
675

XhmikosR's avatar
Dist    
XhmikosR committed
676
    _proto.addAttachmentClass = function addAttachmentClass(attachment) {
XhmikosR's avatar
XhmikosR committed
677
      this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
XhmikosR's avatar
Dist    
XhmikosR committed
678
    };
Mark Otto's avatar
dist    
Mark Otto committed
679

XhmikosR's avatar
Dist    
XhmikosR committed
680
    _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
XhmikosR committed
681
682
683
684
685
686
687
      if (this.tip) {
        return this.tip;
      }

      var element = document.createElement('div');
      element.innerHTML = this.config.template;
      this.tip = element.children[0];
XhmikosR's avatar
Dist    
XhmikosR committed
688
689
      return this.tip;
    };
Mark Otto's avatar
dist    
Mark Otto committed
690

XhmikosR's avatar
Dist    
XhmikosR committed
691
692
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
693
694
695
      this.setElementContent(SelectorEngine.findOne(Selector.TOOLTIP_INNER, tip), this.getTitle());
      tip.classList.remove(ClassName.FADE);
      tip.classList.remove(ClassName.SHOW);
XhmikosR's avatar
Dist    
XhmikosR committed
696
    };
Mark Otto's avatar
dist    
Mark Otto committed
697

XhmikosR's avatar
XhmikosR committed
698
699
700
701
702
    _proto.setElementContent = function setElementContent(element, content) {
      if (element === null) {
        return;
      }

XhmikosR's avatar
Dist    
XhmikosR committed
703
      if (typeof content === 'object' && (content.nodeType || content.jquery)) {
XhmikosR's avatar
XhmikosR committed
704
705
706
707
708
        if (content.jquery) {
          content = content[0];
        } // content is a DOM node or a jQuery


XhmikosR's avatar
XhmikosR committed
709
        if (this.config.html) {
XhmikosR's avatar
XhmikosR committed
710
711
712
          if (content.parentNode !== element) {
            element.innerHTML = '';
            element.appendChild(content);
XhmikosR's avatar
XhmikosR committed
713
714
          }
        } else {
XhmikosR's avatar
XhmikosR committed
715
          element.innerText = content.textContent;
XhmikosR's avatar
XhmikosR committed
716
        }
XhmikosR's avatar
XhmikosR committed
717
718
719
720
721
722
723
724
725

        return;
      }

      if (this.config.html) {
        if (this.config.sanitize) {
          content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
        }

XhmikosR's avatar
XhmikosR committed
726
        element.innerHTML = content;
XhmikosR's avatar
Dist    
XhmikosR committed
727
      } else {
XhmikosR's avatar
XhmikosR committed
728
        element.innerText = content;
XhmikosR's avatar
Dist    
XhmikosR committed
729
730
      }
    };
731

XhmikosR's avatar
Dist    
XhmikosR committed
732
733
    _proto.getTitle = function getTitle() {
      var title = this.element.getAttribute('data-original-title');
734

XhmikosR's avatar
Dist    
XhmikosR committed
735
736
737
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
738

XhmikosR's avatar
Dist    
XhmikosR committed
739
      return title;
Mark Otto's avatar
Mark Otto committed
740
741
    } // Private
    ;
Mark Otto's avatar
grunt    
Mark Otto committed
742

Mark Otto's avatar
Mark Otto committed
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
    _proto._getOffset = function _getOffset() {
      var _this3 = this;

      var offset = {};

      if (typeof this.config.offset === 'function') {
        offset.fn = function (data) {
          data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {});
          return data;
        };
      } else {
        offset.offset = this.config.offset;
      }

      return offset;
    };

Mark Otto's avatar
dist    
Mark Otto committed
760
761
762
763
764
    _proto._getContainer = function _getContainer() {
      if (this.config.container === false) {
        return document.body;
      }

XhmikosR's avatar
XhmikosR committed
765
766
      if (isElement(this.config.container)) {
        return this.config.container;
Mark Otto's avatar
dist    
Mark Otto committed
767
768
      }

XhmikosR's avatar
XhmikosR committed
769
      return SelectorEngine.findOne(this.config.container);
Mark Otto's avatar
dist    
Mark Otto committed
770
771
    };

XhmikosR's avatar
Dist    
XhmikosR committed
772
773
774
    _proto._getAttachment = function _getAttachment(placement) {
      return AttachmentMap[placement.toUpperCase()];
    };
Mark Otto's avatar
dist    
Mark Otto committed
775

XhmikosR's avatar
Dist    
XhmikosR committed
776
    _proto._setListeners = function _setListeners() {
Mark Otto's avatar
Mark Otto committed
777
      var _this4 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
778

XhmikosR's avatar
Dist    
XhmikosR committed
779
780
781
      var triggers = this.config.trigger.split(' ');
      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
782
          EventHandler.on(_this4.element, _this4.constructor.Event.CLICK, _this4.config.selector, function (event) {
Mark Otto's avatar
Mark Otto committed
783
            return _this4.toggle(event);
Mark Otto's avatar
dist    
Mark Otto committed
784
          });
XhmikosR's avatar
Dist    
XhmikosR committed
785
        } else if (trigger !== Trigger.MANUAL) {
Mark Otto's avatar
Mark Otto committed
786
787
          var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN;
          var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT;
XhmikosR's avatar
XhmikosR committed
788
          EventHandler.on(_this4.element, eventIn, _this4.config.selector, function (event) {
Mark Otto's avatar
Mark Otto committed
789
            return _this4._enter(event);
XhmikosR's avatar
XhmikosR committed
790
791
          });
          EventHandler.on(_this4.element, eventOut, _this4.config.selector, function (event) {
Mark Otto's avatar
Mark Otto committed
792
            return _this4._leave(event);
Mark Otto's avatar
dist    
Mark Otto committed
793
794
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
795
      });
XhmikosR's avatar
XhmikosR committed
796
      EventHandler.on(SelectorEngine.closest(this.element, '.modal'), 'hide.bs.modal', function () {
Mark Otto's avatar
Mark Otto committed
797
798
        if (_this4.element) {
          _this4.hide();
XhmikosR's avatar
Dist    
XhmikosR committed
799
800
        }
      });
Mark Otto's avatar
dist    
Mark Otto committed
801

XhmikosR's avatar
Dist    
XhmikosR committed
802
803
804
805
806
807
808
809
810
      if (this.config.selector) {
        this.config = _objectSpread({}, this.config, {
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
      }
    };
811

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

XhmikosR's avatar
Dist    
XhmikosR committed
815
816
817
818
819
      if (this.element.getAttribute('title') || titleType !== 'string') {
        this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
        this.element.setAttribute('title', '');
      }
    };
820

XhmikosR's avatar
Dist    
XhmikosR committed
821
822
    _proto._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
823
      context = context || Data.getData(event.delegateTarget, dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
824

XhmikosR's avatar
Dist    
XhmikosR committed
825
      if (!context) {
XhmikosR's avatar
XhmikosR committed
826
827
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
828
      }
Mark Otto's avatar
grunt    
Mark Otto committed
829

XhmikosR's avatar
Dist    
XhmikosR committed
830
831
832
      if (event) {
        context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
      }
833

XhmikosR's avatar
XhmikosR committed
834
      if (context.getTipElement().classList.contains(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
Mark Otto's avatar
dist    
Mark Otto committed
835
        context._hoverState = HoverState.SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
836
837
838
839
840
        return;
      }

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

XhmikosR's avatar
Dist    
XhmikosR committed
842
843
844
845
846
847
848
      if (!context.config.delay || !context.config.delay.show) {
        context.show();
        return;
      }

      context._timeout = setTimeout(function () {
        if (context._hoverState === HoverState.SHOW) {
849
850
          context.show();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
851
852
      }, context.config.delay.show);
    };
853

XhmikosR's avatar
Dist    
XhmikosR committed
854
855
    _proto._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
856
      context = context || Data.getData(event.delegateTarget, dataKey);
Mark Otto's avatar
dist    
Mark Otto committed
857

XhmikosR's avatar
Dist    
XhmikosR committed
858
      if (!context) {
XhmikosR's avatar
XhmikosR committed
859
860
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
861
      }
Mark Otto's avatar
grunt    
Mark Otto committed
862

XhmikosR's avatar
Dist    
XhmikosR committed
863
864
865
      if (event) {
        context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
      }
866

XhmikosR's avatar
Dist    
XhmikosR committed
867
868
869
      if (context._isWithActiveTrigger()) {
        return;
      }
870

XhmikosR's avatar
Dist    
XhmikosR committed
871
872
      clearTimeout(context._timeout);
      context._hoverState = HoverState.OUT;
873

XhmikosR's avatar
Dist    
XhmikosR committed
874
875
876
877
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
878

XhmikosR's avatar
Dist    
XhmikosR committed
879
880
      context._timeout = setTimeout(function () {
        if (context._hoverState === HoverState.OUT) {
Mark Otto's avatar
dist    
Mark Otto committed
881
          context.hide();
882
        }
XhmikosR's avatar
Dist    
XhmikosR committed
883
884
      }, context.config.delay.hide);
    };
885

XhmikosR's avatar
Dist    
XhmikosR committed
886
887
888
889
    _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
Mark Otto's avatar
dist    
Mark Otto committed
890
        }
XhmikosR's avatar
Dist    
XhmikosR committed
891
      }
Mark Otto's avatar
grunt    
Mark Otto committed
892

XhmikosR's avatar
Dist    
XhmikosR committed
893
894
      return false;
    };
fat's avatar
fat committed
895

XhmikosR's avatar
Dist    
XhmikosR committed
896
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
897
      var dataAttributes = Manipulator.getDataAttributes(this.element);
XhmikosR's avatar
XhmikosR committed
898
899
900
901
902
      Object.keys(dataAttributes).forEach(function (dataAttr) {
        if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
          delete dataAttributes[dataAttr];
        }
      });
XhmikosR's avatar
XhmikosR committed
903
904
905
906
907

      if (config && typeof config.container === 'object' && config.container.jquery) {
        config.container = config.container[0];
      }

XhmikosR's avatar
XhmikosR committed
908
      config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
Mark Otto's avatar
grunt    
Mark Otto committed
909

XhmikosR's avatar
Dist    
XhmikosR committed
910
911
912
913
914
915
      if (typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
          hide: config.delay
        };
      }
Mark Otto's avatar
grunt    
Mark Otto committed
916

XhmikosR's avatar
Dist    
XhmikosR committed
917
918
919
      if (typeof config.title === 'number') {
        config.title = config.title.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
920

XhmikosR's avatar
Dist    
XhmikosR committed
921
922
923
      if (typeof config.content === 'number') {
        config.content = config.content.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
924

XhmikosR's avatar
XhmikosR committed
925
      typeCheckConfig(NAME, config, this.constructor.DefaultType);
XhmikosR's avatar
XhmikosR committed
926
927
928
929
930

      if (config.sanitize) {
        config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
      }

XhmikosR's avatar
Dist    
XhmikosR committed
931
932
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
933

XhmikosR's avatar
Dist    
XhmikosR committed
934
935
    _proto._getDelegateConfig = function _getDelegateConfig() {
      var config = {};
Mark Otto's avatar
grunt    
Mark Otto committed
936

XhmikosR's avatar
Dist    
XhmikosR committed
937
938
939
940
      if (this.config) {
        for (var key in this.config) {
          if (this.constructor.Default[key] !== this.config[key]) {
            config[key] = this.config[key];
941
942
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
943
      }
Mark Otto's avatar
dist    
Mark Otto committed
944

XhmikosR's avatar
Dist    
XhmikosR committed
945
946
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
947

XhmikosR's avatar
Dist    
XhmikosR committed
948
    _proto._cleanTipClass = function _cleanTipClass() {
XhmikosR's avatar
XhmikosR committed
949
950
      var tip = this.getTipElement();
      var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
Mark Otto's avatar
dist    
Mark Otto committed
951

XhmikosR's avatar
Dist    
XhmikosR committed
952
      if (tabClass !== null && tabClass.length) {
XhmikosR's avatar
XhmikosR committed
953
954
955
956
957
        tabClass.map(function (token) {
          return token.trim();
        }).forEach(function (tClass) {
          return tip.classList.remove(tClass);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
958
959
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
960

XhmikosR's avatar
Dist    
XhmikosR committed
961
962
963
    _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
      var popperInstance = popperData.instance;
      this.tip = popperInstance.popper;
Mark Otto's avatar
dist    
Mark Otto committed
964

XhmikosR's avatar
Dist    
XhmikosR committed
965
      this._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
966

XhmikosR's avatar
Dist    
XhmikosR committed
967
968
      this.addAttachmentClass(this._getAttachment(popperData.placement));
    };
Mark Otto's avatar
dist    
Mark Otto committed
969

XhmikosR's avatar
Dist    
XhmikosR committed
970
971
972
    _proto._fixTransition = function _fixTransition() {
      var tip = this.getTipElement();
      var initConfigAnimation = this.config.animation;
Mark Otto's avatar
dist    
Mark Otto committed
973

XhmikosR's avatar
Dist    
XhmikosR committed
974
975
976
      if (tip.getAttribute('x-placement') !== null) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
977

XhmikosR's avatar
XhmikosR committed
978
      tip.classList.remove(ClassName.FADE);
XhmikosR's avatar
Dist    
XhmikosR committed
979
980
981
982
      this.config.animation = false;
      this.hide();
      this.show();
      this.config.animation = initConfigAnimation;
Mark Otto's avatar
Mark Otto committed
983
984
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
985

XhmikosR's avatar
Dist    
XhmikosR committed
986
987
    Tooltip._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
988
        var data = Data.getData(this, DATA_KEY);
Mark Otto's avatar
dist    
Mark Otto committed
989

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

XhmikosR's avatar
Dist    
XhmikosR committed
992
993
994
        if (!data && /dispose|hide/.test(config)) {
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
995

XhmikosR's avatar
Dist    
XhmikosR committed
996
997
998
        if (!data) {
          data = new Tooltip(this, _config);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
999

XhmikosR's avatar
Dist    
XhmikosR committed
1000
        if (typeof config === 'string') {
For faster browsing, not all history is shown. View entire blame