bootstrap.esm.js 143 KB
Newer Older
XhmikosR's avatar
Dist.  
XhmikosR committed
3001
3002
3003

    if (this._isShown && this._config.backdrop) {
      this._backdrop = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3004
      this._backdrop.className = CLASS_NAME_BACKDROP;
XhmikosR's avatar
Dist.  
XhmikosR committed
3005
3006
3007
3008
3009
3010

      if (animate) {
        this._backdrop.classList.add(animate);
      }

      document.body.appendChild(this._backdrop);
XhmikosR's avatar
XhmikosR committed
3011
      EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) {
XhmikosR's avatar
XhmikosR committed
3012
3013
        if (_this8._ignoreBackdropClick) {
          _this8._ignoreBackdropClick = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3014
3015
3016
3017
3018
3019
3020
          return;
        }

        if (event.target !== event.currentTarget) {
          return;
        }

XhmikosR's avatar
XhmikosR committed
3021
        _this8._triggerBackdropTransition();
XhmikosR's avatar
Dist.  
XhmikosR committed
3022
3023
3024
3025
3026
3027
      });

      if (animate) {
        reflow(this._backdrop);
      }

XhmikosR's avatar
XhmikosR committed
3028
      this._backdrop.classList.add(CLASS_NAME_SHOW$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
3029
3030
3031
3032
3033
3034

      if (!animate) {
        callback();
        return;
      }

XhmikosR's avatar
XhmikosR committed
3035
      var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
XhmikosR's avatar
Dist.  
XhmikosR committed
3036
3037
3038
      EventHandler.one(this._backdrop, TRANSITION_END, callback);
      emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
    } else if (!this._isShown && this._backdrop) {
XhmikosR's avatar
XhmikosR committed
3039
      this._backdrop.classList.remove(CLASS_NAME_SHOW$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
3040

XhmikosR's avatar
XhmikosR committed
3041
3042
      var callbackRemove = function callbackRemove() {
        _this8._removeBackdrop();
XhmikosR's avatar
Dist.  
XhmikosR committed
3043

3044
        callback();
XhmikosR's avatar
Dist.  
XhmikosR committed
3045
3046
      };

XhmikosR's avatar
XhmikosR committed
3047
      if (this._element.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
XhmikosR committed
3048
3049
        var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);

XhmikosR's avatar
Dist.  
XhmikosR committed
3050
        EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
XhmikosR's avatar
XhmikosR committed
3051
        emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
XhmikosR's avatar
Dist.  
XhmikosR committed
3052
3053
3054
      } else {
        callbackRemove();
      }
3055
    } else {
XhmikosR's avatar
Dist.  
XhmikosR committed
3056
3057
      callback();
    }
XhmikosR's avatar
XhmikosR committed
3058
3059
3060
3061
3062
3063
  };

  _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
    var _this9 = this;

    if (this._config.backdrop === 'static') {
XhmikosR's avatar
XhmikosR committed
3064
      var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
XhmikosR's avatar
XhmikosR committed
3065
3066
3067
3068
3069

      if (hideEvent.defaultPrevented) {
        return;
      }

XhmikosR's avatar
XhmikosR committed
3070
      this._element.classList.add(CLASS_NAME_STATIC);
XhmikosR's avatar
XhmikosR committed
3071
3072
3073

      var modalTransitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
3074
        _this9._element.classList.remove(CLASS_NAME_STATIC);
XhmikosR's avatar
XhmikosR committed
3075
3076
3077
3078
3079
3080
3081
      });
      emulateTransitionEnd(this._element, modalTransitionDuration);

      this._element.focus();
    } else {
      this.hide();
    }
XhmikosR's avatar
Dist.  
XhmikosR committed
3082
3083
3084
  } // ----------------------------------------------------------------------
  // the following methods are used to handle overflowing modals
  // ----------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3085
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3086

XhmikosR's avatar
XhmikosR committed
3087
3088
  _proto._adjustDialog = function _adjustDialog() {
    var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
XhmikosR's avatar
Dist.  
XhmikosR committed
3089
3090

    if (!this._isBodyOverflowing && isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3091
      this._element.style.paddingLeft = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3092
3093
3094
    }

    if (this._isBodyOverflowing && !isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3095
      this._element.style.paddingRight = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3096
    }
XhmikosR's avatar
XhmikosR committed
3097
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3098

XhmikosR's avatar
XhmikosR committed
3099
  _proto._resetAdjustments = function _resetAdjustments() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3100
3101
    this._element.style.paddingLeft = '';
    this._element.style.paddingRight = '';
XhmikosR's avatar
XhmikosR committed
3102
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3103

XhmikosR's avatar
XhmikosR committed
3104
3105
  _proto._checkScrollbar = function _checkScrollbar() {
    var rect = document.body.getBoundingClientRect();
XhmikosR's avatar
XhmikosR committed
3106
    this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
XhmikosR's avatar
Dist.  
XhmikosR committed
3107
    this._scrollbarWidth = this._getScrollbarWidth();
XhmikosR's avatar
XhmikosR committed
3108
3109
3110
  };

  _proto._setScrollbar = function _setScrollbar() {
XhmikosR's avatar
XhmikosR committed
3111
    var _this10 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3112
3113
3114
3115
3116

    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
3117
      SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3118
3119
        var actualPadding = element.style.paddingRight;
        var calculatedPadding = window.getComputedStyle(element)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3120
        Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3121
        element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3122
3123
      }); // Adjust sticky content margin

XhmikosR's avatar
XhmikosR committed
3124
      SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3125
3126
        var actualMargin = element.style.marginRight;
        var calculatedMargin = window.getComputedStyle(element)['margin-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3127
        Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
XhmikosR's avatar
XhmikosR committed
3128
        element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3129
3130
      }); // Adjust body padding

XhmikosR's avatar
XhmikosR committed
3131
3132
      var actualPadding = document.body.style.paddingRight;
      var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3133
      Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3134
      document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3135
3136
    }

XhmikosR's avatar
XhmikosR committed
3137
    document.body.classList.add(CLASS_NAME_OPEN);
XhmikosR's avatar
XhmikosR committed
3138
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3139

XhmikosR's avatar
XhmikosR committed
3140
  _proto._resetScrollbar = function _resetScrollbar() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3141
    // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3142
    SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3143
      var padding = Manipulator.getDataAttribute(element, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3144
3145
3146
3147
3148
3149
3150

      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
3151
    SelectorEngine.find("" + SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3152
      var margin = Manipulator.getDataAttribute(element, 'margin-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3153
3154
3155
3156
3157
3158
3159

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

XhmikosR's avatar
XhmikosR committed
3160
    var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3161
3162
3163
3164
3165
3166
3167

    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
3168
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3169

XhmikosR's avatar
XhmikosR committed
3170
  _proto._getScrollbarWidth = function _getScrollbarWidth() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3171
    // thx d.walsh
XhmikosR's avatar
XhmikosR committed
3172
    var scrollDiv = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3173
    scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
XhmikosR's avatar
Dist.  
XhmikosR committed
3174
    document.body.appendChild(scrollDiv);
XhmikosR's avatar
XhmikosR committed
3175
    var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
XhmikosR's avatar
Dist.  
XhmikosR committed
3176
3177
3178
    document.body.removeChild(scrollDiv);
    return scrollbarWidth;
  } // Static
XhmikosR's avatar
XhmikosR committed
3179
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3180

XhmikosR's avatar
XhmikosR committed
3181
  Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3182
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3183
      var data = Data.getData(this, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3184

XhmikosR's avatar
XhmikosR committed
3185
      var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$3), Manipulator.getDataAttributes(this)), typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3186
3187
3188
3189
3190
3191
3192

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

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3193
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
3194
3195
3196
3197
3198
3199
3200
        }

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

XhmikosR's avatar
XhmikosR committed
3203
  Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3204
    return Data.getData(element, DATA_KEY$5);
XhmikosR's avatar
XhmikosR committed
3205
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3206

XhmikosR's avatar
XhmikosR committed
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
  _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
3221
3222
3223
3224
3225
3226
3227
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


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

XhmikosR's avatar
XhmikosR committed
3231
  var target = getElementFromSelector(this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3232
3233
3234
3235
3236

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

XhmikosR's avatar
XhmikosR committed
3237
  EventHandler.one(target, EVENT_SHOW$2, function (showEvent) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3238
3239
3240
3241
3242
    if (showEvent.defaultPrevented) {
      // only register focus restorer if modal will actually get shown
      return;
    }

XhmikosR's avatar
XhmikosR committed
3243
    EventHandler.one(target, EVENT_HIDDEN$2, function () {
XhmikosR's avatar
XhmikosR committed
3244
3245
      if (isVisible(_this11)) {
        _this11.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3246
3247
3248
      }
    });
  });
XhmikosR's avatar
XhmikosR committed
3249
  var data = Data.getData(target, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3250
3251

  if (!data) {
XhmikosR's avatar
XhmikosR committed
3252
    var config = _objectSpread2(_objectSpread2({}, Manipulator.getDataAttributes(target)), Manipulator.getDataAttributes(this));
3253

XhmikosR's avatar
Dist.  
XhmikosR committed
3254
3255
3256
3257
3258
    data = new Modal(target, config);
  }

  data.show(this);
});
XhmikosR's avatar
XhmikosR committed
3259
var $$6 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
3260
3261
3262
3263
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
3264
 * add .modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist.  
XhmikosR committed
3265
3266
 */

3267
3268
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
3269
3270
3271
3272
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
3273

XhmikosR's avatar
XhmikosR committed
3274
3275
3276
  $$6.fn[NAME$5].noConflict = function () {
    $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
    return Modal.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
3277
3278
3279
3280
3281
  };
}

/**
 * --------------------------------------------------------------------------
3282
 * Bootstrap (v5.0.0-alpha1): util/sanitizer.js
XhmikosR's avatar
Dist.  
XhmikosR committed
3283
3284
3285
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
XhmikosR's avatar
XhmikosR committed
3286
3287
var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
Dist.  
XhmikosR committed
3288
3289
3290
3291
3292
3293
/**
 * 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
3294
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
XhmikosR's avatar
Dist.  
XhmikosR committed
3295
3296
3297
3298
3299
3300
/**
 * 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
3301
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
3302

XhmikosR's avatar
XhmikosR committed
3303
3304
var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) {
  var attrName = attr.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3305
3306
3307

  if (allowedAttributeList.indexOf(attrName) !== -1) {
    if (uriAttrs.indexOf(attrName) !== -1) {
XhmikosR's avatar
XhmikosR committed
3308
      return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue);
XhmikosR's avatar
Dist.  
XhmikosR committed
3309
3310
3311
3312
3313
    }

    return true;
  }

XhmikosR's avatar
XhmikosR committed
3314
3315
3316
  var regExp = allowedAttributeList.filter(function (attrRegex) {
    return attrRegex instanceof RegExp;
  }); // Check if a regular expression validates the attribute.
XhmikosR's avatar
Dist.  
XhmikosR committed
3317

XhmikosR's avatar
XhmikosR committed
3318
3319
  for (var i = 0, len = regExp.length; i < len; i++) {
    if (regExp[i].test(attrName)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3320
3321
3322
3323
3324
3325
3326
      return true;
    }
  }

  return false;
};

XhmikosR's avatar
XhmikosR committed
3327
var DefaultWhitelist = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
  // 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
3346
  img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
XhmikosR's avatar
Dist.  
XhmikosR committed
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
};
function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
3361
3362
  var _ref;

XhmikosR's avatar
Dist.  
XhmikosR committed
3363
3364
3365
3366
3367
3368
3369
3370
  if (!unsafeHtml.length) {
    return unsafeHtml;
  }

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

XhmikosR's avatar
XhmikosR committed
3371
3372
3373
  var domParser = new window.DOMParser();
  var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  var whitelistKeys = Object.keys(whiteList);
XhmikosR's avatar
XhmikosR committed
3374
3375

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

XhmikosR's avatar
XhmikosR committed
3377
  var _loop = function _loop(i, len) {
XhmikosR's avatar
XhmikosR committed
3378
3379
    var _ref2;

XhmikosR's avatar
XhmikosR committed
3380
3381
    var el = elements[i];
    var elName = el.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3382
3383
3384

    if (whitelistKeys.indexOf(elName) === -1) {
      el.parentNode.removeChild(el);
XhmikosR's avatar
XhmikosR committed
3385
      return "continue";
XhmikosR's avatar
Dist.  
XhmikosR committed
3386
3387
    }

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

XhmikosR's avatar
XhmikosR committed
3390
3391
    var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
    attributeList.forEach(function (attr) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3392
3393
3394
3395
      if (!allowedAttribute(attr, whitelistedAttributes)) {
        el.removeAttribute(attr.nodeName);
      }
    });
XhmikosR's avatar
XhmikosR committed
3396
3397
3398
  };

  for (var i = 0, len = elements.length; i < len; i++) {
3399
    var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3400
3401

    if (_ret === "continue") continue;
XhmikosR's avatar
Dist.  
XhmikosR committed
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
  }

  return createdDocument.body.innerHTML;
}

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

XhmikosR's avatar
XhmikosR committed
3413
var NAME$6 = 'tooltip';
3414
var VERSION$6 = '5.0.0-alpha1';
XhmikosR's avatar
XhmikosR committed
3415
3416
3417
3418
3419
3420
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');
var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
var DefaultType$4 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
  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
3435
3436
  whiteList: 'object',
  popperConfig: '(null|object)'
XhmikosR's avatar
Dist.  
XhmikosR committed
3437
};
XhmikosR's avatar
XhmikosR committed
3438
var AttachmentMap = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3439
3440
3441
3442
3443
3444
  AUTO: 'auto',
  TOP: 'top',
  RIGHT: 'right',
  BOTTOM: 'bottom',
  LEFT: 'left'
};
XhmikosR's avatar
XhmikosR committed
3445
var Default$4 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
  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
3460
3461
  whiteList: DefaultWhitelist,
  popperConfig: null
XhmikosR's avatar
Dist.  
XhmikosR committed
3462
};
XhmikosR's avatar
XhmikosR committed
3463
var Event$1 = {
XhmikosR's avatar
XhmikosR committed
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
  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
3474
};
XhmikosR's avatar
XhmikosR committed
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
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
3485
3486
3487
3488
3489
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
3490

XhmikosR's avatar
XhmikosR committed
3491
var Tooltip = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
3492
  function Tooltip(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
    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
3514
  var _proto = Tooltip.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
3515

XhmikosR's avatar
XhmikosR committed
3516
3517
  // Public
  _proto.enable = function enable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3518
    this._isEnabled = true;
XhmikosR's avatar
XhmikosR committed
3519
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3520

XhmikosR's avatar
XhmikosR committed
3521
  _proto.disable = function disable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3522
    this._isEnabled = false;
XhmikosR's avatar
XhmikosR committed
3523
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3524

XhmikosR's avatar
XhmikosR committed
3525
  _proto.toggleEnabled = function toggleEnabled() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3526
    this._isEnabled = !this._isEnabled;
XhmikosR's avatar
XhmikosR committed
3527
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3528

XhmikosR's avatar
XhmikosR committed
3529
  _proto.toggle = function toggle(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3530
3531
3532
3533
3534
    if (!this._isEnabled) {
      return;
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3535
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3536
      var context = Data.getData(event.target, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3537
3538

      if (!context) {
XhmikosR's avatar
XhmikosR committed
3539
3540
        context = new this.constructor(event.target, this._getDelegateConfig());
        Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
      }

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

      if (context._isWithActiveTrigger()) {
        context._enter(null, context);
      } else {
        context._leave(null, context);
      }
    } else {
XhmikosR's avatar
XhmikosR committed
3551
      if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3552
3553
3554
3555
3556
3557
3558
        this._leave(null, this);

        return;
      }

      this._enter(null, this);
    }
XhmikosR's avatar
XhmikosR committed
3559
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3560

XhmikosR's avatar
XhmikosR committed
3561
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3562
3563
3564
    clearTimeout(this._timeout);
    Data.removeData(this.element, this.constructor.DATA_KEY);
    EventHandler.off(this.element, this.constructor.EVENT_KEY);
XhmikosR's avatar
XhmikosR committed
3565
    EventHandler.off(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
XhmikosR's avatar
Dist.  
XhmikosR committed
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575

    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
3576
    if (this._popper) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3577
3578
3579
3580
3581
3582
3583
      this._popper.destroy();
    }

    this._popper = null;
    this.element = null;
    this.config = null;
    this.tip = null;
XhmikosR's avatar
XhmikosR committed
3584
3585
3586
3587
  };

  _proto.show = function show() {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3588
3589
3590
3591
3592
3593

    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
3594
3595
3596
      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
3597
3598
3599
3600
3601

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

XhmikosR's avatar
XhmikosR committed
3602
3603
      var tip = this.getTipElement();
      var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist.  
XhmikosR committed
3604
3605
3606
3607
3608
      tip.setAttribute('id', tipId);
      this.element.setAttribute('aria-describedby', tipId);
      this.setContent();

      if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
3609
        tip.classList.add(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
3610
3611
      }

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

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

3616
      this._addAttachmentClass(attachment);
XhmikosR's avatar
Dist.  
XhmikosR committed
3617

XhmikosR's avatar
XhmikosR committed
3618
      var container = this._getContainer();
XhmikosR's avatar
Dist.  
XhmikosR committed
3619
3620
3621
3622
3623
3624
3625
3626

      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
3627
      this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
XhmikosR committed
3628
      tip.classList.add(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist.  
XhmikosR committed
3629
3630
3631
3632
3633
      // 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
3634
3635
3636
        var _ref;

        (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3637
3638
3639
3640
          EventHandler.on(element, 'mouseover', noop());
        });
      }

XhmikosR's avatar
XhmikosR committed
3641
3642
3643
      var complete = function complete() {
        if (_this.config.animation) {
          _this._fixTransition();
XhmikosR's avatar
Dist.  
XhmikosR committed
3644
3645
        }

XhmikosR's avatar
XhmikosR committed
3646
3647
3648
        var prevHoverState = _this._hoverState;
        _this._hoverState = null;
        EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
XhmikosR's avatar
Dist.  
XhmikosR committed
3649

XhmikosR's avatar
XhmikosR committed
3650
        if (prevHoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
XhmikosR committed
3651
          _this._leave(null, _this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3652
3653
3654
        }
      };

XhmikosR's avatar
XhmikosR committed
3655
      if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3656
        var transitionDuration = getTransitionDurationFromElement(this.tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3657
3658
3659
3660
3661
3662
        EventHandler.one(this.tip, TRANSITION_END, complete);
        emulateTransitionEnd(this.tip, transitionDuration);
      } else {
        complete();
      }
    }
XhmikosR's avatar
XhmikosR committed
3663
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3664

3665
  _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
3666
    var _this2 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3667

XhmikosR's avatar
XhmikosR committed
3668
3669
3670
    var tip = this.getTipElement();

    var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
3671
      if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3672
3673
3674
        tip.parentNode.removeChild(tip);
      }

XhmikosR's avatar
XhmikosR committed
3675
3676
3677
      _this2._cleanTipClass();

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

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

3681
      _this2._popper.destroy();
XhmikosR's avatar
Dist.  
XhmikosR committed
3682
3683
    };

XhmikosR's avatar
XhmikosR committed
3684
    var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
XhmikosR's avatar
Dist.  
XhmikosR committed
3685
3686
3687
3688
3689

    if (hideEvent.defaultPrevented) {
      return;
    }

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

    if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3694
3695
3696
      var _ref2;

      (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3697
3698
        return EventHandler.off(element, 'mouseover', noop);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
3699
3700
    }

XhmikosR's avatar
XhmikosR committed
3701
3702
3703
    this._activeTrigger[TRIGGER_CLICK] = false;
    this._activeTrigger[TRIGGER_FOCUS] = false;
    this._activeTrigger[TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3704

XhmikosR's avatar
XhmikosR committed
3705
    if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3706
      var transitionDuration = getTransitionDurationFromElement(tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3707
3708
3709
3710
3711
3712
3713
      EventHandler.one(tip, TRANSITION_END, complete);
      emulateTransitionEnd(tip, transitionDuration);
    } else {
      complete();
    }

    this._hoverState = '';
XhmikosR's avatar
XhmikosR committed
3714
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3715

XhmikosR's avatar
XhmikosR committed
3716
  _proto.update = function update() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3717
3718
3719
3720
    if (this._popper !== null) {
      this._popper.scheduleUpdate();
    }
  } // Protected
XhmikosR's avatar
XhmikosR committed
3721
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3722

XhmikosR's avatar
XhmikosR committed
3723
  _proto.isWithContent = function isWithContent() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3724
    return Boolean(this.getTitle());
XhmikosR's avatar
XhmikosR committed
3725
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3726

XhmikosR's avatar
XhmikosR committed
3727
  _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3728
3729
3730
3731
    if (this.tip) {
      return this.tip;
    }

XhmikosR's avatar
XhmikosR committed
3732
    var element = document.createElement('div');
XhmikosR's avatar
Dist.  
XhmikosR committed
3733
3734
3735
    element.innerHTML = this.config.template;
    this.tip = element.children[0];
    return this.tip;
XhmikosR's avatar
XhmikosR committed
3736
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3737

XhmikosR's avatar
XhmikosR committed
3738
3739
  _proto.setContent = function setContent() {
    var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3740
    this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
XhmikosR's avatar
XhmikosR committed
3741
    tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3);
XhmikosR's avatar
XhmikosR committed
3742
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3743

XhmikosR's avatar
XhmikosR committed
3744
  _proto.setElementContent = function setElementContent(element, content) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3745
3746
3747
3748
    if (element === null) {
      return;
    }

3749
    if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
      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
3761
        element.textContent = content.textContent;
XhmikosR's avatar
Dist.  
XhmikosR committed
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
      }

      return;
    }

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

      element.innerHTML = content;
    } else {
XhmikosR's avatar
XhmikosR committed
3774
      element.textContent = content;
XhmikosR's avatar
Dist.  
XhmikosR committed
3775
    }
XhmikosR's avatar
XhmikosR committed
3776
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3777

XhmikosR's avatar
XhmikosR committed
3778
3779
  _proto.getTitle = function getTitle() {
    var title = this.element.getAttribute('data-original-title');
XhmikosR's avatar
Dist.  
XhmikosR committed
3780
3781
3782
3783
3784
3785
3786

    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
3787
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3788

XhmikosR's avatar
XhmikosR committed
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
  _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
3815
    return _objectSpread2(_objectSpread2({}, defaultBsConfig), this.config.popperConfig);
XhmikosR's avatar
XhmikosR committed
3816
3817
  };

3818
3819
3820
3821
  _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
    this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
  };

XhmikosR's avatar
XhmikosR committed
3822
  _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3823
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3824

XhmikosR's avatar
XhmikosR committed
3825
    var offset = {};
XhmikosR's avatar
Dist.  
XhmikosR committed
3826
3827

    if (typeof this.config.offset === 'function') {
XhmikosR's avatar
XhmikosR committed
3828
      offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
3829
        data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this4.config.offset(data.offsets, _this4.element) || {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3830
3831
3832
3833
3834
3835
3836
        return data;
      };
    } else {
      offset.offset = this.config.offset;
    }

    return offset;
XhmikosR's avatar
XhmikosR committed
3837
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3838

XhmikosR's avatar
XhmikosR committed
3839
  _proto._getContainer = function _getContainer() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3840
3841
3842
3843
3844
3845
3846
3847
3848
    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
3849
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3850

XhmikosR's avatar
XhmikosR committed
3851
  _proto._getAttachment = function _getAttachment(placement) {
XhmikosR's avatar
XhmikosR committed
3852
    return AttachmentMap[placement.toUpperCase()];
XhmikosR's avatar
XhmikosR committed
3853
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3854

XhmikosR's avatar
XhmikosR committed
3855
  _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3856
    var _this5 = this;
XhmikosR's avatar
XhmikosR committed
3857
3858
3859

    var triggers = this.config.trigger.split(' ');
    triggers.forEach(function (trigger) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3860
      if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
3861
3862
        EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
          return _this5.toggle(event);
XhmikosR's avatar
XhmikosR committed
3863
        });
XhmikosR's avatar
XhmikosR committed
3864
3865
3866
      } 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
3867
3868
        EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) {
          return _this5._enter(event);
XhmikosR's avatar
XhmikosR committed
3869
        });
XhmikosR's avatar
XhmikosR committed
3870
3871
        EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) {
          return _this5._leave(event);
XhmikosR's avatar
XhmikosR committed
3872
        });
XhmikosR's avatar
Dist.  
XhmikosR committed
3873
3874
      }
    });
Mark Otto's avatar
dist v5    
Mark Otto committed
3875
3876

    this._hideModalHandler = function () {
XhmikosR's avatar
XhmikosR committed
3877
3878
      if (_this5.element) {
        _this5.hide();
XhmikosR's avatar
Dist.  
XhmikosR committed
3879
      }
Mark Otto's avatar
dist v5    
Mark Otto committed
3880
3881
    };

XhmikosR's avatar
XhmikosR committed
3882
    EventHandler.on(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
XhmikosR's avatar
Dist.  
XhmikosR committed
3883
3884

    if (this.config.selector) {
XhmikosR's avatar
XhmikosR committed
3885
      this.config = _objectSpread2(_objectSpread2({}, this.config), {}, {
XhmikosR's avatar
Dist.  
XhmikosR committed
3886
3887
3888
3889
3890
3891
        trigger: 'manual',
        selector: ''
      });
    } else {
      this._fixTitle();
    }
XhmikosR's avatar
XhmikosR committed
3892
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3893

XhmikosR's avatar
XhmikosR committed
3894
3895
  _proto._fixTitle = function _fixTitle() {
    var titleType = typeof this.element.getAttribute('data-original-title');
XhmikosR's avatar
Dist.  
XhmikosR committed
3896
3897
3898
3899
3900

    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
3901
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3902

XhmikosR's avatar
XhmikosR committed
3903
3904
  _proto._enter = function _enter(event, context) {
    var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3905
    context = context || Data.getData(event.target, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3906
3907

    if (!context) {
XhmikosR's avatar
XhmikosR committed
3908
3909
      context = new this.constructor(event.target, this._getDelegateConfig());
      Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3910
3911
3912
    }

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

XhmikosR's avatar
XhmikosR committed
3916
3917
    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
3918
3919
3920
3921
      return;
    }

    clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3922
    context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist.  
XhmikosR committed
3923
3924
3925
3926
3927
3928

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

XhmikosR's avatar
XhmikosR committed
3929
    context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3930
      if (context._hoverState === HOVER_STATE_SHOW) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3931
3932
3933
        context.show();
      }
    }, context.config.delay.show);
XhmikosR's avatar
XhmikosR committed
3934
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3935

XhmikosR's avatar
XhmikosR committed
3936
3937
  _proto._leave = function _leave(event, context) {
    var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3938
    context = context || Data.getData(event.target, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3939
3940

    if (!context) {
XhmikosR's avatar
XhmikosR committed
3941
3942
      context = new this.constructor(event.target, this._getDelegateConfig());
      Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist.  
XhmikosR committed
3943
3944
3945
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3946
      context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3947
3948
3949
3950
3951
3952
3953
    }

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

    clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3954
    context._hoverState = HOVER_STATE_OUT;
XhmikosR's avatar
Dist.  
XhmikosR committed
3955
3956
3957
3958
3959
3960

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

XhmikosR's avatar
XhmikosR committed
3961
    context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3962
      if (context._hoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3963
3964
3965
        context.hide();
      }
    }, context.config.delay.hide);
XhmikosR's avatar
XhmikosR committed
3966
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3967

XhmikosR's avatar
XhmikosR committed
3968
3969
  _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
    for (var trigger in this._activeTrigger) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3970
3971
3972
3973
3974
3975
      if (this._activeTrigger[trigger]) {
        return true;
      }
    }

    return false;
XhmikosR's avatar
XhmikosR committed
3976
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3977

XhmikosR's avatar
XhmikosR committed
3978
3979
3980
  _proto._getConfig = function _getConfig(config) {
    var dataAttributes = Manipulator.getDataAttributes(this.element);
    Object.keys(dataAttributes).forEach(function (dataAttr) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3981
3982
3983
3984
3985
3986
3987
3988
3989
      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
3990
    config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), dataAttributes), typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000

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

    if (typeof config.title === 'number') {
      config.title = config.title.toString();
For faster browsing, not all history is shown. View entire blame