bootstrap.esm.js 141 KB
Newer Older
XhmikosR's avatar
Dist.  
XhmikosR committed
3001
  // ----------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3002
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3003

XhmikosR's avatar
XhmikosR committed
3004
3005
  _proto._adjustDialog = function _adjustDialog() {
    var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
XhmikosR's avatar
Dist.  
XhmikosR committed
3006
3007

    if (!this._isBodyOverflowing && isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3008
      this._element.style.paddingLeft = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3009
3010
3011
    }

    if (this._isBodyOverflowing && !isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3012
      this._element.style.paddingRight = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3013
    }
XhmikosR's avatar
XhmikosR committed
3014
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3015

XhmikosR's avatar
XhmikosR committed
3016
  _proto._resetAdjustments = function _resetAdjustments() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3017
3018
    this._element.style.paddingLeft = '';
    this._element.style.paddingRight = '';
XhmikosR's avatar
XhmikosR committed
3019
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3020

XhmikosR's avatar
XhmikosR committed
3021
3022
  _proto._checkScrollbar = function _checkScrollbar() {
    var rect = document.body.getBoundingClientRect();
XhmikosR's avatar
XhmikosR committed
3023
    this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
XhmikosR's avatar
Dist.  
XhmikosR committed
3024
    this._scrollbarWidth = this._getScrollbarWidth();
XhmikosR's avatar
XhmikosR committed
3025
3026
3027
  };

  _proto._setScrollbar = function _setScrollbar() {
XhmikosR's avatar
XhmikosR committed
3028
    var _this10 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3029
3030
3031
3032
3033

    if (this._isBodyOverflowing) {
      // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
      //   while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
      // Adjust fixed content padding
XhmikosR's avatar
XhmikosR committed
3034
      SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3035
3036
        var actualPadding = element.style.paddingRight;
        var calculatedPadding = window.getComputedStyle(element)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3037
        Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3038
        element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3039
3040
      }); // Adjust sticky content margin

XhmikosR's avatar
XhmikosR committed
3041
      SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3042
3043
        var actualMargin = element.style.marginRight;
        var calculatedMargin = window.getComputedStyle(element)['margin-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3044
        Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
XhmikosR's avatar
XhmikosR committed
3045
        element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3046
3047
      }); // Adjust body padding

XhmikosR's avatar
XhmikosR committed
3048
3049
      var actualPadding = document.body.style.paddingRight;
      var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3050
      Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3051
      document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3052
3053
    }

XhmikosR's avatar
XhmikosR committed
3054
    document.body.classList.add(CLASS_NAME_OPEN);
XhmikosR's avatar
XhmikosR committed
3055
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3056

XhmikosR's avatar
XhmikosR committed
3057
  _proto._resetScrollbar = function _resetScrollbar() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3058
    // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3059
    SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3060
      var padding = Manipulator.getDataAttribute(element, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3061
3062
3063
3064
3065
3066
3067

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

XhmikosR's avatar
XhmikosR committed
3068
    SelectorEngine.find("" + SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3069
      var margin = Manipulator.getDataAttribute(element, 'margin-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3070
3071
3072
3073
3074
3075
3076

      if (typeof margin !== 'undefined') {
        Manipulator.removeDataAttribute(element, 'margin-right');
        element.style.marginRight = margin;
      }
    }); // Restore body padding

XhmikosR's avatar
XhmikosR committed
3077
    var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3078
3079
3080
3081
3082
3083
3084

    if (typeof padding === 'undefined') {
      document.body.style.paddingRight = '';
    } else {
      Manipulator.removeDataAttribute(document.body, 'padding-right');
      document.body.style.paddingRight = padding;
    }
XhmikosR's avatar
XhmikosR committed
3085
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3086

XhmikosR's avatar
XhmikosR committed
3087
  _proto._getScrollbarWidth = function _getScrollbarWidth() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3088
    // thx d.walsh
XhmikosR's avatar
XhmikosR committed
3089
    var scrollDiv = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3090
    scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
XhmikosR's avatar
Dist.  
XhmikosR committed
3091
    document.body.appendChild(scrollDiv);
XhmikosR's avatar
XhmikosR committed
3092
    var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
XhmikosR's avatar
Dist.  
XhmikosR committed
3093
3094
3095
    document.body.removeChild(scrollDiv);
    return scrollbarWidth;
  } // Static
XhmikosR's avatar
XhmikosR committed
3096
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3097

XhmikosR's avatar
XhmikosR committed
3098
  Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3099
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3100
      var data = Data.getData(this, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3101

XhmikosR's avatar
XhmikosR committed
3102
      var _config = _extends({}, Default$3, Manipulator.getDataAttributes(this), typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3103
3104
3105
3106
3107
3108
3109

      if (!data) {
        data = new Modal(this, _config);
      }

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3110
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
3111
3112
3113
3114
3115
3116
3117
        }

        data[config](relatedTarget);
      } else if (_config.show) {
        data.show(relatedTarget);
      }
    });
XhmikosR's avatar
XhmikosR committed
3118
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3119

XhmikosR's avatar
XhmikosR committed
3120
  Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3121
    return Data.getData(element, DATA_KEY$5);
XhmikosR's avatar
XhmikosR committed
3122
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3123

XhmikosR's avatar
XhmikosR committed
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
  _createClass(Modal, null, [{
    key: "VERSION",
    get: function get() {
      return VERSION$5;
    }
  }, {
    key: "Default",
    get: function get() {
      return Default$3;
    }
  }]);

  return Modal;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
3138
3139
3140
3141
3142
3143
3144
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
3145
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) {
XhmikosR's avatar
XhmikosR committed
3146
  var _this11 = this;
XhmikosR's avatar
XhmikosR committed
3147

XhmikosR's avatar
XhmikosR committed
3148
  var target = getElementFromSelector(this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3149
3150
3151
3152
3153

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

XhmikosR's avatar
XhmikosR committed
3154
  EventHandler.one(target, EVENT_SHOW$2, function (showEvent) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3155
3156
3157
3158
3159
    if (showEvent.defaultPrevented) {
      // only register focus restorer if modal will actually get shown
      return;
    }

XhmikosR's avatar
XhmikosR committed
3160
    EventHandler.one(target, EVENT_HIDDEN$2, function () {
XhmikosR's avatar
XhmikosR committed
3161
3162
      if (isVisible(_this11)) {
        _this11.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3163
3164
3165
      }
    });
  });
XhmikosR's avatar
XhmikosR committed
3166
  var data = Data.getData(target, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3167
3168

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

XhmikosR's avatar
Dist.  
XhmikosR committed
3171
3172
3173
3174
3175
    data = new Modal(target, config);
  }

  data.show(this);
});
XhmikosR's avatar
XhmikosR committed
3176
var $$6 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
3177
3178
3179
3180
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
3181
 * add .modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist.  
XhmikosR committed
3182
3183
 */

3184
3185
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
3186
3187
3188
3189
if ($$6) {
  var JQUERY_NO_CONFLICT$5 = $$6.fn[NAME$5];
  $$6.fn[NAME$5] = Modal.jQueryInterface;
  $$6.fn[NAME$5].Constructor = Modal;
XhmikosR's avatar
Dist.  
XhmikosR committed
3190

XhmikosR's avatar
XhmikosR committed
3191
3192
3193
  $$6.fn[NAME$5].noConflict = function () {
    $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
    return Modal.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
3194
3195
3196
3197
3198
  };
}

/**
 * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3199
 * Bootstrap (v5.0.0-alpha2): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
3200
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
Dist.  
XhmikosR committed
3201
3202
 * --------------------------------------------------------------------------
 */
XhmikosR's avatar
XhmikosR committed
3203
3204
var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
Dist.  
XhmikosR committed
3205
3206
3207
3208
3209
3210
/**
 * 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
3211
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
XhmikosR's avatar
Dist.  
XhmikosR committed
3212
3213
3214
3215
3216
3217
/**
 * 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
3218
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
Dist.  
XhmikosR committed
3219

XhmikosR's avatar
XhmikosR committed
3220
3221
var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) {
  var attrName = attr.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3222
3223
3224

  if (allowedAttributeList.indexOf(attrName) !== -1) {
    if (uriAttrs.indexOf(attrName) !== -1) {
Mark Otto's avatar
Mark Otto committed
3225
      return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
XhmikosR's avatar
Dist.  
XhmikosR committed
3226
3227
3228
3229
3230
    }

    return true;
  }

XhmikosR's avatar
XhmikosR committed
3231
3232
3233
  var regExp = allowedAttributeList.filter(function (attrRegex) {
    return attrRegex instanceof RegExp;
  }); // Check if a regular expression validates the attribute.
XhmikosR's avatar
Dist.  
XhmikosR committed
3234

XhmikosR's avatar
XhmikosR committed
3235
  for (var i = 0, len = regExp.length; i < len; i++) {
Mark Otto's avatar
Mark Otto committed
3236
    if (attrName.match(regExp[i])) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3237
3238
3239
3240
3241
3242
3243
      return true;
    }
  }

  return false;
};

XhmikosR's avatar
XhmikosR committed
3244
var DefaultAllowlist = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
  // 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
3263
  img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
XhmikosR's avatar
Dist.  
XhmikosR committed
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
};
XhmikosR's avatar
XhmikosR committed
3277
function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
3278
3279
  var _ref;

XhmikosR's avatar
Dist.  
XhmikosR committed
3280
3281
3282
3283
3284
3285
3286
3287
  if (!unsafeHtml.length) {
    return unsafeHtml;
  }

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

XhmikosR's avatar
XhmikosR committed
3288
3289
  var domParser = new window.DOMParser();
  var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
XhmikosR's avatar
XhmikosR committed
3290
  var allowlistKeys = Object.keys(allowList);
XhmikosR's avatar
XhmikosR committed
3291
3292

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

XhmikosR's avatar
XhmikosR committed
3294
  var _loop = function _loop(i, len) {
XhmikosR's avatar
XhmikosR committed
3295
3296
    var _ref2;

XhmikosR's avatar
XhmikosR committed
3297
3298
    var el = elements[i];
    var elName = el.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3299

XhmikosR's avatar
XhmikosR committed
3300
    if (allowlistKeys.indexOf(elName) === -1) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3301
      el.parentNode.removeChild(el);
XhmikosR's avatar
XhmikosR committed
3302
      return "continue";
XhmikosR's avatar
Dist.  
XhmikosR committed
3303
3304
    }

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

XhmikosR's avatar
XhmikosR committed
3307
    var allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
XhmikosR's avatar
XhmikosR committed
3308
    attributeList.forEach(function (attr) {
XhmikosR's avatar
XhmikosR committed
3309
      if (!allowedAttribute(attr, allowedAttributes)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3310
3311
3312
        el.removeAttribute(attr.nodeName);
      }
    });
XhmikosR's avatar
XhmikosR committed
3313
3314
3315
  };

  for (var i = 0, len = elements.length; i < len; i++) {
3316
    var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3317
3318

    if (_ret === "continue") continue;
XhmikosR's avatar
Dist.  
XhmikosR committed
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
  }

  return createdDocument.body.innerHTML;
}

/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

XhmikosR's avatar
XhmikosR committed
3330
var NAME$6 = 'tooltip';
XhmikosR's avatar
XhmikosR committed
3331
var VERSION$6 = '5.0.0-alpha2';
XhmikosR's avatar
XhmikosR committed
3332
3333
3334
3335
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
3336
var DISALLOWED_ATTRIBUTES = ['sanitize', 'allowList', 'sanitizeFn'];
XhmikosR's avatar
XhmikosR committed
3337
var DefaultType$4 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
  animation: 'boolean',
  template: 'string',
  title: '(string|element|function)',
  trigger: 'string',
  delay: '(number|object)',
  html: 'boolean',
  selector: '(string|boolean)',
  placement: '(string|function)',
  offset: '(number|string|function)',
  container: '(string|element|boolean)',
  fallbackPlacement: '(string|array)',
  boundary: '(string|element)',
  sanitize: 'boolean',
  sanitizeFn: '(null|function)',
XhmikosR's avatar
XhmikosR committed
3352
  allowList: 'object',
XhmikosR's avatar
XhmikosR committed
3353
  popperConfig: '(null|object)'
XhmikosR's avatar
Dist.  
XhmikosR committed
3354
};
XhmikosR's avatar
XhmikosR committed
3355
var AttachmentMap = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3356
3357
3358
3359
3360
3361
  AUTO: 'auto',
  TOP: 'top',
  RIGHT: 'right',
  BOTTOM: 'bottom',
  LEFT: 'left'
};
XhmikosR's avatar
XhmikosR committed
3362
var Default$4 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
  animation: true,
  template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  trigger: 'hover focus',
  title: '',
  delay: 0,
  html: false,
  selector: false,
  placement: 'top',
  offset: 0,
  container: false,
  fallbackPlacement: 'flip',
  boundary: 'scrollParent',
  sanitize: true,
  sanitizeFn: null,
XhmikosR's avatar
XhmikosR committed
3377
  allowList: DefaultAllowlist,
XhmikosR's avatar
XhmikosR committed
3378
  popperConfig: null
XhmikosR's avatar
Dist.  
XhmikosR committed
3379
};
XhmikosR's avatar
XhmikosR committed
3380
var Event$1 = {
XhmikosR's avatar
XhmikosR committed
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
  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
Dist.  
XhmikosR committed
3391
};
XhmikosR's avatar
XhmikosR committed
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
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
3402
3403
3404
3405
3406
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
3407

XhmikosR's avatar
XhmikosR committed
3408
var Tooltip = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
3409
  function Tooltip(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
    if (typeof Popper === 'undefined') {
      throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)');
    } // private


    this._isEnabled = true;
    this._timeout = 0;
    this._hoverState = '';
    this._activeTrigger = {};
    this._popper = null; // Protected

    this.element = element;
    this.config = this._getConfig(config);
    this.tip = null;

    this._setListeners();

    Data.setData(element, this.constructor.DATA_KEY, this);
  } // Getters


XhmikosR's avatar
XhmikosR committed
3431
  var _proto = Tooltip.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
3432

XhmikosR's avatar
XhmikosR committed
3433
3434
  // Public
  _proto.enable = function enable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3435
    this._isEnabled = true;
XhmikosR's avatar
XhmikosR committed
3436
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3437

XhmikosR's avatar
XhmikosR committed
3438
  _proto.disable = function disable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3439
    this._isEnabled = false;
XhmikosR's avatar
XhmikosR committed
3440
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3441

XhmikosR's avatar
XhmikosR committed
3442
  _proto.toggleEnabled = function toggleEnabled() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3443
    this._isEnabled = !this._isEnabled;
XhmikosR's avatar
XhmikosR committed
3444
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3445

XhmikosR's avatar
XhmikosR committed
3446
  _proto.toggle = function toggle(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3447
3448
3449
3450
3451
    if (!this._isEnabled) {
      return;
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3452
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3453
      var context = Data.getData(event.delegateTarget, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3454
3455

      if (!context) {
XhmikosR's avatar
XhmikosR committed
3456
3457
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
      }

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

      if (context._isWithActiveTrigger()) {
        context._enter(null, context);
      } else {
        context._leave(null, context);
      }
    } else {
XhmikosR's avatar
XhmikosR committed
3468
      if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3469
3470
3471
3472
3473
3474
3475
        this._leave(null, this);

        return;
      }

      this._enter(null, this);
    }
XhmikosR's avatar
XhmikosR committed
3476
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3477

XhmikosR's avatar
XhmikosR committed
3478
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3479
3480
3481
    clearTimeout(this._timeout);
    Data.removeData(this.element, this.constructor.DATA_KEY);
    EventHandler.off(this.element, this.constructor.EVENT_KEY);
XhmikosR's avatar
XhmikosR committed
3482
    EventHandler.off(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
XhmikosR's avatar
Dist.  
XhmikosR committed
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492

    if (this.tip) {
      this.tip.parentNode.removeChild(this.tip);
    }

    this._isEnabled = null;
    this._timeout = null;
    this._hoverState = null;
    this._activeTrigger = null;

XhmikosR's avatar
XhmikosR committed
3493
    if (this._popper) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3494
3495
3496
3497
3498
3499
3500
      this._popper.destroy();
    }

    this._popper = null;
    this.element = null;
    this.config = null;
    this.tip = null;
XhmikosR's avatar
XhmikosR committed
3501
3502
3503
3504
  };

  _proto.show = function show() {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3505
3506
3507
3508
3509
3510

    if (this.element.style.display === 'none') {
      throw new Error('Please use show on visible elements');
    }

    if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
3511
3512
3513
      var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
      var shadowRoot = findShadowRoot(this.element);
      var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
XhmikosR's avatar
Dist.  
XhmikosR committed
3514
3515
3516
3517
3518

      if (showEvent.defaultPrevented || !isInTheDom) {
        return;
      }

XhmikosR's avatar
XhmikosR committed
3519
3520
      var tip = this.getTipElement();
      var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist.  
XhmikosR committed
3521
3522
3523
3524
3525
      tip.setAttribute('id', tipId);
      this.element.setAttribute('aria-describedby', tipId);
      this.setContent();

      if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
3526
        tip.classList.add(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
3527
3528
      }

XhmikosR's avatar
XhmikosR committed
3529
      var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
XhmikosR's avatar
Dist.  
XhmikosR committed
3530

XhmikosR's avatar
XhmikosR committed
3531
      var attachment = this._getAttachment(placement);
XhmikosR's avatar
Dist.  
XhmikosR committed
3532

3533
      this._addAttachmentClass(attachment);
XhmikosR's avatar
Dist.  
XhmikosR committed
3534

XhmikosR's avatar
XhmikosR committed
3535
      var container = this._getContainer();
XhmikosR's avatar
Dist.  
XhmikosR committed
3536
3537
3538
3539
3540
3541
3542
3543

      Data.setData(tip, this.constructor.DATA_KEY, this);

      if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
        container.appendChild(tip);
      }

      EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
XhmikosR's avatar
XhmikosR committed
3544
      this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
XhmikosR committed
3545
      tip.classList.add(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist.  
XhmikosR committed
3546
3547
3548
3549
3550
      // empty mouseover listeners to the body's immediate children;
      // only needed because of broken event delegation on iOS
      // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html

      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3551
3552
3553
        var _ref;

        (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3554
3555
3556
3557
          EventHandler.on(element, 'mouseover', noop());
        });
      }

XhmikosR's avatar
XhmikosR committed
3558
3559
3560
      var complete = function complete() {
        if (_this.config.animation) {
          _this._fixTransition();
XhmikosR's avatar
Dist.  
XhmikosR committed
3561
3562
        }

XhmikosR's avatar
XhmikosR committed
3563
3564
3565
        var prevHoverState = _this._hoverState;
        _this._hoverState = null;
        EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
XhmikosR's avatar
Dist.  
XhmikosR committed
3566

XhmikosR's avatar
XhmikosR committed
3567
        if (prevHoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
XhmikosR committed
3568
          _this._leave(null, _this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3569
3570
3571
        }
      };

XhmikosR's avatar
XhmikosR committed
3572
      if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3573
        var transitionDuration = getTransitionDurationFromElement(this.tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3574
3575
3576
3577
3578
3579
        EventHandler.one(this.tip, TRANSITION_END, complete);
        emulateTransitionEnd(this.tip, transitionDuration);
      } else {
        complete();
      }
    }
XhmikosR's avatar
XhmikosR committed
3580
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3581

3582
  _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
3583
    var _this2 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3584

XhmikosR's avatar
XhmikosR committed
3585
3586
3587
3588
    if (!this._popper) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
3589
3590
3591
    var tip = this.getTipElement();

    var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
3592
      if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3593
3594
3595
        tip.parentNode.removeChild(tip);
      }

XhmikosR's avatar
XhmikosR committed
3596
3597
3598
      _this2._cleanTipClass();

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

XhmikosR's avatar
XhmikosR committed
3600
      EventHandler.trigger(_this2.element, _this2.constructor.Event.HIDDEN);
XhmikosR's avatar
Dist.  
XhmikosR committed
3601

3602
      _this2._popper.destroy();
XhmikosR's avatar
Dist.  
XhmikosR committed
3603
3604
    };

XhmikosR's avatar
XhmikosR committed
3605
    var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
XhmikosR's avatar
Dist.  
XhmikosR committed
3606
3607
3608
3609
3610

    if (hideEvent.defaultPrevented) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
3611
    tip.classList.remove(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we remove the extra
XhmikosR's avatar
Dist.  
XhmikosR committed
3612
3613
3614
    // empty mouseover listeners we added for iOS support

    if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3615
3616
3617
      var _ref2;

      (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3618
3619
        return EventHandler.off(element, 'mouseover', noop);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
3620
3621
    }

XhmikosR's avatar
XhmikosR committed
3622
3623
3624
    this._activeTrigger[TRIGGER_CLICK] = false;
    this._activeTrigger[TRIGGER_FOCUS] = false;
    this._activeTrigger[TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3625

XhmikosR's avatar
XhmikosR committed
3626
    if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3627
      var transitionDuration = getTransitionDurationFromElement(tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3628
3629
3630
3631
3632
3633
3634
      EventHandler.one(tip, TRANSITION_END, complete);
      emulateTransitionEnd(tip, transitionDuration);
    } else {
      complete();
    }

    this._hoverState = '';
XhmikosR's avatar
XhmikosR committed
3635
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3636

XhmikosR's avatar
XhmikosR committed
3637
  _proto.update = function update() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3638
3639
3640
3641
    if (this._popper !== null) {
      this._popper.scheduleUpdate();
    }
  } // Protected
XhmikosR's avatar
XhmikosR committed
3642
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3643

XhmikosR's avatar
XhmikosR committed
3644
  _proto.isWithContent = function isWithContent() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3645
    return Boolean(this.getTitle());
XhmikosR's avatar
XhmikosR committed
3646
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3647

XhmikosR's avatar
XhmikosR committed
3648
  _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3649
3650
3651
3652
    if (this.tip) {
      return this.tip;
    }

XhmikosR's avatar
XhmikosR committed
3653
    var element = document.createElement('div');
XhmikosR's avatar
Dist.  
XhmikosR committed
3654
3655
3656
    element.innerHTML = this.config.template;
    this.tip = element.children[0];
    return this.tip;
XhmikosR's avatar
XhmikosR committed
3657
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3658

XhmikosR's avatar
XhmikosR committed
3659
3660
  _proto.setContent = function setContent() {
    var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3661
    this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
XhmikosR's avatar
XhmikosR committed
3662
    tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3);
XhmikosR's avatar
XhmikosR committed
3663
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3664

XhmikosR's avatar
XhmikosR committed
3665
  _proto.setElementContent = function setElementContent(element, content) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3666
3667
3668
3669
    if (element === null) {
      return;
    }

3670
    if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
      if (content.jquery) {
        content = content[0];
      } // content is a DOM node or a jQuery


      if (this.config.html) {
        if (content.parentNode !== element) {
          element.innerHTML = '';
          element.appendChild(content);
        }
      } else {
XhmikosR's avatar
XhmikosR committed
3682
        element.textContent = content.textContent;
XhmikosR's avatar
Dist.  
XhmikosR committed
3683
3684
3685
3686
3687
3688
3689
      }

      return;
    }

    if (this.config.html) {
      if (this.config.sanitize) {
XhmikosR's avatar
XhmikosR committed
3690
        content = sanitizeHtml(content, this.config.allowList, this.config.sanitizeFn);
XhmikosR's avatar
Dist.  
XhmikosR committed
3691
3692
3693
3694
      }

      element.innerHTML = content;
    } else {
XhmikosR's avatar
XhmikosR committed
3695
      element.textContent = content;
XhmikosR's avatar
Dist.  
XhmikosR committed
3696
    }
XhmikosR's avatar
XhmikosR committed
3697
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3698

XhmikosR's avatar
XhmikosR committed
3699
3700
  _proto.getTitle = function getTitle() {
    var title = this.element.getAttribute('data-original-title');
XhmikosR's avatar
Dist.  
XhmikosR committed
3701
3702
3703
3704
3705
3706
3707

    if (!title) {
      title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
    }

    return title;
  } // Private
XhmikosR's avatar
XhmikosR committed
3708
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3709

XhmikosR's avatar
XhmikosR committed
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
  _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
3736
    return _extends({}, defaultBsConfig, this.config.popperConfig);
XhmikosR's avatar
XhmikosR committed
3737
3738
  };

3739
3740
3741
3742
  _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
    this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
  };

XhmikosR's avatar
XhmikosR committed
3743
  _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3744
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3745

XhmikosR's avatar
XhmikosR committed
3746
    var offset = {};
XhmikosR's avatar
Dist.  
XhmikosR committed
3747
3748

    if (typeof this.config.offset === 'function') {
XhmikosR's avatar
XhmikosR committed
3749
      offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
3750
        data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3751
3752
3753
3754
3755
3756
3757
        return data;
      };
    } else {
      offset.offset = this.config.offset;
    }

    return offset;
XhmikosR's avatar
XhmikosR committed
3758
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3759

XhmikosR's avatar
XhmikosR committed
3760
  _proto._getContainer = function _getContainer() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3761
3762
3763
3764
3765
3766
3767
3768
3769
    if (this.config.container === false) {
      return document.body;
    }

    if (isElement(this.config.container)) {
      return this.config.container;
    }

    return SelectorEngine.findOne(this.config.container);
XhmikosR's avatar
XhmikosR committed
3770
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3771

XhmikosR's avatar
XhmikosR committed
3772
  _proto._getAttachment = function _getAttachment(placement) {
XhmikosR's avatar
XhmikosR committed
3773
    return AttachmentMap[placement.toUpperCase()];
XhmikosR's avatar
XhmikosR committed
3774
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3775

XhmikosR's avatar
XhmikosR committed
3776
  _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3777
    var _this5 = this;
XhmikosR's avatar
XhmikosR committed
3778
3779
3780

    var triggers = this.config.trigger.split(' ');
    triggers.forEach(function (trigger) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3781
      if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
3782
3783
        EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
          return _this5.toggle(event);
XhmikosR's avatar
XhmikosR committed
3784
        });
XhmikosR's avatar
XhmikosR committed
3785
3786
3787
      } 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
3788
3789
        EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) {
          return _this5._enter(event);
XhmikosR's avatar
XhmikosR committed
3790
        });
XhmikosR's avatar
XhmikosR committed
3791
3792
        EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) {
          return _this5._leave(event);
XhmikosR's avatar
XhmikosR committed
3793
        });
XhmikosR's avatar
Dist.  
XhmikosR committed
3794
3795
      }
    });
Mark Otto's avatar
dist v5    
Mark Otto committed
3796
3797

    this._hideModalHandler = function () {
XhmikosR's avatar
XhmikosR committed
3798
3799
      if (_this5.element) {
        _this5.hide();
XhmikosR's avatar
Dist.  
XhmikosR committed
3800
      }
Mark Otto's avatar
dist v5    
Mark Otto committed
3801
3802
    };

XhmikosR's avatar
XhmikosR committed
3803
    EventHandler.on(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
XhmikosR's avatar
Dist.  
XhmikosR committed
3804
3805

    if (this.config.selector) {
XhmikosR's avatar
XhmikosR committed
3806
      this.config = _extends({}, this.config, {
XhmikosR's avatar
Dist.  
XhmikosR committed
3807
3808
3809
3810
3811
3812
        trigger: 'manual',
        selector: ''
      });
    } else {
      this._fixTitle();
    }
XhmikosR's avatar
XhmikosR committed
3813
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3814

XhmikosR's avatar
XhmikosR committed
3815
3816
  _proto._fixTitle = function _fixTitle() {
    var titleType = typeof this.element.getAttribute('data-original-title');
XhmikosR's avatar
Dist.  
XhmikosR committed
3817
3818
3819
3820
3821

    if (this.element.getAttribute('title') || titleType !== 'string') {
      this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
      this.element.setAttribute('title', '');
    }
XhmikosR's avatar
XhmikosR committed
3822
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3823

XhmikosR's avatar
XhmikosR committed
3824
3825
  _proto._enter = function _enter(event, context) {
    var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3826
    context = context || Data.getData(event.delegateTarget, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3827
3828

    if (!context) {
XhmikosR's avatar
XhmikosR committed
3829
3830
      context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
      Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3831
3832
3833
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3834
      context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
XhmikosR's avatar
Dist.  
XhmikosR committed
3835
3836
    }

XhmikosR's avatar
XhmikosR committed
3837
3838
    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
3839
3840
3841
3842
      return;
    }

    clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3843
    context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist.  
XhmikosR committed
3844
3845
3846
3847
3848
3849

    if (!context.config.delay || !context.config.delay.show) {
      context.show();
      return;
    }

XhmikosR's avatar
XhmikosR committed
3850
    context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3851
      if (context._hoverState === HOVER_STATE_SHOW) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3852
3853
3854
        context.show();
      }
    }, context.config.delay.show);
XhmikosR's avatar
XhmikosR committed
3855
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3856

XhmikosR's avatar
XhmikosR committed
3857
3858
  _proto._leave = function _leave(event, context) {
    var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3859
    context = context || Data.getData(event.delegateTarget, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3860
3861

    if (!context) {
XhmikosR's avatar
XhmikosR committed
3862
3863
      context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
      Data.setData(event.delegateTarget, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3864
3865
3866
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3867
      context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3868
3869
3870
3871
3872
3873
3874
    }

    if (context._isWithActiveTrigger()) {
      return;
    }

    clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3875
    context._hoverState = HOVER_STATE_OUT;
XhmikosR's avatar
Dist.  
XhmikosR committed
3876
3877
3878
3879
3880
3881

    if (!context.config.delay || !context.config.delay.hide) {
      context.hide();
      return;
    }

XhmikosR's avatar
XhmikosR committed
3882
    context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3883
      if (context._hoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3884
3885
3886
        context.hide();
      }
    }, context.config.delay.hide);
XhmikosR's avatar
XhmikosR committed
3887
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3888

XhmikosR's avatar
XhmikosR committed
3889
3890
  _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
    for (var trigger in this._activeTrigger) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3891
3892
3893
3894
3895
3896
      if (this._activeTrigger[trigger]) {
        return true;
      }
    }

    return false;
XhmikosR's avatar
XhmikosR committed
3897
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3898

XhmikosR's avatar
XhmikosR committed
3899
3900
3901
  _proto._getConfig = function _getConfig(config) {
    var dataAttributes = Manipulator.getDataAttributes(this.element);
    Object.keys(dataAttributes).forEach(function (dataAttr) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3902
3903
3904
3905
3906
3907
3908
3909
3910
      if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
        delete dataAttributes[dataAttr];
      }
    });

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

XhmikosR's avatar
XhmikosR committed
3911
    config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930

    if (typeof config.delay === 'number') {
      config.delay = {
        show: config.delay,
        hide: config.delay
      };
    }

    if (typeof config.title === 'number') {
      config.title = config.title.toString();
    }

    if (typeof config.content === 'number') {
      config.content = config.content.toString();
    }

    typeCheckConfig(NAME$6, config, this.constructor.DefaultType);

    if (config.sanitize) {
XhmikosR's avatar
XhmikosR committed
3931
      config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
XhmikosR's avatar
Dist.  
XhmikosR committed
3932
3933
3934
    }

    return config;
XhmikosR's avatar
XhmikosR committed
3935
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3936

XhmikosR's avatar
XhmikosR committed
3937
3938
  _proto._getDelegateConfig = function _getDelegateConfig() {
    var config = {};
XhmikosR's avatar
Dist.  
XhmikosR committed
3939
3940

    if (this.config) {
XhmikosR's avatar
XhmikosR committed
3941
      for (var key in this.config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3942
3943
3944
3945
3946
3947
3948
        if (this.constructor.Default[key] !== this.config[key]) {
          config[key] = this.config[key];
        }
      }
    }

    return config;
XhmikosR's avatar
XhmikosR committed
3949
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3950

XhmikosR's avatar
XhmikosR committed
3951
3952
3953
  _proto._cleanTipClass = function _cleanTipClass() {
    var tip = this.getTipElement();
    var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
XhmikosR's avatar
Dist.  
XhmikosR committed
3954

XhmikosR's avatar
XhmikosR committed
3955
    if (tabClass !== null && tabClass.length > 0) {
XhmikosR's avatar
XhmikosR committed
3956
3957
3958
3959
3960
      tabClass.map(function (token) {
        return token.trim();
      }).forEach(function (tClass) {
        return tip.classList.remove(tClass);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
3961
    }
XhmikosR's avatar
XhmikosR committed
3962
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3963

XhmikosR's avatar
XhmikosR committed
3964
  _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
XhmikosR's avatar
XhmikosR committed
3965
    this.tip = popperData.instance.popper;
XhmikosR's avatar
Dist.  
XhmikosR committed
3966
3967
3968

    this._cleanTipClass();

3969
    this._addAttachmentClass(this._getAttachment(popperData.placement));
XhmikosR's avatar
XhmikosR committed
3970
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3971

XhmikosR's avatar
XhmikosR committed
3972
3973
3974
  _proto._fixTransition = function _fixTransition() {
    var tip = this.getTipElement();
    var initConfigAnimation = this.config.animation;
XhmikosR's avatar
Dist.  
XhmikosR committed
3975
3976
3977
3978
3979

    if (tip.getAttribute('x-placement') !== null) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
3980
    tip.classList.remove(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
3981
3982
3983
3984
3985
    this.config.animation = false;
    this.hide();
    this.show();
    this.config.animation = initConfigAnimation;
  } // Static
XhmikosR's avatar
XhmikosR committed
3986
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3987

XhmikosR's avatar
XhmikosR committed
3988
  Tooltip.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3989
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3990
      var data = Data.getData(this, DATA_KEY$6);
XhmikosR's avatar
Dist.  
XhmikosR committed
3991

XhmikosR's avatar
XhmikosR committed
3992
      var _config = typeof config === 'object' && config;
XhmikosR's avatar
Dist.  
XhmikosR committed
3993
3994
3995
3996
3997
3998
3999
4000

      if (!data && /dispose|hide/.test(config)) {
        return;
      }

      if (!data) {
        data = new Tooltip(this, _config);
      }
For faster browsing, not all history is shown. View entire blame