tooltip.js 32.6 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1
/*!
2
  * Bootstrap tooltip.js v5.0.0-alpha1 (https://getbootstrap.com/)
XhmikosR's avatar
XhmikosR committed
3
  * Copyright 2011-2020 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) {
XhmikosR's avatar
XhmikosR committed
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
  (global = global || self, global.Tooltip = factory(global.Data, global.EventHandler, global.Manipulator, global.Popper, global.SelectorEngine));
XhmikosR's avatar
XhmikosR committed
10
}(this, (function (Data, EventHandler, Manipulator, Popper, SelectorEngine) { 'use strict';
XhmikosR's avatar
XhmikosR committed
11

XhmikosR's avatar
XhmikosR committed
12
13
14
15
16
  Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
  EventHandler = EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default') ? EventHandler['default'] : EventHandler;
  Manipulator = Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default') ? Manipulator['default'] : Manipulator;
  Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
  SelectorEngine = SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, '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

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);

    if (Object.getOwnPropertySymbols) {
      var symbols = Object.getOwnPropertySymbols(object);
      if (enumerableOnly) symbols = symbols.filter(function (sym) {
        return Object.getOwnPropertyDescriptor(object, sym).enumerable;
      });
      keys.push.apply(keys, symbols);
    }

    return keys;
  }

  function _objectSpread2(target) {
Mark Otto's avatar
dist    
Mark Otto committed
64
65
66
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i] != null ? arguments[i] : {};

67
      if (i % 2) {
XhmikosR's avatar
XhmikosR committed
68
        ownKeys(Object(source), true).forEach(function (key) {
69
70
71
72
73
          _defineProperty(target, key, source[key]);
        });
      } else if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
      } else {
XhmikosR's avatar
XhmikosR committed
74
        ownKeys(Object(source)).forEach(function (key) {
75
76
          Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
Mark Otto's avatar
dist    
Mark Otto committed
77
78
      }
    }
Mark Otto's avatar
dist    
Mark Otto committed
79

Mark Otto's avatar
dist    
Mark Otto committed
80
81
    return target;
  }
82

XhmikosR's avatar
XhmikosR committed
83
84
  /**
   * --------------------------------------------------------------------------
85
   * Bootstrap (v5.0.0-alpha1): util/index.js
XhmikosR's avatar
XhmikosR committed
86
87
88
89
90
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;
  var MILLISECONDS_MULTIPLIER = 1000;
XhmikosR's avatar
XhmikosR committed
91
  var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
XhmikosR's avatar
XhmikosR committed
92
93

  var toType = function toType(obj) {
XhmikosR's avatar
XhmikosR committed
94
95
96
97
    if (obj === null || obj === undefined) {
      return "" + obj;
    }

XhmikosR's avatar
XhmikosR committed
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
    return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  };
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
      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
139
    element.dispatchEvent(new Event(TRANSITION_END));
XhmikosR's avatar
XhmikosR committed
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
  };

  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 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);
XhmikosR's avatar
XhmikosR committed
197
  };
XhmikosR's avatar
XhmikosR committed
198
199
200
201
202

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

XhmikosR's avatar
XhmikosR committed
203
204
205
206
207
208
209
210
211
212
213
  var getjQuery = function getjQuery() {
    var _window = window,
        jQuery = _window.jQuery;

    if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
      return jQuery;
    }

    return null;
  };

XhmikosR's avatar
XhmikosR committed
214
215
  /**
   * --------------------------------------------------------------------------
216
   * Bootstrap (v5.0.0-alpha1): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
217
218
219
220
221
   * 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
222
223
224
225
226
227
  /**
   * 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
   */

XhmikosR's avatar
XhmikosR committed
228
  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
XhmikosR's avatar
XhmikosR committed
229
230
231
232
233
234
  /**
   * 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
   */

XhmikosR's avatar
XhmikosR committed
235
  var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
XhmikosR's avatar
XhmikosR committed
236
237
238
239
240
241

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

    if (allowedAttributeList.indexOf(attrName) !== -1) {
      if (uriAttrs.indexOf(attrName) !== -1) {
XhmikosR's avatar
XhmikosR committed
242
        return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue);
XhmikosR's avatar
XhmikosR committed
243
244
245
246
247
248
249
250
251
      }

      return true;
    }

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

XhmikosR's avatar
XhmikosR committed
252
253
    for (var i = 0, len = regExp.length; i < len; i++) {
      if (regExp[i].test(attrName)) {
XhmikosR's avatar
XhmikosR committed
254
255
256
257
258
259
260
        return true;
      }
    }

    return false;
  };

XhmikosR's avatar
XhmikosR committed
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
  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: [],
XhmikosR's avatar
XhmikosR committed
280
    img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
XhmikosR's avatar
XhmikosR committed
281
282
283
284
285
286
287
288
289
290
291
292
293
294
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  };
  function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
295
296
    var _ref;

XhmikosR's avatar
XhmikosR committed
297
    if (!unsafeHtml.length) {
XhmikosR's avatar
XhmikosR committed
298
299
300
301
302
303
304
305
306
307
      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
308
309

    var elements = (_ref = []).concat.apply(_ref, createdDocument.body.querySelectorAll('*'));
XhmikosR's avatar
XhmikosR committed
310
311

    var _loop = function _loop(i, len) {
XhmikosR's avatar
XhmikosR committed
312
313
      var _ref2;

XhmikosR's avatar
XhmikosR committed
314
315
316
      var el = elements[i];
      var elName = el.nodeName.toLowerCase();

XhmikosR's avatar
XhmikosR committed
317
      if (whitelistKeys.indexOf(elName) === -1) {
XhmikosR's avatar
XhmikosR committed
318
319
320
321
        el.parentNode.removeChild(el);
        return "continue";
      }

XhmikosR's avatar
XhmikosR committed
322
323
      var attributeList = (_ref2 = []).concat.apply(_ref2, el.attributes);

XhmikosR's avatar
XhmikosR committed
324
325
326
327
328
329
330
331
332
      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++) {
333
      var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
334
335
336
337
338
339
340

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

    return createdDocument.body.innerHTML;
  }

XhmikosR's avatar
Dist    
XhmikosR committed
341
342
343
344
345
346
347
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tooltip';
348
  var VERSION = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
349
350
351
352
  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
353
  var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
XhmikosR's avatar
Dist    
XhmikosR committed
354
355
356
357
358
359
360
361
362
  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
363
    offset: '(number|string|function)',
XhmikosR's avatar
Dist    
XhmikosR committed
364
365
    container: '(string|element|boolean)',
    fallbackPlacement: '(string|array)',
XhmikosR's avatar
XhmikosR committed
366
367
368
    boundary: '(string|element)',
    sanitize: 'boolean',
    sanitizeFn: '(null|function)',
XhmikosR's avatar
XhmikosR committed
369
370
    whiteList: 'object',
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
371
372
373
374
375
376
377
378
379
380
  };
  var AttachmentMap = {
    AUTO: 'auto',
    TOP: 'top',
    RIGHT: 'right',
    BOTTOM: 'bottom',
    LEFT: 'left'
  };
  var Default = {
    animation: true,
XhmikosR's avatar
XhmikosR committed
381
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
XhmikosR's avatar
Dist    
XhmikosR committed
382
383
384
385
386
387
388
389
390
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: 0,
    container: false,
    fallbackPlacement: 'flip',
XhmikosR's avatar
XhmikosR committed
391
392
393
    boundary: 'scrollParent',
    sanitize: true,
    sanitizeFn: null,
XhmikosR's avatar
XhmikosR committed
394
395
    whiteList: DefaultWhitelist,
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
396
  };
XhmikosR's avatar
XhmikosR committed
397
  var Event$1 = {
XhmikosR's avatar
Dist    
XhmikosR committed
398
399
400
401
402
403
404
405
406
407
408
    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
  };
XhmikosR's avatar
XhmikosR committed
409
410
411
412
413
414
415
416
417
418
  var CLASS_NAME_FADE = 'fade';
  var CLASS_NAME_MODAL = 'modal';
  var CLASS_NAME_SHOW = 'show';
  var HOVER_STATE_SHOW = 'show';
  var HOVER_STATE_OUT = 'out';
  var SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  var TRIGGER_HOVER = 'hover';
  var TRIGGER_FOCUS = 'focus';
  var TRIGGER_CLICK = 'click';
  var TRIGGER_MANUAL = 'manual';
XhmikosR's avatar
XhmikosR committed
419
420
421
422
423
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
424

XhmikosR's avatar
XhmikosR committed
425
  var Tooltip = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
426
427
    function Tooltip(element, config) {
      if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
428
        throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)');
XhmikosR's avatar
Dist    
XhmikosR committed
429
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
430
431


XhmikosR's avatar
Dist    
XhmikosR committed
432
433
434
435
436
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
437

XhmikosR's avatar
Dist    
XhmikosR committed
438
439
440
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
441

XhmikosR's avatar
Dist    
XhmikosR committed
442
      this._setListeners();
XhmikosR's avatar
XhmikosR committed
443
444

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

Jacob Thornton's avatar
Jacob Thornton committed
447

XhmikosR's avatar
Dist    
XhmikosR committed
448
    var _proto = Tooltip.prototype;
449

XhmikosR's avatar
Dist    
XhmikosR committed
450
451
452
453
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
454

XhmikosR's avatar
Dist    
XhmikosR committed
455
456
457
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
458

XhmikosR's avatar
Dist    
XhmikosR committed
459
460
461
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Mark Otto's avatar
dist    
Mark Otto committed
462

XhmikosR's avatar
Dist    
XhmikosR committed
463
464
465
466
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Mark Otto's avatar
Mark Otto committed
467

XhmikosR's avatar
Dist    
XhmikosR committed
468
469
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
470
        var context = Data.getData(event.target, dataKey);
Mark Otto's avatar
Mark Otto committed
471

XhmikosR's avatar
Dist    
XhmikosR committed
472
        if (!context) {
XhmikosR's avatar
XhmikosR committed
473
474
          context = new this.constructor(event.target, this._getDelegateConfig());
          Data.setData(event.target, dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
475
        }
fat's avatar
fat committed
476

XhmikosR's avatar
Dist    
XhmikosR committed
477
        context._activeTrigger.click = !context._activeTrigger.click;
fat's avatar
fat committed
478

XhmikosR's avatar
Dist    
XhmikosR committed
479
480
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
Mark Otto's avatar
grunt    
Mark Otto committed
481
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
482
483
484
          context._leave(null, context);
        }
      } else {
XhmikosR's avatar
XhmikosR committed
485
        if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
486
          this._leave(null, this);
487

XhmikosR's avatar
Dist    
XhmikosR committed
488
          return;
Mark Otto's avatar
dist    
Mark Otto committed
489
        }
490

XhmikosR's avatar
Dist    
XhmikosR committed
491
492
493
494
495
496
        this._enter(null, this);
      }
    };

    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
XhmikosR's avatar
XhmikosR committed
497
498
      Data.removeData(this.element, this.constructor.DATA_KEY);
      EventHandler.off(this.element, this.constructor.EVENT_KEY);
XhmikosR's avatar
XhmikosR committed
499
      EventHandler.off(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
500

XhmikosR's avatar
Dist    
XhmikosR committed
501
      if (this.tip) {
XhmikosR's avatar
XhmikosR committed
502
        this.tip.parentNode.removeChild(this.tip);
XhmikosR's avatar
Dist    
XhmikosR committed
503
      }
504

XhmikosR's avatar
Dist    
XhmikosR committed
505
506
507
508
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
509

XhmikosR's avatar
XhmikosR committed
510
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
511
512
        this._popper.destroy();
      }
513

XhmikosR's avatar
Dist    
XhmikosR committed
514
515
516
517
518
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
519

XhmikosR's avatar
Dist    
XhmikosR committed
520
521
    _proto.show = function show() {
      var _this = this;
522

XhmikosR's avatar
XhmikosR committed
523
      if (this.element.style.display === 'none') {
XhmikosR's avatar
Dist    
XhmikosR committed
524
525
        throw new Error('Please use show on visible elements');
      }
526

XhmikosR's avatar
Dist    
XhmikosR committed
527
      if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
528
529
        var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
        var shadowRoot = findShadowRoot(this.element);
XhmikosR's avatar
Dist.    
XhmikosR committed
530
        var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
531

XhmikosR's avatar
XhmikosR committed
532
        if (showEvent.defaultPrevented || !isInTheDom) {
XhmikosR's avatar
Dist    
XhmikosR committed
533
534
          return;
        }
535

XhmikosR's avatar
Dist    
XhmikosR committed
536
        var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
537
        var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist    
XhmikosR committed
538
539
540
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
541

XhmikosR's avatar
Dist    
XhmikosR committed
542
        if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
543
          tip.classList.add(CLASS_NAME_FADE);
XhmikosR's avatar
Dist    
XhmikosR committed
544
        }
545

XhmikosR's avatar
Dist    
XhmikosR committed
546
        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
547

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

550
        this._addAttachmentClass(attachment);
Mark Otto's avatar
dist    
Mark Otto committed
551
552
553

        var container = this._getContainer();

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

XhmikosR's avatar
XhmikosR committed
556
557
        if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
          container.appendChild(tip);
XhmikosR's avatar
Dist    
XhmikosR committed
558
        }
Mark Otto's avatar
grunt    
Mark Otto committed
559

XhmikosR's avatar
XhmikosR committed
560
        EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
XhmikosR's avatar
XhmikosR committed
561
        this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
XhmikosR committed
562
        tip.classList.add(CLASS_NAME_SHOW); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist    
XhmikosR committed
563
564
565
        // 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
566

XhmikosR's avatar
Dist    
XhmikosR committed
567
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
568
569
570
          var _ref;

          (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
571
572
            EventHandler.on(element, 'mouseover', noop());
          });
XhmikosR's avatar
Dist    
XhmikosR committed
573
        }
Mark Otto's avatar
build    
Mark Otto committed
574

XhmikosR's avatar
Dist    
XhmikosR committed
575
576
577
578
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
579

XhmikosR's avatar
Dist    
XhmikosR committed
580
581
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
XhmikosR's avatar
XhmikosR committed
582
          EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
583

XhmikosR's avatar
XhmikosR committed
584
          if (prevHoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
Dist    
XhmikosR committed
585
            _this._leave(null, _this);
586
          }
XhmikosR's avatar
Dist    
XhmikosR committed
587
588
        };

XhmikosR's avatar
XhmikosR committed
589
        if (this.tip.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
XhmikosR committed
590
591
592
          var transitionDuration = getTransitionDurationFromElement(this.tip);
          EventHandler.one(this.tip, TRANSITION_END, complete);
          emulateTransitionEnd(this.tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
593
594
        } else {
          complete();
595
        }
XhmikosR's avatar
Dist    
XhmikosR committed
596
597
      }
    };
598

599
    _proto.hide = function hide() {
XhmikosR's avatar
Dist    
XhmikosR committed
600
      var _this2 = this;
601

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

XhmikosR's avatar
Dist    
XhmikosR committed
604
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
605
        if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
XhmikosR's avatar
Dist    
XhmikosR committed
606
607
          tip.parentNode.removeChild(tip);
        }
608

XhmikosR's avatar
Dist    
XhmikosR committed
609
        _this2._cleanTipClass();
Mark Otto's avatar
grunt    
Mark Otto committed
610

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

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

615
        _this2._popper.destroy();
XhmikosR's avatar
Dist    
XhmikosR committed
616
      };
Mark Otto's avatar
grunt    
Mark Otto committed
617

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

XhmikosR's avatar
XhmikosR committed
620
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
621
622
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
623

XhmikosR's avatar
XhmikosR committed
624
      tip.classList.remove(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra
XhmikosR's avatar
Dist    
XhmikosR committed
625
      // empty mouseover listeners we added for iOS support
Mark Otto's avatar
dist    
Mark Otto committed
626

XhmikosR's avatar
Dist    
XhmikosR committed
627
      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
628
629
630
        var _ref2;

        (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
631
632
          return EventHandler.off(element, 'mouseover', noop);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
633
      }
Mark Otto's avatar
dist    
Mark Otto committed
634

XhmikosR's avatar
XhmikosR committed
635
636
637
      this._activeTrigger[TRIGGER_CLICK] = false;
      this._activeTrigger[TRIGGER_FOCUS] = false;
      this._activeTrigger[TRIGGER_HOVER] = false;
Mark Otto's avatar
dist    
Mark Otto committed
638

XhmikosR's avatar
XhmikosR committed
639
      if (this.tip.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
XhmikosR committed
640
641
642
        var transitionDuration = getTransitionDurationFromElement(tip);
        EventHandler.one(tip, TRANSITION_END, complete);
        emulateTransitionEnd(tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
643
644
645
      } else {
        complete();
      }
Mark Otto's avatar
dist    
Mark Otto committed
646

XhmikosR's avatar
Dist    
XhmikosR committed
647
648
      this._hoverState = '';
    };
Mark Otto's avatar
dist    
Mark Otto committed
649

XhmikosR's avatar
Dist    
XhmikosR committed
650
651
652
653
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
654
655
    } // Protected
    ;
Mark Otto's avatar
dist    
Mark Otto committed
656

XhmikosR's avatar
Dist    
XhmikosR committed
657
658
659
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Mark Otto's avatar
dist    
Mark Otto committed
660

XhmikosR's avatar
Dist    
XhmikosR committed
661
    _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
XhmikosR committed
662
663
664
665
666
667
668
      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
669
670
      return this.tip;
    };
Mark Otto's avatar
dist    
Mark Otto committed
671

XhmikosR's avatar
Dist    
XhmikosR committed
672
673
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
674
      this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
XhmikosR's avatar
XhmikosR committed
675
      tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
XhmikosR's avatar
Dist    
XhmikosR committed
676
    };
Mark Otto's avatar
dist    
Mark Otto committed
677

XhmikosR's avatar
XhmikosR committed
678
679
680
681
682
    _proto.setElementContent = function setElementContent(element, content) {
      if (element === null) {
        return;
      }

683
      if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
XhmikosR committed
684
685
686
687
688
        if (content.jquery) {
          content = content[0];
        } // content is a DOM node or a jQuery


XhmikosR's avatar
XhmikosR committed
689
        if (this.config.html) {
XhmikosR's avatar
XhmikosR committed
690
691
692
          if (content.parentNode !== element) {
            element.innerHTML = '';
            element.appendChild(content);
XhmikosR's avatar
XhmikosR committed
693
694
          }
        } else {
XhmikosR's avatar
XhmikosR committed
695
          element.textContent = content.textContent;
XhmikosR's avatar
XhmikosR committed
696
        }
XhmikosR's avatar
XhmikosR committed
697
698
699
700
701
702
703
704
705

        return;
      }

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

XhmikosR's avatar
XhmikosR committed
706
        element.innerHTML = content;
XhmikosR's avatar
Dist    
XhmikosR committed
707
      } else {
XhmikosR's avatar
XhmikosR committed
708
        element.textContent = content;
XhmikosR's avatar
Dist    
XhmikosR committed
709
710
      }
    };
711

XhmikosR's avatar
Dist    
XhmikosR committed
712
713
    _proto.getTitle = function getTitle() {
      var title = this.element.getAttribute('data-original-title');
714

XhmikosR's avatar
Dist    
XhmikosR committed
715
716
717
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
718

XhmikosR's avatar
Dist    
XhmikosR committed
719
      return title;
Mark Otto's avatar
Mark Otto committed
720
721
    } // Private
    ;
Mark Otto's avatar
grunt    
Mark Otto committed
722

XhmikosR's avatar
XhmikosR committed
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
    _proto._getPopperConfig = function _getPopperConfig(attachment) {
      var _this3 = this;

      var defaultBsConfig = {
        placement: attachment,
        modifiers: {
          offset: this._getOffset(),
          flip: {
            behavior: this.config.fallbackPlacement
          },
          arrow: {
            element: "." + this.constructor.NAME + "-arrow"
          },
          preventOverflow: {
            boundariesElement: this.config.boundary
          }
        },
        onCreate: function onCreate(data) {
          if (data.originalPlacement !== data.placement) {
            _this3._handlePopperPlacementChange(data);
          }
        },
        onUpdate: function onUpdate(data) {
          return _this3._handlePopperPlacementChange(data);
        }
      };
XhmikosR's avatar
XhmikosR committed
749
      return _objectSpread2(_objectSpread2({}, defaultBsConfig), this.config.popperConfig);
XhmikosR's avatar
XhmikosR committed
750
751
    };

752
753
754
755
    _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
      this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
    };

Mark Otto's avatar
Mark Otto committed
756
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
757
      var _this4 = this;
Mark Otto's avatar
Mark Otto committed
758
759
760
761
762

      var offset = {};

      if (typeof this.config.offset === 'function') {
        offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
763
          data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this4.config.offset(data.offsets, _this4.element) || {});
Mark Otto's avatar
Mark Otto committed
764
765
766
767
768
769
770
771
772
          return data;
        };
      } else {
        offset.offset = this.config.offset;
      }

      return offset;
    };

Mark Otto's avatar
dist    
Mark Otto committed
773
774
775
776
777
    _proto._getContainer = function _getContainer() {
      if (this.config.container === false) {
        return document.body;
      }

XhmikosR's avatar
XhmikosR committed
778
779
      if (isElement(this.config.container)) {
        return this.config.container;
Mark Otto's avatar
dist    
Mark Otto committed
780
781
      }

XhmikosR's avatar
XhmikosR committed
782
      return SelectorEngine.findOne(this.config.container);
Mark Otto's avatar
dist    
Mark Otto committed
783
784
    };

XhmikosR's avatar
Dist    
XhmikosR committed
785
786
787
    _proto._getAttachment = function _getAttachment(placement) {
      return AttachmentMap[placement.toUpperCase()];
    };
Mark Otto's avatar
dist    
Mark Otto committed
788

XhmikosR's avatar
Dist    
XhmikosR committed
789
    _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
790
      var _this5 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
791

XhmikosR's avatar
Dist    
XhmikosR committed
792
793
794
      var triggers = this.config.trigger.split(' ');
      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
795
796
          EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
            return _this5.toggle(event);
Mark Otto's avatar
dist    
Mark Otto committed
797
          });
XhmikosR's avatar
XhmikosR committed
798
799
800
        } else if (trigger !== TRIGGER_MANUAL) {
          var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
          var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
XhmikosR's avatar
XhmikosR committed
801
802
          EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) {
            return _this5._enter(event);
XhmikosR's avatar
XhmikosR committed
803
          });
XhmikosR's avatar
XhmikosR committed
804
805
          EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) {
            return _this5._leave(event);
Mark Otto's avatar
dist    
Mark Otto committed
806
807
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
808
      });
Mark Otto's avatar
dist v5    
Mark Otto committed
809
810

      this._hideModalHandler = function () {
XhmikosR's avatar
XhmikosR committed
811
812
        if (_this5.element) {
          _this5.hide();
XhmikosR's avatar
Dist    
XhmikosR committed
813
        }
Mark Otto's avatar
dist v5    
Mark Otto committed
814
815
      };

XhmikosR's avatar
XhmikosR committed
816
      EventHandler.on(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
Mark Otto's avatar
dist    
Mark Otto committed
817

XhmikosR's avatar
Dist    
XhmikosR committed
818
      if (this.config.selector) {
XhmikosR's avatar
XhmikosR committed
819
        this.config = _objectSpread2(_objectSpread2({}, this.config), {}, {
XhmikosR's avatar
Dist    
XhmikosR committed
820
821
822
823
824
825
826
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
      }
    };
827

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

XhmikosR's avatar
Dist    
XhmikosR committed
831
832
833
834
835
      if (this.element.getAttribute('title') || titleType !== 'string') {
        this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
        this.element.setAttribute('title', '');
      }
    };
836

XhmikosR's avatar
Dist    
XhmikosR committed
837
838
    _proto._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
839
      context = context || Data.getData(event.target, dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
840

XhmikosR's avatar
Dist    
XhmikosR committed
841
      if (!context) {
XhmikosR's avatar
XhmikosR committed
842
843
        context = new this.constructor(event.target, this._getDelegateConfig());
        Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
844
      }
Mark Otto's avatar
grunt    
Mark Otto committed
845

XhmikosR's avatar
Dist    
XhmikosR committed
846
      if (event) {
XhmikosR's avatar
XhmikosR committed
847
        context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
XhmikosR's avatar
Dist    
XhmikosR committed
848
      }
849

XhmikosR's avatar
XhmikosR committed
850
851
      if (context.getTipElement().classList.contains(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) {
        context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
852
853
854
855
        return;
      }

      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
856
      context._hoverState = HOVER_STATE_SHOW;
Mark Otto's avatar
grunt    
Mark Otto committed
857

XhmikosR's avatar
Dist    
XhmikosR committed
858
859
860
861
862
863
      if (!context.config.delay || !context.config.delay.show) {
        context.show();
        return;
      }

      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
864
        if (context._hoverState === HOVER_STATE_SHOW) {
865
866
          context.show();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
867
868
      }, context.config.delay.show);
    };
869

XhmikosR's avatar
Dist    
XhmikosR committed
870
871
    _proto._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
872
      context = context || Data.getData(event.target, dataKey);
Mark Otto's avatar
dist    
Mark Otto committed
873

XhmikosR's avatar
Dist    
XhmikosR committed
874
      if (!context) {
XhmikosR's avatar
XhmikosR committed
875
876
        context = new this.constructor(event.target, this._getDelegateConfig());
        Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
877
      }
Mark Otto's avatar
grunt    
Mark Otto committed
878

XhmikosR's avatar
Dist    
XhmikosR committed
879
      if (event) {
XhmikosR's avatar
XhmikosR committed
880
        context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist    
XhmikosR committed
881
      }
882

XhmikosR's avatar
Dist    
XhmikosR committed
883
884
885
      if (context._isWithActiveTrigger()) {
        return;
      }
886

XhmikosR's avatar
Dist    
XhmikosR committed
887
      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
888
      context._hoverState = HOVER_STATE_OUT;
889

XhmikosR's avatar
Dist    
XhmikosR committed
890
891
892
893
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
894

XhmikosR's avatar
Dist    
XhmikosR committed
895
      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
896
        if (context._hoverState === HOVER_STATE_OUT) {
Mark Otto's avatar
dist    
Mark Otto committed
897
          context.hide();
898
        }
XhmikosR's avatar
Dist    
XhmikosR committed
899
900
      }, context.config.delay.hide);
    };
901

XhmikosR's avatar
Dist    
XhmikosR committed
902
903
904
905
    _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
Mark Otto's avatar
dist    
Mark Otto committed
906
        }
XhmikosR's avatar
Dist    
XhmikosR committed
907
      }
Mark Otto's avatar
grunt    
Mark Otto committed
908

XhmikosR's avatar
Dist    
XhmikosR committed
909
910
      return false;
    };
fat's avatar
fat committed
911

XhmikosR's avatar
Dist    
XhmikosR committed
912
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
913
      var dataAttributes = Manipulator.getDataAttributes(this.element);
XhmikosR's avatar
XhmikosR committed
914
915
916
917
918
      Object.keys(dataAttributes).forEach(function (dataAttr) {
        if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
          delete dataAttributes[dataAttr];
        }
      });
XhmikosR's avatar
XhmikosR committed
919
920
921
922
923

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
926
927
928
929
930
931
      if (typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
          hide: config.delay
        };
      }
Mark Otto's avatar
grunt    
Mark Otto committed
932

XhmikosR's avatar
Dist    
XhmikosR committed
933
934
935
      if (typeof config.title === 'number') {
        config.title = config.title.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
936

XhmikosR's avatar
Dist    
XhmikosR committed
937
938
939
      if (typeof config.content === 'number') {
        config.content = config.content.toString();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
940

XhmikosR's avatar
XhmikosR committed
941
      typeCheckConfig(NAME, config, this.constructor.DefaultType);
XhmikosR's avatar
XhmikosR committed
942
943
944
945
946

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

XhmikosR's avatar
Dist    
XhmikosR committed
947
948
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
949

XhmikosR's avatar
Dist    
XhmikosR committed
950
951
    _proto._getDelegateConfig = function _getDelegateConfig() {
      var config = {};
Mark Otto's avatar
grunt    
Mark Otto committed
952

XhmikosR's avatar
Dist    
XhmikosR committed
953
954
955
956
      if (this.config) {
        for (var key in this.config) {
          if (this.constructor.Default[key] !== this.config[key]) {
            config[key] = this.config[key];
957
958
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
959
      }
Mark Otto's avatar
dist    
Mark Otto committed
960

XhmikosR's avatar
Dist    
XhmikosR committed
961
962
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
963

XhmikosR's avatar
Dist    
XhmikosR committed
964
    _proto._cleanTipClass = function _cleanTipClass() {
XhmikosR's avatar
XhmikosR committed
965
966
      var tip = this.getTipElement();
      var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
Mark Otto's avatar
dist    
Mark Otto committed
967

XhmikosR's avatar
XhmikosR committed
968
      if (tabClass !== null && tabClass.length > 0) {
XhmikosR's avatar
XhmikosR committed
969
970
971
972
973
        tabClass.map(function (token) {
          return token.trim();
        }).forEach(function (tClass) {
          return tip.classList.remove(tClass);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
974
975
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
976

XhmikosR's avatar
Dist    
XhmikosR committed
977
978
979
    _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
      var popperInstance = popperData.instance;
      this.tip = popperInstance.popper;
Mark Otto's avatar
dist    
Mark Otto committed
980

XhmikosR's avatar
Dist    
XhmikosR committed
981
      this._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
982

983
      this._addAttachmentClass(this._getAttachment(popperData.placement));
XhmikosR's avatar
Dist    
XhmikosR committed
984
    };
Mark Otto's avatar
dist    
Mark Otto committed
985

XhmikosR's avatar
Dist    
XhmikosR committed
986
987
988
    _proto._fixTransition = function _fixTransition() {
      var tip = this.getTipElement();
      var initConfigAnimation = this.config.animation;
Mark Otto's avatar
dist    
Mark Otto committed
989

XhmikosR's avatar
Dist    
XhmikosR committed
990
991
992
      if (tip.getAttribute('x-placement') !== null) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
993

XhmikosR's avatar
XhmikosR committed
994
      tip.classList.remove(CLASS_NAME_FADE);
XhmikosR's avatar
Dist    
XhmikosR committed
995
996
997
998
      this.config.animation = false;
      this.hide();
      this.show();
      this.config.animation = initConfigAnimation;
Mark Otto's avatar
Mark Otto committed
999
1000
    } // Static
    ;
For faster browsing, not all history is shown. View entire blame