bootstrap.js 149 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
3001
          Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
XhmikosR's avatar
XhmikosR committed
3002
          element.style.marginRight = Number.parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist    
XhmikosR committed
3003
3004
3005
        }); // Adjust body padding

        var actualPadding = document.body.style.paddingRight;
XhmikosR's avatar
XhmikosR committed
3006
3007
        var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
        Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3008
        document.body.style.paddingRight = Number.parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
XhmikosR's avatar
Dist    
XhmikosR committed
3009
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3010

XhmikosR's avatar
XhmikosR committed
3011
      document.body.classList.add(CLASS_NAME_OPEN);
XhmikosR's avatar
Dist    
XhmikosR committed
3012
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3013

XhmikosR's avatar
Dist    
XhmikosR committed
3014
3015
    _proto._resetScrollbar = function _resetScrollbar() {
      // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3016
      SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3017
3018
3019
3020
3021
3022
3023
        var padding = Manipulator.getDataAttribute(element, 'padding-right');

        if (typeof padding !== 'undefined') {
          Manipulator.removeDataAttribute(element, 'padding-right');
          element.style.paddingRight = padding;
        }
      }); // Restore sticky content and navbar-toggler margin
Jacob Thornton's avatar
Jacob Thornton committed
3024

XhmikosR's avatar
XhmikosR committed
3025
      SelectorEngine.find("" + SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3026
        var margin = Manipulator.getDataAttribute(element, 'margin-right');
Mark Otto's avatar
dist    
Mark Otto committed
3027

XhmikosR's avatar
Dist    
XhmikosR committed
3028
        if (typeof margin !== 'undefined') {
XhmikosR's avatar
XhmikosR committed
3029
3030
          Manipulator.removeDataAttribute(element, 'margin-right');
          element.style.marginRight = margin;
XhmikosR's avatar
Dist    
XhmikosR committed
3031
3032
        }
      }); // Restore body padding
Jacob Thornton's avatar
Jacob Thornton committed
3033

XhmikosR's avatar
XhmikosR committed
3034
3035
      var padding = Manipulator.getDataAttribute(document.body, 'padding-right');

XhmikosR's avatar
Dist.    
XhmikosR committed
3036
3037
3038
      if (typeof padding === 'undefined') {
        document.body.style.paddingRight = '';
      } else {
XhmikosR's avatar
XhmikosR committed
3039
3040
3041
        Manipulator.removeDataAttribute(document.body, 'padding-right');
        document.body.style.paddingRight = padding;
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3042
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3043

XhmikosR's avatar
Dist    
XhmikosR committed
3044
3045
3046
    _proto._getScrollbarWidth = function _getScrollbarWidth() {
      // thx d.walsh
      var scrollDiv = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3047
      scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
XhmikosR's avatar
Dist    
XhmikosR committed
3048
3049
3050
3051
      document.body.appendChild(scrollDiv);
      var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
      document.body.removeChild(scrollDiv);
      return scrollbarWidth;
Mark Otto's avatar
Mark Otto committed
3052
3053
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
3054

XhmikosR's avatar
XhmikosR committed
3055
    Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist    
XhmikosR committed
3056
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3057
        var data = Data.getData(this, DATA_KEY$5);
Mark Otto's avatar
grunt    
Mark Otto committed
3058

XhmikosR's avatar
XhmikosR committed
3059
        var _config = _extends({}, Default$3, Manipulator.getDataAttributes(this), typeof config === 'object' && config ? config : {});
Jacob Thornton's avatar
Jacob Thornton committed
3060

XhmikosR's avatar
Dist    
XhmikosR committed
3061
3062
3063
3064
3065
3066
3067
        if (!data) {
          data = new Modal(this, _config);
        }

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

XhmikosR's avatar
Dist    
XhmikosR committed
3070
3071
3072
          data[config](relatedTarget);
        } else if (_config.show) {
          data.show(relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
3073
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3074
3075
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
3076

XhmikosR's avatar
XhmikosR committed
3077
    Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
3078
3079
3080
      return Data.getData(element, DATA_KEY$5);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
    _createClass(Modal, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$5;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default$3;
      }
    }]);
Mark Otto's avatar
dist    
Mark Otto committed
3092

XhmikosR's avatar
Dist    
XhmikosR committed
3093
3094
3095
3096
3097
3098
3099
    return Modal;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
3100
3101


XhmikosR's avatar
XhmikosR committed
3102
  EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) {
XhmikosR's avatar
XhmikosR committed
3103
    var _this11 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3104

XhmikosR's avatar
XhmikosR committed
3105
    var target = getElementFromSelector(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3106
3107
3108
3109
3110

    if (this.tagName === 'A' || this.tagName === 'AREA') {
      event.preventDefault();
    }

XhmikosR's avatar
XhmikosR committed
3111
    EventHandler.one(target, EVENT_SHOW$2, function (showEvent) {
XhmikosR's avatar
XhmikosR committed
3112
3113
      if (showEvent.defaultPrevented) {
        // only register focus restorer if modal will actually get shown
XhmikosR's avatar
Dist    
XhmikosR committed
3114
        return;
Jacob Thornton's avatar
Jacob Thornton committed
3115
3116
      }

XhmikosR's avatar
XhmikosR committed
3117
      EventHandler.one(target, EVENT_HIDDEN$2, function () {
XhmikosR's avatar
XhmikosR committed
3118
3119
        if (isVisible(_this11)) {
          _this11.focus();
Jacob Thornton's avatar
Jacob Thornton committed
3120
        }
Mark Otto's avatar
dist    
Mark Otto committed
3121
3122
      });
    });
XhmikosR's avatar
XhmikosR committed
3123
    var data = Data.getData(target, DATA_KEY$5);
Mark Otto's avatar
dist    
Mark Otto committed
3124

XhmikosR's avatar
XhmikosR committed
3125
    if (!data) {
XhmikosR's avatar
XhmikosR committed
3126
      var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this));
3127

XhmikosR's avatar
XhmikosR committed
3128
3129
3130
3131
      data = new Modal(target, config);
    }

    data.show(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3132
3133
3134
3135
3136
  });
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3137
   * add .Modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
3138
   */
Jacob Thornton's avatar
Jacob Thornton committed
3139

XhmikosR's avatar
XhmikosR committed
3140
3141
3142
  onDOMContentLoaded(function () {
    var $ = getjQuery();
    /* istanbul ignore if */
3143

XhmikosR's avatar
XhmikosR committed
3144
3145
3146
3147
    if ($) {
      var JQUERY_NO_CONFLICT = $.fn[NAME$5];
      $.fn[NAME$5] = Modal.jQueryInterface;
      $.fn[NAME$5].Constructor = Modal;
Jacob Thornton's avatar
Jacob Thornton committed
3148

XhmikosR's avatar
XhmikosR committed
3149
3150
3151
3152
3153
3154
      $.fn[NAME$5].noConflict = function () {
        $.fn[NAME$5] = JQUERY_NO_CONFLICT;
        return Modal.jQueryInterface;
      };
    }
  });
Jacob Thornton's avatar
Jacob Thornton committed
3155

XhmikosR's avatar
XhmikosR committed
3156
3157
  /**
   * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3158
   * Bootstrap (v5.0.0-alpha3): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
3159
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
XhmikosR committed
3160
3161
   * --------------------------------------------------------------------------
   */
XhmikosR's avatar
XhmikosR committed
3162
  var uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
XhmikosR's avatar
XhmikosR committed
3163
  var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
XhmikosR committed
3164
3165
3166
3167
3168
3169
  /**
   * 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
3170
  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
XhmikosR's avatar
XhmikosR committed
3171
3172
3173
3174
3175
3176
  /**
   * 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
3177
  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
3178
3179
3180
3181

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

XhmikosR's avatar
XhmikosR committed
3182
3183
    if (allowedAttributeList.includes(attrName)) {
      if (uriAttrs.has(attrName)) {
Mark Otto's avatar
Mark Otto committed
3184
        return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
XhmikosR's avatar
XhmikosR committed
3185
3186
3187
3188
3189
3190
3191
3192
3193
      }

      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
3194
    for (var i = 0, len = regExp.length; i < len; i++) {
Mark Otto's avatar
Mark Otto committed
3195
      if (attrName.match(regExp[i])) {
XhmikosR's avatar
XhmikosR committed
3196
3197
3198
3199
3200
3201
3202
        return true;
      }
    }

    return false;
  };

XhmikosR's avatar
XhmikosR committed
3203
  var DefaultAllowlist = {
XhmikosR's avatar
XhmikosR committed
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
    // 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
3222
    img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
XhmikosR's avatar
XhmikosR committed
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  };
XhmikosR's avatar
XhmikosR committed
3236
  function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
3237
3238
    var _ref;

XhmikosR's avatar
XhmikosR committed
3239
    if (!unsafeHtml.length) {
XhmikosR's avatar
XhmikosR committed
3240
3241
3242
3243
3244
3245
3246
3247
3248
      return unsafeHtml;
    }

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

    var domParser = new window.DOMParser();
    var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
XhmikosR's avatar
XhmikosR committed
3249
    var allowlistKeys = Object.keys(allowList);
XhmikosR's avatar
XhmikosR committed
3250
3251

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

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

XhmikosR's avatar
XhmikosR committed
3256
3257
3258
      var el = elements[i];
      var elName = el.nodeName.toLowerCase();

XhmikosR's avatar
XhmikosR committed
3259
      if (!allowlistKeys.includes(elName)) {
XhmikosR's avatar
XhmikosR committed
3260
3261
3262
3263
        el.parentNode.removeChild(el);
        return "continue";
      }

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

XhmikosR's avatar
XhmikosR committed
3266
      var allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
XhmikosR's avatar
XhmikosR committed
3267
      attributeList.forEach(function (attr) {
XhmikosR's avatar
XhmikosR committed
3268
        if (!allowedAttribute(attr, allowedAttributes)) {
XhmikosR's avatar
XhmikosR committed
3269
3270
3271
3272
3273
3274
          el.removeAttribute(attr.nodeName);
        }
      });
    };

    for (var i = 0, len = elements.length; i < len; i++) {
3275
      var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3276
3277
3278
3279
3280
3281
3282

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

    return createdDocument.body.innerHTML;
  }

XhmikosR's avatar
Dist    
XhmikosR committed
3283
3284
3285
3286
3287
3288
3289
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$6 = 'tooltip';
XhmikosR's avatar
XhmikosR committed
3290
  var VERSION$6 = '5.0.0-alpha3';
XhmikosR's avatar
Dist    
XhmikosR committed
3291
3292
3293
3294
  var DATA_KEY$6 = 'bs.tooltip';
  var EVENT_KEY$6 = "." + DATA_KEY$6;
  var CLASS_PREFIX = 'bs-tooltip';
  var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
XhmikosR's avatar
XhmikosR committed
3295
  var DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
XhmikosR's avatar
Dist    
XhmikosR committed
3296
3297
3298
3299
3300
3301
3302
3303
3304
  var DefaultType$4 = {
    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
3305
    offset: '(number|string|function)',
XhmikosR's avatar
Dist    
XhmikosR committed
3306
3307
    container: '(string|element|boolean)',
    fallbackPlacement: '(string|array)',
XhmikosR's avatar
XhmikosR committed
3308
3309
3310
    boundary: '(string|element)',
    sanitize: 'boolean',
    sanitizeFn: '(null|function)',
XhmikosR's avatar
XhmikosR committed
3311
    allowList: 'object',
XhmikosR's avatar
XhmikosR committed
3312
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
3313
  };
XhmikosR's avatar
XhmikosR committed
3314
  var AttachmentMap = {
XhmikosR's avatar
Dist    
XhmikosR committed
3315
3316
3317
3318
3319
3320
3321
3322
    AUTO: 'auto',
    TOP: 'top',
    RIGHT: 'right',
    BOTTOM: 'bottom',
    LEFT: 'left'
  };
  var Default$4 = {
    animation: true,
XhmikosR's avatar
XhmikosR committed
3323
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
XhmikosR's avatar
Dist    
XhmikosR committed
3324
3325
3326
3327
3328
3329
3330
3331
3332
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: 0,
    container: false,
    fallbackPlacement: 'flip',
XhmikosR's avatar
XhmikosR committed
3333
3334
3335
    boundary: 'scrollParent',
    sanitize: true,
    sanitizeFn: null,
XhmikosR's avatar
XhmikosR committed
3336
    allowList: DefaultAllowlist,
XhmikosR's avatar
XhmikosR committed
3337
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
3338
  };
XhmikosR's avatar
XhmikosR committed
3339
  var Event$1 = {
XhmikosR's avatar
Dist    
XhmikosR committed
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
    HIDE: "hide" + EVENT_KEY$6,
    HIDDEN: "hidden" + EVENT_KEY$6,
    SHOW: "show" + EVENT_KEY$6,
    SHOWN: "shown" + EVENT_KEY$6,
    INSERTED: "inserted" + EVENT_KEY$6,
    CLICK: "click" + EVENT_KEY$6,
    FOCUSIN: "focusin" + EVENT_KEY$6,
    FOCUSOUT: "focusout" + EVENT_KEY$6,
    MOUSEENTER: "mouseenter" + EVENT_KEY$6,
    MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  };
XhmikosR's avatar
XhmikosR committed
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
  var CLASS_NAME_FADE$1 = 'fade';
  var CLASS_NAME_MODAL = 'modal';
  var CLASS_NAME_SHOW$3 = '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
3361
3362
3363
3364
3365
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
3366

XhmikosR's avatar
XhmikosR committed
3367
  var Tooltip = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
3368
    function Tooltip(element, config) {
XhmikosR's avatar
XhmikosR committed
3369
      if (typeof Popper__default['default'] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3370
        throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
XhmikosR's avatar
Dist    
XhmikosR committed
3371
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
3372
3373


XhmikosR's avatar
Dist    
XhmikosR committed
3374
3375
3376
3377
3378
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
Jacob Thornton's avatar
Jacob Thornton committed
3379

XhmikosR's avatar
Dist    
XhmikosR committed
3380
3381
3382
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
Jacob Thornton's avatar
Jacob Thornton committed
3383

XhmikosR's avatar
Dist    
XhmikosR committed
3384
      this._setListeners();
XhmikosR's avatar
XhmikosR committed
3385
3386

      Data.setData(element, this.constructor.DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
3387
    } // Getters
Jacob Thornton's avatar
Jacob Thornton committed
3388
3389


XhmikosR's avatar
Dist    
XhmikosR committed
3390
    var _proto = Tooltip.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
3391

XhmikosR's avatar
Dist    
XhmikosR committed
3392
3393
3394
3395
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3396

XhmikosR's avatar
Dist    
XhmikosR committed
3397
3398
3399
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3400

XhmikosR's avatar
Dist    
XhmikosR committed
3401
3402
3403
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3404

XhmikosR's avatar
Dist    
XhmikosR committed
3405
3406
3407
3408
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3409

XhmikosR's avatar
Dist    
XhmikosR committed
3410
3411
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3412
        var context = Data.getData(event.delegateTarget, dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
3413

XhmikosR's avatar
Dist    
XhmikosR committed
3414
        if (!context) {
XhmikosR's avatar
XhmikosR committed
3415
3416
          context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
          Data.setData(event.delegateTarget, dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
3417
        }
Jacob Thornton's avatar
Jacob Thornton committed
3418

XhmikosR's avatar
Dist    
XhmikosR committed
3419
        context._activeTrigger.click = !context._activeTrigger.click;
Jacob Thornton's avatar
Jacob Thornton committed
3420

XhmikosR's avatar
Dist    
XhmikosR committed
3421
3422
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
Mark Otto's avatar
dist    
Mark Otto committed
3423
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
3424
3425
3426
          context._leave(null, context);
        }
      } else {
XhmikosR's avatar
XhmikosR committed
3427
        if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) {
XhmikosR's avatar
Dist    
XhmikosR committed
3428
          this._leave(null, this);
Jacob Thornton's avatar
Jacob Thornton committed
3429

XhmikosR's avatar
Dist    
XhmikosR committed
3430
          return;
Mark Otto's avatar
dist    
Mark Otto committed
3431
        }
Jacob Thornton's avatar
Jacob Thornton committed
3432

XhmikosR's avatar
Dist    
XhmikosR committed
3433
3434
3435
        this._enter(null, this);
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3436

XhmikosR's avatar
Dist    
XhmikosR committed
3437
3438
    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
XhmikosR's avatar
XhmikosR committed
3439
3440
      Data.removeData(this.element, this.constructor.DATA_KEY);
      EventHandler.off(this.element, this.constructor.EVENT_KEY);
XhmikosR's avatar
XhmikosR committed
3441
      EventHandler.off(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
Jacob Thornton's avatar
Jacob Thornton committed
3442

XhmikosR's avatar
Dist    
XhmikosR committed
3443
      if (this.tip) {
XhmikosR's avatar
XhmikosR committed
3444
        this.tip.parentNode.removeChild(this.tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3445
      }
Mark Otto's avatar
dist    
Mark Otto committed
3446

XhmikosR's avatar
Dist    
XhmikosR committed
3447
3448
3449
3450
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
Mark Otto's avatar
grunt    
Mark Otto committed
3451

XhmikosR's avatar
XhmikosR committed
3452
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
3453
3454
        this._popper.destroy();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3455

XhmikosR's avatar
Dist    
XhmikosR committed
3456
3457
3458
3459
3460
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3461

XhmikosR's avatar
Dist    
XhmikosR committed
3462
3463
    _proto.show = function show() {
      var _this = this;
Jacob Thornton's avatar
Jacob Thornton committed
3464

XhmikosR's avatar
XhmikosR committed
3465
      if (this.element.style.display === 'none') {
XhmikosR's avatar
Dist    
XhmikosR committed
3466
3467
        throw new Error('Please use show on visible elements');
      }
Mark Otto's avatar
dist    
Mark Otto committed
3468

XhmikosR's avatar
Dist    
XhmikosR committed
3469
      if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
3470
3471
        var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
        var shadowRoot = findShadowRoot(this.element);
XhmikosR's avatar
Dist.    
XhmikosR committed
3472
        var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
Jacob Thornton's avatar
Jacob Thornton committed
3473

XhmikosR's avatar
XhmikosR committed
3474
        if (showEvent.defaultPrevented || !isInTheDom) {
XhmikosR's avatar
Dist    
XhmikosR committed
3475
3476
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
3477

XhmikosR's avatar
Dist    
XhmikosR committed
3478
        var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3479
        var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist    
XhmikosR committed
3480
3481
3482
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
Jacob Thornton's avatar
Jacob Thornton committed
3483

XhmikosR's avatar
Dist    
XhmikosR committed
3484
        if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
3485
          tip.classList.add(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
3486
        }
Jacob Thornton's avatar
Jacob Thornton committed
3487

XhmikosR's avatar
Dist    
XhmikosR committed
3488
        var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
Jacob Thornton's avatar
Jacob Thornton committed
3489

XhmikosR's avatar
Dist    
XhmikosR committed
3490
        var attachment = this._getAttachment(placement);
Mark Otto's avatar
dist    
Mark Otto committed
3491

3492
        this._addAttachmentClass(attachment);
Mark Otto's avatar
dist    
Mark Otto committed
3493
3494
3495

        var container = this._getContainer();

XhmikosR's avatar
XhmikosR committed
3496
        Data.setData(tip, this.constructor.DATA_KEY, this);
Mark Otto's avatar
grunt    
Mark Otto committed
3497

XhmikosR's avatar
XhmikosR committed
3498
3499
        if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
          container.appendChild(tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3500
3501
        }

XhmikosR's avatar
XhmikosR committed
3502
        EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
XhmikosR's avatar
XhmikosR committed
3503
        this._popper = new Popper__default['default'](this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
XhmikosR committed
3504
        tip.classList.add(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist    
XhmikosR committed
3505
3506
3507
        // 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
dist    
Mark Otto committed
3508

XhmikosR's avatar
Dist    
XhmikosR committed
3509
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3510
3511
3512
          var _ref;

          (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3513
3514
            EventHandler.on(element, 'mouseover', noop());
          });
XhmikosR's avatar
Dist    
XhmikosR committed
3515
        }
Mark Otto's avatar
grunt    
Mark Otto committed
3516

XhmikosR's avatar
Dist    
XhmikosR committed
3517
3518
3519
3520
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
Mark Otto's avatar
dist    
Mark Otto committed
3521

XhmikosR's avatar
Dist    
XhmikosR committed
3522
3523
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
XhmikosR's avatar
XhmikosR committed
3524
          EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
Jacob Thornton's avatar
Jacob Thornton committed
3525

XhmikosR's avatar
XhmikosR committed
3526
          if (prevHoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
Dist    
XhmikosR committed
3527
            _this._leave(null, _this);
Mark Otto's avatar
dist    
Mark Otto committed
3528
          }
XhmikosR's avatar
Dist    
XhmikosR committed
3529
3530
        };

XhmikosR's avatar
XhmikosR committed
3531
        if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3532
3533
3534
          var transitionDuration = getTransitionDurationFromElement(this.tip);
          EventHandler.one(this.tip, TRANSITION_END, complete);
          emulateTransitionEnd(this.tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3535
3536
        } else {
          complete();
Mark Otto's avatar
dist    
Mark Otto committed
3537
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3538
3539
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3540

3541
    _proto.hide = function hide() {
XhmikosR's avatar
Dist    
XhmikosR committed
3542
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3543

XhmikosR's avatar
XhmikosR committed
3544
3545
3546
3547
      if (!this._popper) {
        return;
      }

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

XhmikosR's avatar
Dist    
XhmikosR committed
3550
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
3551
        if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
XhmikosR's avatar
Dist    
XhmikosR committed
3552
3553
          tip.parentNode.removeChild(tip);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
3554

XhmikosR's avatar
Dist    
XhmikosR committed
3555
        _this2._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
3556

XhmikosR's avatar
Dist    
XhmikosR committed
3557
        _this2.element.removeAttribute('aria-describedby');
Mark Otto's avatar
dist    
Mark Otto committed
3558

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

3561
        _this2._popper.destroy();
XhmikosR's avatar
Dist    
XhmikosR committed
3562
      };
Mark Otto's avatar
grunt    
Mark Otto committed
3563

XhmikosR's avatar
XhmikosR committed
3564
      var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
Mark Otto's avatar
dist    
Mark Otto committed
3565

XhmikosR's avatar
XhmikosR committed
3566
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
3567
3568
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3569

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

XhmikosR's avatar
Dist    
XhmikosR committed
3573
      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3574
3575
3576
        var _ref2;

        (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3577
3578
          return EventHandler.off(element, 'mouseover', noop);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
3579
      }
Jacob Thornton's avatar
Jacob Thornton committed
3580

XhmikosR's avatar
XhmikosR committed
3581
3582
3583
      this._activeTrigger[TRIGGER_CLICK] = false;
      this._activeTrigger[TRIGGER_FOCUS] = false;
      this._activeTrigger[TRIGGER_HOVER] = false;
Jacob Thornton's avatar
Jacob Thornton committed
3584

XhmikosR's avatar
XhmikosR committed
3585
      if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3586
3587
3588
        var transitionDuration = getTransitionDurationFromElement(tip);
        EventHandler.one(tip, TRANSITION_END, complete);
        emulateTransitionEnd(tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3589
3590
3591
      } else {
        complete();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3592

XhmikosR's avatar
Dist    
XhmikosR committed
3593
3594
      this._hoverState = '';
    };
Jacob Thornton's avatar
Jacob Thornton committed
3595

XhmikosR's avatar
Dist    
XhmikosR committed
3596
3597
3598
3599
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
3600
3601
    } // Protected
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3602

XhmikosR's avatar
Dist    
XhmikosR committed
3603
3604
3605
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Jacob Thornton's avatar
Jacob Thornton committed
3606

XhmikosR's avatar
Dist    
XhmikosR committed
3607
    _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
XhmikosR committed
3608
3609
3610
3611
3612
3613
3614
      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
3615
3616
      return this.tip;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3617

XhmikosR's avatar
Dist    
XhmikosR committed
3618
3619
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3620
      this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
XhmikosR's avatar
XhmikosR committed
3621
      tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3);
XhmikosR's avatar
Dist    
XhmikosR committed
3622
    };
Jacob Thornton's avatar
Jacob Thornton committed
3623

XhmikosR's avatar
XhmikosR committed
3624
3625
3626
3627
3628
    _proto.setElementContent = function setElementContent(element, content) {
      if (element === null) {
        return;
      }

3629
      if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
XhmikosR committed
3630
3631
3632
3633
3634
        if (content.jquery) {
          content = content[0];
        } // content is a DOM node or a jQuery


XhmikosR's avatar
XhmikosR committed
3635
        if (this.config.html) {
XhmikosR's avatar
XhmikosR committed
3636
3637
3638
          if (content.parentNode !== element) {
            element.innerHTML = '';
            element.appendChild(content);
Mark Otto's avatar
dist    
Mark Otto committed
3639
3640
          }
        } else {
XhmikosR's avatar
XhmikosR committed
3641
          element.textContent = content.textContent;
Mark Otto's avatar
dist    
Mark Otto committed
3642
        }
XhmikosR's avatar
XhmikosR committed
3643
3644
3645
3646
3647
3648

        return;
      }

      if (this.config.html) {
        if (this.config.sanitize) {
XhmikosR's avatar
XhmikosR committed
3649
          content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn);
XhmikosR's avatar
XhmikosR committed
3650
3651
        }

XhmikosR's avatar
XhmikosR committed
3652
        element.innerHTML = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3653
      } else {
XhmikosR's avatar
XhmikosR committed
3654
        element.textContent = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3655
3656
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3657

XhmikosR's avatar
Dist    
XhmikosR committed
3658
    _proto.getTitle = function getTitle() {
XhmikosR's avatar
XhmikosR committed
3659
      var title = this.element.getAttribute('data-bs-original-title');
Jacob Thornton's avatar
Jacob Thornton committed
3660

XhmikosR's avatar
Dist    
XhmikosR committed
3661
3662
3663
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3664

XhmikosR's avatar
Dist    
XhmikosR committed
3665
      return title;
Mark Otto's avatar
Mark Otto committed
3666
3667
    } // Private
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3668

XhmikosR's avatar
XhmikosR committed
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
    _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
3695
      return _extends({}, defaultBsConfig, this.config.popperConfig);
XhmikosR's avatar
XhmikosR committed
3696
3697
    };

3698
3699
3700
3701
    _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
      this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
    };

Mark Otto's avatar
Mark Otto committed
3702
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3703
      var _this4 = this;
Mark Otto's avatar
Mark Otto committed
3704
3705
3706
3707
3708

      var offset = {};

      if (typeof this.config.offset === 'function') {
        offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
3709
          data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {});
Mark Otto's avatar
Mark Otto committed
3710
3711
3712
3713
3714
3715
3716
3717
3718
          return data;
        };
      } else {
        offset.offset = this.config.offset;
      }

      return offset;
    };

Mark Otto's avatar
dist    
Mark Otto committed
3719
3720
3721
3722
3723
    _proto._getContainer = function _getContainer() {
      if (this.config.container === false) {
        return document.body;
      }

XhmikosR's avatar
XhmikosR committed
3724
3725
      if (isElement(this.config.container)) {
        return this.config.container;
Mark Otto's avatar
dist    
Mark Otto committed
3726
3727
      }

XhmikosR's avatar
XhmikosR committed
3728
      return SelectorEngine.findOne(this.config.container);
Mark Otto's avatar
dist    
Mark Otto committed
3729
3730
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3731
    _proto._getAttachment = function _getAttachment(placement) {
XhmikosR's avatar
XhmikosR committed
3732
      return AttachmentMap[placement.toUpperCase()];
XhmikosR's avatar
Dist    
XhmikosR committed
3733
    };
Mark Otto's avatar
dist    
Mark Otto committed
3734

XhmikosR's avatar
Dist    
XhmikosR committed
3735
    _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3736
      var _this5 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3737

XhmikosR's avatar
Dist    
XhmikosR committed
3738
3739
3740
      var triggers = this.config.trigger.split(' ');
      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
3741
3742
          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
3743
          });
XhmikosR's avatar
XhmikosR committed
3744
3745
3746
        } 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
3747
3748
          EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) {
            return _this5._enter(event);
XhmikosR's avatar
XhmikosR committed
3749
          });
XhmikosR's avatar
XhmikosR committed
3750
3751
          EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) {
            return _this5._leave(event);
Mark Otto's avatar
dist    
Mark Otto committed
3752
3753
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3754
      });
Mark Otto's avatar
dist v5    
Mark Otto committed
3755
3756

      this._hideModalHandler = function () {
XhmikosR's avatar
XhmikosR committed
3757
3758
        if (_this5.element) {
          _this5.hide();
XhmikosR's avatar
Dist    
XhmikosR committed
3759
        }
Mark Otto's avatar
dist v5    
Mark Otto committed
3760
3761
      };

XhmikosR's avatar
XhmikosR committed
3762
      EventHandler.on(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
Jacob Thornton's avatar
Jacob Thornton committed
3763

XhmikosR's avatar
Dist    
XhmikosR committed
3764
      if (this.config.selector) {
XhmikosR's avatar
XhmikosR committed
3765
        this.config = _extends({}, this.config, {
XhmikosR's avatar
Dist    
XhmikosR committed
3766
3767
3768
3769
3770
3771
3772
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3773

XhmikosR's avatar
Dist    
XhmikosR committed
3774
    _proto._fixTitle = function _fixTitle() {
XhmikosR's avatar
XhmikosR committed
3775
3776
      var title = this.element.getAttribute('title');
      var originalTitleType = typeof this.element.getAttribute('data-bs-original-title');
Mark Otto's avatar
dist    
Mark Otto committed
3777

XhmikosR's avatar
XhmikosR committed
3778
3779
      if (title || originalTitleType !== 'string') {
        this.element.setAttribute('data-bs-original-title', title || '');
XhmikosR's avatar
Dist    
XhmikosR committed
3780
3781
3782
        this.element.setAttribute('title', '');
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3783

XhmikosR's avatar
Dist    
XhmikosR committed
3784
3785
    _proto._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3786
      context = context || Data.getData(event.delegateTarget, dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
3787

XhmikosR's avatar
Dist    
XhmikosR committed
3788
      if (!context) {
XhmikosR's avatar
XhmikosR committed
3789
3790
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
3791
      }
Jacob Thornton's avatar
Jacob Thornton committed
3792

XhmikosR's avatar
Dist    
XhmikosR committed
3793
      if (event) {
XhmikosR's avatar
XhmikosR committed
3794
        context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
XhmikosR's avatar
Dist    
XhmikosR committed
3795
      }
Jacob Thornton's avatar
Jacob Thornton committed
3796

XhmikosR's avatar
XhmikosR committed
3797
3798
      if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$3) || context._hoverState === HOVER_STATE_SHOW) {
        context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
3799
3800
3801
3802
        return;
      }

      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3803
      context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
3804
3805
3806
3807
3808

      if (!context.config.delay || !context.config.delay.show) {
        context.show();
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3809

XhmikosR's avatar
Dist    
XhmikosR committed
3810
      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3811
        if (context._hoverState === HOVER_STATE_SHOW) {
Mark Otto's avatar
dist    
Mark Otto committed
3812
3813
          context.show();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3814
3815
      }, context.config.delay.show);
    };
Jacob Thornton's avatar
Jacob Thornton committed
3816

XhmikosR's avatar
Dist    
XhmikosR committed
3817
3818
    _proto._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3819
      context = context || Data.getData(event.delegateTarget, dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
3820

XhmikosR's avatar
Dist    
XhmikosR committed
3821
      if (!context) {
XhmikosR's avatar
XhmikosR committed
3822
3823
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
3824
      }
Mark Otto's avatar
dist    
Mark Otto committed
3825

XhmikosR's avatar
Dist    
XhmikosR committed
3826
      if (event) {
XhmikosR's avatar
XhmikosR committed
3827
        context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist    
XhmikosR committed
3828
      }
Jacob Thornton's avatar
Jacob Thornton committed
3829

XhmikosR's avatar
Dist    
XhmikosR committed
3830
3831
3832
      if (context._isWithActiveTrigger()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3833

XhmikosR's avatar
Dist    
XhmikosR committed
3834
      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3835
      context._hoverState = HOVER_STATE_OUT;
Jacob Thornton's avatar
Jacob Thornton committed
3836

XhmikosR's avatar
Dist    
XhmikosR committed
3837
3838
3839
3840
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3841

XhmikosR's avatar
Dist    
XhmikosR committed
3842
      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3843
        if (context._hoverState === HOVER_STATE_OUT) {
Mark Otto's avatar
dist    
Mark Otto committed
3844
3845
          context.hide();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3846
3847
      }, context.config.delay.hide);
    };
Jacob Thornton's avatar
Jacob Thornton committed
3848

XhmikosR's avatar
Dist    
XhmikosR committed
3849
3850
3851
3852
    _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
Mark Otto's avatar
dist    
Mark Otto committed
3853
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3854
      }
Jacob Thornton's avatar
Jacob Thornton committed
3855

XhmikosR's avatar
Dist    
XhmikosR committed
3856
3857
      return false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3858

XhmikosR's avatar
Dist    
XhmikosR committed
3859
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
3860
      var dataAttributes = Manipulator.getDataAttributes(this.element);
XhmikosR's avatar
XhmikosR committed
3861
      Object.keys(dataAttributes).forEach(function (dataAttr) {
XhmikosR's avatar
XhmikosR committed
3862
        if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
XhmikosR's avatar
XhmikosR committed
3863
3864
3865
          delete dataAttributes[dataAttr];
        }
      });
XhmikosR's avatar
XhmikosR committed
3866
3867
3868
3869
3870

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

XhmikosR's avatar
XhmikosR committed
3871
      config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
Jacob Thornton's avatar
Jacob Thornton committed
3872

XhmikosR's avatar
Dist    
XhmikosR committed
3873
3874
3875
3876
3877
3878
      if (typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
          hide: config.delay
        };
      }
Mark Otto's avatar
grunt    
Mark Otto committed
3879

XhmikosR's avatar
Dist    
XhmikosR committed
3880
3881
3882
      if (typeof config.title === 'number') {
        config.title = config.title.toString();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3883

XhmikosR's avatar
Dist    
XhmikosR committed
3884
3885
3886
      if (typeof config.content === 'number') {
        config.content = config.content.toString();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3887

XhmikosR's avatar
XhmikosR committed
3888
      typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
XhmikosR's avatar
XhmikosR committed
3889
3890

      if (config.sanitize) {
XhmikosR's avatar
XhmikosR committed
3891
        config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
XhmikosR's avatar
XhmikosR committed
3892
3893
      }

XhmikosR's avatar
Dist    
XhmikosR committed
3894
3895
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
3896

XhmikosR's avatar
Dist    
XhmikosR committed
3897
3898
    _proto._getDelegateConfig = function _getDelegateConfig() {
      var config = {};
Mark Otto's avatar
dist    
Mark Otto committed
3899

XhmikosR's avatar
Dist    
XhmikosR committed
3900
3901
3902
3903
      if (this.config) {
        for (var key in this.config) {
          if (this.constructor.Default[key] !== this.config[key]) {
            config[key] = this.config[key];
Mark Otto's avatar
dist    
Mark Otto committed
3904
3905
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3906
      }
Mark Otto's avatar
dist    
Mark Otto committed
3907

XhmikosR's avatar
Dist    
XhmikosR committed
3908
3909
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
3910

XhmikosR's avatar
Dist    
XhmikosR committed
3911
    _proto._cleanTipClass = function _cleanTipClass() {
XhmikosR's avatar
XhmikosR committed
3912
3913
      var tip = this.getTipElement();
      var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
Mark Otto's avatar
dist    
Mark Otto committed
3914

XhmikosR's avatar
XhmikosR committed
3915
      if (tabClass !== null && tabClass.length > 0) {
XhmikosR's avatar
XhmikosR committed
3916
3917
3918
3919
3920
        tabClass.map(function (token) {
          return token.trim();
        }).forEach(function (tClass) {
          return tip.classList.remove(tClass);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
3921
3922
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3923

XhmikosR's avatar
Dist    
XhmikosR committed
3924
    _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
XhmikosR's avatar
XhmikosR committed
3925
      this.tip = popperData.instance.popper;
Mark Otto's avatar
dist    
Mark Otto committed
3926

XhmikosR's avatar
Dist    
XhmikosR committed
3927
      this._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
3928

3929
      this._addAttachmentClass(this._getAttachment(popperData.placement));
XhmikosR's avatar
Dist    
XhmikosR committed
3930
    };
Mark Otto's avatar
dist    
Mark Otto committed
3931

XhmikosR's avatar
Dist    
XhmikosR committed
3932
3933
3934
    _proto._fixTransition = function _fixTransition() {
      var tip = this.getTipElement();
      var initConfigAnimation = this.config.animation;
Jacob Thornton's avatar
Jacob Thornton committed
3935

XhmikosR's avatar
Dist    
XhmikosR committed
3936
3937
3938
      if (tip.getAttribute('x-placement') !== null) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3939

XhmikosR's avatar
XhmikosR committed
3940
      tip.classList.remove(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
3941
3942
3943
3944
      this.config.animation = false;
      this.hide();
      this.show();
      this.config.animation = initConfigAnimation;
Mark Otto's avatar
Mark Otto committed
3945
3946
    } // Static
    ;
Mark Otto's avatar
grunt    
Mark Otto committed
3947

XhmikosR's avatar
XhmikosR committed
3948
    Tooltip.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist    
XhmikosR committed
3949
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3950
        var data = Data.getData(this, DATA_KEY$6);
Jacob Thornton's avatar
Jacob Thornton committed
3951

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

XhmikosR's avatar
Dist    
XhmikosR committed
3954
3955
3956
        if (!data && /dispose|hide/.test(config)) {
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
3957

XhmikosR's avatar
Dist    
XhmikosR committed
3958
3959
3960
        if (!data) {
          data = new Tooltip(this, _config);
        }
Mark Otto's avatar
dist    
Mark Otto committed
3961

XhmikosR's avatar
Dist    
XhmikosR committed
3962
3963
3964
        if (typeof config === 'string') {
          if (typeof data[config] === 'undefined') {
            throw new TypeError("No method named \"" + config + "\"");
Mark Otto's avatar
dist    
Mark Otto committed
3965
3966
          }

XhmikosR's avatar
Dist    
XhmikosR committed
3967
          data[config]();
Mark Otto's avatar
dist    
Mark Otto committed
3968
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3969
3970
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
3971

XhmikosR's avatar
XhmikosR committed
3972
    Tooltip.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
3973
3974
3975
      return Data.getData(element, DATA_KEY$6);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
    _createClass(Tooltip, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$6;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default$4;
      }
    }, {
      key: "NAME",
      get: function get() {
        return NAME$6;
      }
    }, {
      key: "DATA_KEY",
      get: function get() {
        return DATA_KEY$6;
      }
    }, {
      key: "Event",
      get: function get() {
XhmikosR's avatar
XhmikosR committed
3999
        return Event$1;
XhmikosR's avatar
Dist    
XhmikosR committed
4000
      }
For faster browsing, not all history is shown. View entire blame