bootstrap.js 152 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
3001
    };
Jacob Thornton's avatar
Jacob Thornton committed
3002

XhmikosR's avatar
Dist    
XhmikosR committed
3003
3004
    _proto._showBackdrop = function _showBackdrop(callback) {
      var _this8 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3005

XhmikosR's avatar
XhmikosR committed
3006
      var animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
Jacob Thornton's avatar
Jacob Thornton committed
3007

XhmikosR's avatar
Dist    
XhmikosR committed
3008
3009
      if (this._isShown && this._config.backdrop) {
        this._backdrop = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3010
        this._backdrop.className = CLASS_NAME_BACKDROP;
Mark Otto's avatar
grunt    
Mark Otto committed
3011

XhmikosR's avatar
Dist    
XhmikosR committed
3012
3013
3014
        if (animate) {
          this._backdrop.classList.add(animate);
        }
Jacob Thornton's avatar
Jacob Thornton committed
3015

XhmikosR's avatar
XhmikosR committed
3016
        document.body.appendChild(this._backdrop);
XhmikosR's avatar
XhmikosR committed
3017
        EventHandler.on(this._element, EVENT_CLICK_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
3018
3019
          if (_this8._ignoreBackdropClick) {
            _this8._ignoreBackdropClick = false;
Jacob Thornton's avatar
Jacob Thornton committed
3020
3021
            return;
          }
Mark Otto's avatar
dist    
Mark Otto committed
3022

XhmikosR's avatar
Dist    
XhmikosR committed
3023
          if (event.target !== event.currentTarget) {
Jacob Thornton's avatar
Jacob Thornton committed
3024
3025
            return;
          }
Mark Otto's avatar
dist    
Mark Otto committed
3026

XhmikosR's avatar
XhmikosR committed
3027
          _this8._triggerBackdropTransition();
XhmikosR's avatar
Dist    
XhmikosR committed
3028
        });
Jacob Thornton's avatar
Jacob Thornton committed
3029

XhmikosR's avatar
Dist    
XhmikosR committed
3030
        if (animate) {
XhmikosR's avatar
XhmikosR committed
3031
          reflow(this._backdrop);
XhmikosR's avatar
Dist    
XhmikosR committed
3032
        }
Jacob Thornton's avatar
Jacob Thornton committed
3033

XhmikosR's avatar
XhmikosR committed
3034
        this._backdrop.classList.add(CLASS_NAME_SHOW$2);
Jacob Thornton's avatar
Jacob Thornton committed
3035

XhmikosR's avatar
Dist    
XhmikosR committed
3036
        if (!animate) {
Jacob Thornton's avatar
Jacob Thornton committed
3037
          callback();
XhmikosR's avatar
Dist    
XhmikosR committed
3038
          return;
Jacob Thornton's avatar
Jacob Thornton committed
3039
3040
        }

XhmikosR's avatar
XhmikosR committed
3041
3042
3043
        var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
        EventHandler.one(this._backdrop, TRANSITION_END, callback);
        emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3044
      } else if (!this._isShown && this._backdrop) {
XhmikosR's avatar
XhmikosR committed
3045
        this._backdrop.classList.remove(CLASS_NAME_SHOW$2);
Jacob Thornton's avatar
Jacob Thornton committed
3046

XhmikosR's avatar
Dist    
XhmikosR committed
3047
3048
        var callbackRemove = function callbackRemove() {
          _this8._removeBackdrop();
Jacob Thornton's avatar
Jacob Thornton committed
3049

3050
          callback();
XhmikosR's avatar
Dist    
XhmikosR committed
3051
3052
        };

XhmikosR's avatar
XhmikosR committed
3053
        if (this._element.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
XhmikosR committed
3054
          var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
Mark Otto's avatar
grunt    
Mark Otto committed
3055

XhmikosR's avatar
XhmikosR committed
3056
3057
          EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
          emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3058
3059
        } else {
          callbackRemove();
Mark Otto's avatar
dist    
Mark Otto committed
3060
        }
3061
      } else {
XhmikosR's avatar
Dist    
XhmikosR committed
3062
3063
        callback();
      }
XhmikosR's avatar
XhmikosR committed
3064
3065
3066
3067
3068
3069
    };

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

      if (this._config.backdrop === 'static') {
XhmikosR's avatar
XhmikosR committed
3070
        var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
XhmikosR's avatar
XhmikosR committed
3071
3072
3073
3074
3075

        if (hideEvent.defaultPrevented) {
          return;
        }

XhmikosR's avatar
XhmikosR committed
3076
        this._element.classList.add(CLASS_NAME_STATIC);
XhmikosR's avatar
XhmikosR committed
3077
3078
3079

        var modalTransitionDuration = getTransitionDurationFromElement(this._element);
        EventHandler.one(this._element, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
3080
          _this9._element.classList.remove(CLASS_NAME_STATIC);
XhmikosR's avatar
XhmikosR committed
3081
3082
3083
3084
3085
3086
3087
        });
        emulateTransitionEnd(this._element, modalTransitionDuration);

        this._element.focus();
      } else {
        this.hide();
      }
Mark Otto's avatar
Mark Otto committed
3088
    } // ----------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
3089
3090
    // the following methods are used to handle overflowing modals
    // ----------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
3091
    ;
Mark Otto's avatar
grunt    
Mark Otto committed
3092

XhmikosR's avatar
Dist    
XhmikosR committed
3093
3094
    _proto._adjustDialog = function _adjustDialog() {
      var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
Mark Otto's avatar
grunt    
Mark Otto committed
3095

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

XhmikosR's avatar
Dist    
XhmikosR committed
3100
3101
3102
3103
      if (this._isBodyOverflowing && !isModalOverflowing) {
        this._element.style.paddingRight = this._scrollbarWidth + "px";
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3104

XhmikosR's avatar
Dist    
XhmikosR committed
3105
3106
3107
3108
    _proto._resetAdjustments = function _resetAdjustments() {
      this._element.style.paddingLeft = '';
      this._element.style.paddingRight = '';
    };
Mark Otto's avatar
dist    
Mark Otto committed
3109

XhmikosR's avatar
Dist    
XhmikosR committed
3110
3111
    _proto._checkScrollbar = function _checkScrollbar() {
      var rect = document.body.getBoundingClientRect();
XhmikosR's avatar
XhmikosR committed
3112
      this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
XhmikosR's avatar
Dist    
XhmikosR committed
3113
3114
      this._scrollbarWidth = this._getScrollbarWidth();
    };
Mark Otto's avatar
dist    
Mark Otto committed
3115

XhmikosR's avatar
Dist    
XhmikosR committed
3116
    _proto._setScrollbar = function _setScrollbar() {
XhmikosR's avatar
XhmikosR committed
3117
      var _this10 = this;
XhmikosR's avatar
Dist    
XhmikosR committed
3118
3119
3120
3121

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

XhmikosR's avatar
XhmikosR committed
3130
        SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
XhmikosR's avatar
Dist    
XhmikosR committed
3131
          var actualMargin = element.style.marginRight;
XhmikosR's avatar
XhmikosR committed
3132
3133
          var calculatedMargin = window.getComputedStyle(element)['margin-right'];
          Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
XhmikosR's avatar
XhmikosR committed
3134
          element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px";
XhmikosR's avatar
Dist    
XhmikosR committed
3135
3136
3137
        }); // Adjust body padding

        var actualPadding = document.body.style.paddingRight;
XhmikosR's avatar
XhmikosR committed
3138
3139
3140
        var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
        Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
        document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
XhmikosR's avatar
Dist    
XhmikosR committed
3141
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3142

XhmikosR's avatar
XhmikosR committed
3143
      document.body.classList.add(CLASS_NAME_OPEN);
XhmikosR's avatar
Dist    
XhmikosR committed
3144
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3145

XhmikosR's avatar
Dist    
XhmikosR committed
3146
3147
    _proto._resetScrollbar = function _resetScrollbar() {
      // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3148
      SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
3149
3150
3151
3152
3153
3154
3155
        var padding = Manipulator.getDataAttribute(element, 'padding-right');

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
3160
        if (typeof margin !== 'undefined') {
XhmikosR's avatar
XhmikosR committed
3161
3162
          Manipulator.removeDataAttribute(element, 'margin-right');
          element.style.marginRight = margin;
XhmikosR's avatar
Dist    
XhmikosR committed
3163
3164
        }
      }); // Restore body padding
Jacob Thornton's avatar
Jacob Thornton committed
3165

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

XhmikosR's avatar
Dist.    
XhmikosR committed
3168
3169
3170
      if (typeof padding === 'undefined') {
        document.body.style.paddingRight = '';
      } else {
XhmikosR's avatar
XhmikosR committed
3171
3172
3173
        Manipulator.removeDataAttribute(document.body, 'padding-right');
        document.body.style.paddingRight = padding;
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3174
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3175

XhmikosR's avatar
Dist    
XhmikosR committed
3176
3177
3178
    _proto._getScrollbarWidth = function _getScrollbarWidth() {
      // thx d.walsh
      var scrollDiv = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
3179
      scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
XhmikosR's avatar
Dist    
XhmikosR committed
3180
3181
3182
3183
      document.body.appendChild(scrollDiv);
      var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
      document.body.removeChild(scrollDiv);
      return scrollbarWidth;
Mark Otto's avatar
Mark Otto committed
3184
3185
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
3186

XhmikosR's avatar
XhmikosR committed
3187
    Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist    
XhmikosR committed
3188
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3189
        var data = Data.getData(this, DATA_KEY$5);
Mark Otto's avatar
grunt    
Mark Otto committed
3190

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

XhmikosR's avatar
Dist    
XhmikosR committed
3193
3194
3195
3196
3197
3198
3199
        if (!data) {
          data = new Modal(this, _config);
        }

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

XhmikosR's avatar
Dist    
XhmikosR committed
3202
3203
3204
          data[config](relatedTarget);
        } else if (_config.show) {
          data.show(relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
3205
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3206
3207
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
3208

XhmikosR's avatar
XhmikosR committed
3209
    Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
3210
3211
3212
      return Data.getData(element, DATA_KEY$5);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
    _createClass(Modal, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$5;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default$3;
      }
    }]);
Mark Otto's avatar
dist    
Mark Otto committed
3224

XhmikosR's avatar
Dist    
XhmikosR committed
3225
3226
3227
3228
3229
3230
3231
    return Modal;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
3232
3233


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

XhmikosR's avatar
XhmikosR committed
3237
    var target = getElementFromSelector(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3238
3239
3240
3241
3242

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

XhmikosR's avatar
XhmikosR committed
3243
    EventHandler.one(target, EVENT_SHOW$2, function (showEvent) {
XhmikosR's avatar
XhmikosR committed
3244
3245
      if (showEvent.defaultPrevented) {
        // only register focus restorer if modal will actually get shown
XhmikosR's avatar
Dist    
XhmikosR committed
3246
        return;
Jacob Thornton's avatar
Jacob Thornton committed
3247
3248
      }

XhmikosR's avatar
XhmikosR committed
3249
      EventHandler.one(target, EVENT_HIDDEN$2, function () {
XhmikosR's avatar
XhmikosR committed
3250
3251
        if (isVisible(_this11)) {
          _this11.focus();
Jacob Thornton's avatar
Jacob Thornton committed
3252
        }
Mark Otto's avatar
dist    
Mark Otto committed
3253
3254
      });
    });
XhmikosR's avatar
XhmikosR committed
3255
    var data = Data.getData(target, DATA_KEY$5);
Mark Otto's avatar
dist    
Mark Otto committed
3256

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

XhmikosR's avatar
XhmikosR committed
3260
3261
3262
3263
      data = new Modal(target, config);
    }

    data.show(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3264
  });
XhmikosR's avatar
XhmikosR committed
3265
  var $$6 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
3266
3267
3268
3269
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
3270
   * add .modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
3271
   */
Jacob Thornton's avatar
Jacob Thornton committed
3272

3273
3274
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
3275
3276
3277
3278
  if ($$6) {
    var JQUERY_NO_CONFLICT$5 = $$6.fn[NAME$5];
    $$6.fn[NAME$5] = Modal.jQueryInterface;
    $$6.fn[NAME$5].Constructor = Modal;
Jacob Thornton's avatar
Jacob Thornton committed
3279

XhmikosR's avatar
XhmikosR committed
3280
3281
3282
    $$6.fn[NAME$5].noConflict = function () {
      $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
      return Modal.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
3283
3284
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
3285

XhmikosR's avatar
XhmikosR committed
3286
3287
  /**
   * --------------------------------------------------------------------------
3288
   * Bootstrap (v5.0.0-alpha1): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
3289
3290
3291
3292
3293
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
XhmikosR committed
3294
3295
3296
3297
3298
3299
  /**
   * 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
3300
  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
XhmikosR's avatar
XhmikosR committed
3301
3302
3303
3304
3305
3306
  /**
   * 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
3307
  var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
XhmikosR's avatar
XhmikosR committed
3308
3309
3310
3311
3312
3313

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

    if (allowedAttributeList.indexOf(attrName) !== -1) {
      if (uriAttrs.indexOf(attrName) !== -1) {
XhmikosR's avatar
XhmikosR committed
3314
        return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue);
XhmikosR's avatar
XhmikosR committed
3315
3316
3317
3318
3319
3320
3321
3322
3323
      }

      return true;
    }

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

XhmikosR's avatar
XhmikosR committed
3324
3325
    for (var i = 0, len = regExp.length; i < len; i++) {
      if (regExp[i].test(attrName)) {
XhmikosR's avatar
XhmikosR committed
3326
3327
3328
3329
3330
3331
3332
        return true;
      }
    }

    return false;
  };

XhmikosR's avatar
XhmikosR committed
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
  var DefaultWhitelist = {
    // Global attributes allowed on any supplied element below.
    '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
    a: ['target', 'href', 'title', 'rel'],
    area: [],
    b: [],
    br: [],
    col: [],
    code: [],
    div: [],
    em: [],
    hr: [],
    h1: [],
    h2: [],
    h3: [],
    h4: [],
    h5: [],
    h6: [],
    i: [],
XhmikosR's avatar
XhmikosR committed
3352
    img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
XhmikosR's avatar
XhmikosR committed
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  };
  function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
3367
3368
    var _ref;

XhmikosR's avatar
XhmikosR committed
3369
    if (!unsafeHtml.length) {
XhmikosR's avatar
XhmikosR committed
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
      return unsafeHtml;
    }

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

    var domParser = new window.DOMParser();
    var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
    var whitelistKeys = Object.keys(whiteList);
XhmikosR's avatar
XhmikosR committed
3380
3381

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

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

XhmikosR's avatar
XhmikosR committed
3386
3387
3388
      var el = elements[i];
      var elName = el.nodeName.toLowerCase();

XhmikosR's avatar
XhmikosR committed
3389
      if (whitelistKeys.indexOf(elName) === -1) {
XhmikosR's avatar
XhmikosR committed
3390
3391
3392
3393
        el.parentNode.removeChild(el);
        return "continue";
      }

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

XhmikosR's avatar
XhmikosR committed
3396
3397
3398
3399
3400
3401
3402
3403
3404
      var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
      attributeList.forEach(function (attr) {
        if (!allowedAttribute(attr, whitelistedAttributes)) {
          el.removeAttribute(attr.nodeName);
        }
      });
    };

    for (var i = 0, len = elements.length; i < len; i++) {
3405
      var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3406
3407
3408
3409
3410
3411
3412

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

    return createdDocument.body.innerHTML;
  }

XhmikosR's avatar
Dist    
XhmikosR committed
3413
3414
3415
3416
3417
3418
3419
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$6 = 'tooltip';
3420
  var VERSION$6 = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
3421
3422
3423
3424
  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
3425
  var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
XhmikosR's avatar
Dist    
XhmikosR committed
3426
3427
3428
3429
3430
3431
3432
3433
3434
  var DefaultType$4 = {
    animation: 'boolean',
    template: 'string',
    title: '(string|element|function)',
    trigger: 'string',
    delay: '(number|object)',
    html: 'boolean',
    selector: '(string|boolean)',
    placement: '(string|function)',
Mark Otto's avatar
Mark Otto committed
3435
    offset: '(number|string|function)',
XhmikosR's avatar
Dist    
XhmikosR committed
3436
3437
    container: '(string|element|boolean)',
    fallbackPlacement: '(string|array)',
XhmikosR's avatar
XhmikosR committed
3438
3439
3440
    boundary: '(string|element)',
    sanitize: 'boolean',
    sanitizeFn: '(null|function)',
XhmikosR's avatar
XhmikosR committed
3441
3442
    whiteList: 'object',
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
3443
  };
XhmikosR's avatar
XhmikosR committed
3444
  var AttachmentMap = {
XhmikosR's avatar
Dist    
XhmikosR committed
3445
3446
3447
3448
3449
3450
3451
3452
    AUTO: 'auto',
    TOP: 'top',
    RIGHT: 'right',
    BOTTOM: 'bottom',
    LEFT: 'left'
  };
  var Default$4 = {
    animation: true,
XhmikosR's avatar
XhmikosR committed
3453
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>',
XhmikosR's avatar
Dist    
XhmikosR committed
3454
3455
3456
3457
3458
3459
3460
3461
3462
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: 0,
    container: false,
    fallbackPlacement: 'flip',
XhmikosR's avatar
XhmikosR committed
3463
3464
3465
    boundary: 'scrollParent',
    sanitize: true,
    sanitizeFn: null,
XhmikosR's avatar
XhmikosR committed
3466
3467
    whiteList: DefaultWhitelist,
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
3468
  };
XhmikosR's avatar
XhmikosR committed
3469
  var Event$1 = {
XhmikosR's avatar
Dist    
XhmikosR committed
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
    HIDE: "hide" + EVENT_KEY$6,
    HIDDEN: "hidden" + EVENT_KEY$6,
    SHOW: "show" + EVENT_KEY$6,
    SHOWN: "shown" + EVENT_KEY$6,
    INSERTED: "inserted" + EVENT_KEY$6,
    CLICK: "click" + EVENT_KEY$6,
    FOCUSIN: "focusin" + EVENT_KEY$6,
    FOCUSOUT: "focusout" + EVENT_KEY$6,
    MOUSEENTER: "mouseenter" + EVENT_KEY$6,
    MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  };
XhmikosR's avatar
XhmikosR committed
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
  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
3491
3492
3493
3494
3495
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
3496

XhmikosR's avatar
XhmikosR committed
3497
  var Tooltip = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
3498
3499
    function Tooltip(element, config) {
      if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3500
        throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)');
XhmikosR's avatar
Dist    
XhmikosR committed
3501
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
3502
3503


XhmikosR's avatar
Dist    
XhmikosR committed
3504
3505
3506
3507
3508
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
Jacob Thornton's avatar
Jacob Thornton committed
3509

XhmikosR's avatar
Dist    
XhmikosR committed
3510
3511
3512
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
Jacob Thornton's avatar
Jacob Thornton committed
3513

XhmikosR's avatar
Dist    
XhmikosR committed
3514
      this._setListeners();
XhmikosR's avatar
XhmikosR committed
3515
3516

      Data.setData(element, this.constructor.DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
3517
    } // Getters
Jacob Thornton's avatar
Jacob Thornton committed
3518
3519


XhmikosR's avatar
Dist    
XhmikosR committed
3520
    var _proto = Tooltip.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
3521

XhmikosR's avatar
Dist    
XhmikosR committed
3522
3523
3524
3525
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3526

XhmikosR's avatar
Dist    
XhmikosR committed
3527
3528
3529
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3530

XhmikosR's avatar
Dist    
XhmikosR committed
3531
3532
3533
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3534

XhmikosR's avatar
Dist    
XhmikosR committed
3535
3536
3537
3538
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3539

XhmikosR's avatar
Dist    
XhmikosR committed
3540
3541
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3542
        var context = Data.getData(event.target, dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
3543

XhmikosR's avatar
Dist    
XhmikosR committed
3544
        if (!context) {
XhmikosR's avatar
XhmikosR committed
3545
3546
          context = new this.constructor(event.target, this._getDelegateConfig());
          Data.setData(event.target, dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
3547
        }
Jacob Thornton's avatar
Jacob Thornton committed
3548

XhmikosR's avatar
Dist    
XhmikosR committed
3549
        context._activeTrigger.click = !context._activeTrigger.click;
Jacob Thornton's avatar
Jacob Thornton committed
3550

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

XhmikosR's avatar
Dist    
XhmikosR committed
3560
          return;
Mark Otto's avatar
dist    
Mark Otto committed
3561
        }
Jacob Thornton's avatar
Jacob Thornton committed
3562

XhmikosR's avatar
Dist    
XhmikosR committed
3563
3564
3565
        this._enter(null, this);
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3566

XhmikosR's avatar
Dist    
XhmikosR committed
3567
3568
    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
XhmikosR's avatar
XhmikosR committed
3569
3570
      Data.removeData(this.element, this.constructor.DATA_KEY);
      EventHandler.off(this.element, this.constructor.EVENT_KEY);
XhmikosR's avatar
XhmikosR committed
3571
      EventHandler.off(this.element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
Jacob Thornton's avatar
Jacob Thornton committed
3572

XhmikosR's avatar
Dist    
XhmikosR committed
3573
      if (this.tip) {
XhmikosR's avatar
XhmikosR committed
3574
        this.tip.parentNode.removeChild(this.tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3575
      }
Mark Otto's avatar
dist    
Mark Otto committed
3576

XhmikosR's avatar
Dist    
XhmikosR committed
3577
3578
3579
3580
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
Mark Otto's avatar
grunt    
Mark Otto committed
3581

XhmikosR's avatar
XhmikosR committed
3582
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
3583
3584
        this._popper.destroy();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3585

XhmikosR's avatar
Dist    
XhmikosR committed
3586
3587
3588
3589
3590
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3591

XhmikosR's avatar
Dist    
XhmikosR committed
3592
3593
    _proto.show = function show() {
      var _this = this;
Jacob Thornton's avatar
Jacob Thornton committed
3594

XhmikosR's avatar
XhmikosR committed
3595
      if (this.element.style.display === 'none') {
XhmikosR's avatar
Dist    
XhmikosR committed
3596
3597
        throw new Error('Please use show on visible elements');
      }
Mark Otto's avatar
dist    
Mark Otto committed
3598

XhmikosR's avatar
Dist    
XhmikosR committed
3599
      if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
3600
3601
        var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
        var shadowRoot = findShadowRoot(this.element);
XhmikosR's avatar
Dist.    
XhmikosR committed
3602
        var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
Jacob Thornton's avatar
Jacob Thornton committed
3603

XhmikosR's avatar
XhmikosR committed
3604
        if (showEvent.defaultPrevented || !isInTheDom) {
XhmikosR's avatar
Dist    
XhmikosR committed
3605
3606
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
3607

XhmikosR's avatar
Dist    
XhmikosR committed
3608
        var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3609
        var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist    
XhmikosR committed
3610
3611
3612
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
Jacob Thornton's avatar
Jacob Thornton committed
3613

XhmikosR's avatar
Dist    
XhmikosR committed
3614
        if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
3615
          tip.classList.add(CLASS_NAME_FADE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
3616
        }
Jacob Thornton's avatar
Jacob Thornton committed
3617

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

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

3622
        this._addAttachmentClass(attachment);
Mark Otto's avatar
dist    
Mark Otto committed
3623
3624
3625

        var container = this._getContainer();

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

XhmikosR's avatar
XhmikosR committed
3628
3629
        if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
          container.appendChild(tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3630
3631
        }

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

XhmikosR's avatar
Dist    
XhmikosR committed
3639
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3640
3641
3642
          var _ref;

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

XhmikosR's avatar
Dist    
XhmikosR committed
3647
3648
3649
3650
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
Mark Otto's avatar
dist    
Mark Otto committed
3651

XhmikosR's avatar
Dist    
XhmikosR committed
3652
3653
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
XhmikosR's avatar
XhmikosR committed
3654
          EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
Jacob Thornton's avatar
Jacob Thornton committed
3655

XhmikosR's avatar
XhmikosR committed
3656
          if (prevHoverState === HOVER_STATE_OUT) {
XhmikosR's avatar
Dist    
XhmikosR committed
3657
            _this._leave(null, _this);
Mark Otto's avatar
dist    
Mark Otto committed
3658
          }
XhmikosR's avatar
Dist    
XhmikosR committed
3659
3660
        };

XhmikosR's avatar
XhmikosR committed
3661
        if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3662
3663
3664
          var transitionDuration = getTransitionDurationFromElement(this.tip);
          EventHandler.one(this.tip, TRANSITION_END, complete);
          emulateTransitionEnd(this.tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3665
3666
        } else {
          complete();
Mark Otto's avatar
dist    
Mark Otto committed
3667
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3668
3669
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3670

3671
    _proto.hide = function hide() {
XhmikosR's avatar
Dist    
XhmikosR committed
3672
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3673

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

XhmikosR's avatar
Dist    
XhmikosR committed
3676
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
3677
        if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
XhmikosR's avatar
Dist    
XhmikosR committed
3678
3679
          tip.parentNode.removeChild(tip);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
3680

XhmikosR's avatar
Dist    
XhmikosR committed
3681
        _this2._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
3682

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

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

3687
        _this2._popper.destroy();
XhmikosR's avatar
Dist    
XhmikosR committed
3688
      };
Mark Otto's avatar
grunt    
Mark Otto committed
3689

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

XhmikosR's avatar
XhmikosR committed
3692
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
3693
3694
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3695

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

XhmikosR's avatar
Dist    
XhmikosR committed
3699
      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3700
3701
3702
        var _ref2;

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

XhmikosR's avatar
XhmikosR committed
3707
3708
3709
      this._activeTrigger[TRIGGER_CLICK] = false;
      this._activeTrigger[TRIGGER_FOCUS] = false;
      this._activeTrigger[TRIGGER_HOVER] = false;
Jacob Thornton's avatar
Jacob Thornton committed
3710

XhmikosR's avatar
XhmikosR committed
3711
      if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
XhmikosR's avatar
XhmikosR committed
3712
3713
3714
        var transitionDuration = getTransitionDurationFromElement(tip);
        EventHandler.one(tip, TRANSITION_END, complete);
        emulateTransitionEnd(tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3715
3716
3717
      } else {
        complete();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3718

XhmikosR's avatar
Dist    
XhmikosR committed
3719
3720
      this._hoverState = '';
    };
Jacob Thornton's avatar
Jacob Thornton committed
3721

XhmikosR's avatar
Dist    
XhmikosR committed
3722
3723
3724
3725
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
3726
3727
    } // Protected
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3728

XhmikosR's avatar
Dist    
XhmikosR committed
3729
3730
3731
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Jacob Thornton's avatar
Jacob Thornton committed
3732

XhmikosR's avatar
Dist    
XhmikosR committed
3733
    _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
XhmikosR committed
3734
3735
3736
3737
3738
3739
3740
      if (this.tip) {
        return this.tip;
      }

      var element = document.createElement('div');
      element.innerHTML = this.config.template;
      this.tip = element.children[0];
XhmikosR's avatar
Dist    
XhmikosR committed
3741
3742
      return this.tip;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3743

XhmikosR's avatar
Dist    
XhmikosR committed
3744
3745
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3746
      this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
XhmikosR's avatar
XhmikosR committed
3747
      tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3);
XhmikosR's avatar
Dist    
XhmikosR committed
3748
    };
Jacob Thornton's avatar
Jacob Thornton committed
3749

XhmikosR's avatar
XhmikosR committed
3750
3751
3752
3753
3754
    _proto.setElementContent = function setElementContent(element, content) {
      if (element === null) {
        return;
      }

3755
      if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
XhmikosR committed
3756
3757
3758
3759
3760
        if (content.jquery) {
          content = content[0];
        } // content is a DOM node or a jQuery


XhmikosR's avatar
XhmikosR committed
3761
        if (this.config.html) {
XhmikosR's avatar
XhmikosR committed
3762
3763
3764
          if (content.parentNode !== element) {
            element.innerHTML = '';
            element.appendChild(content);
Mark Otto's avatar
dist    
Mark Otto committed
3765
3766
          }
        } else {
XhmikosR's avatar
XhmikosR committed
3767
          element.textContent = content.textContent;
Mark Otto's avatar
dist    
Mark Otto committed
3768
        }
XhmikosR's avatar
XhmikosR committed
3769
3770
3771
3772
3773
3774
3775
3776
3777

        return;
      }

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

XhmikosR's avatar
XhmikosR committed
3778
        element.innerHTML = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3779
      } else {
XhmikosR's avatar
XhmikosR committed
3780
        element.textContent = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3781
3782
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3783

XhmikosR's avatar
Dist    
XhmikosR committed
3784
3785
    _proto.getTitle = function getTitle() {
      var title = this.element.getAttribute('data-original-title');
Jacob Thornton's avatar
Jacob Thornton committed
3786

XhmikosR's avatar
Dist    
XhmikosR committed
3787
3788
3789
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3790

XhmikosR's avatar
Dist    
XhmikosR committed
3791
      return title;
Mark Otto's avatar
Mark Otto committed
3792
3793
    } // Private
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3794

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

3824
3825
3826
3827
    _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
      this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
    };

Mark Otto's avatar
Mark Otto committed
3828
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3829
      var _this4 = this;
Mark Otto's avatar
Mark Otto committed
3830
3831
3832
3833
3834

      var offset = {};

      if (typeof this.config.offset === 'function') {
        offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
3835
          data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this4.config.offset(data.offsets, _this4.element) || {});
Mark Otto's avatar
Mark Otto committed
3836
3837
3838
3839
3840
3841
3842
3843
3844
          return data;
        };
      } else {
        offset.offset = this.config.offset;
      }

      return offset;
    };

Mark Otto's avatar
dist    
Mark Otto committed
3845
3846
3847
3848
3849
    _proto._getContainer = function _getContainer() {
      if (this.config.container === false) {
        return document.body;
      }

XhmikosR's avatar
XhmikosR committed
3850
3851
      if (isElement(this.config.container)) {
        return this.config.container;
Mark Otto's avatar
dist    
Mark Otto committed
3852
3853
      }

XhmikosR's avatar
XhmikosR committed
3854
      return SelectorEngine.findOne(this.config.container);
Mark Otto's avatar
dist    
Mark Otto committed
3855
3856
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3857
    _proto._getAttachment = function _getAttachment(placement) {
XhmikosR's avatar
XhmikosR committed
3858
      return AttachmentMap[placement.toUpperCase()];
XhmikosR's avatar
Dist    
XhmikosR committed
3859
    };
Mark Otto's avatar
dist    
Mark Otto committed
3860

XhmikosR's avatar
Dist    
XhmikosR committed
3861
    _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3862
      var _this5 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3863

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

      this._hideModalHandler = function () {
XhmikosR's avatar
XhmikosR committed
3883
3884
        if (_this5.element) {
          _this5.hide();
XhmikosR's avatar
Dist    
XhmikosR committed
3885
        }
Mark Otto's avatar
dist v5    
Mark Otto committed
3886
3887
      };

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

XhmikosR's avatar
Dist    
XhmikosR committed
3890
      if (this.config.selector) {
XhmikosR's avatar
XhmikosR committed
3891
        this.config = _objectSpread2(_objectSpread2({}, this.config), {}, {
XhmikosR's avatar
Dist    
XhmikosR committed
3892
3893
3894
3895
3896
3897
3898
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3899

XhmikosR's avatar
Dist    
XhmikosR committed
3900
3901
    _proto._fixTitle = function _fixTitle() {
      var titleType = typeof this.element.getAttribute('data-original-title');
Mark Otto's avatar
dist    
Mark Otto committed
3902

XhmikosR's avatar
Dist    
XhmikosR committed
3903
3904
3905
3906
3907
      if (this.element.getAttribute('title') || titleType !== 'string') {
        this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
        this.element.setAttribute('title', '');
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3908

XhmikosR's avatar
Dist    
XhmikosR committed
3909
3910
    _proto._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3911
      context = context || Data.getData(event.target, dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
3912

XhmikosR's avatar
Dist    
XhmikosR committed
3913
      if (!context) {
XhmikosR's avatar
XhmikosR committed
3914
3915
        context = new this.constructor(event.target, this._getDelegateConfig());
        Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
3916
      }
Jacob Thornton's avatar
Jacob Thornton committed
3917

XhmikosR's avatar
Dist    
XhmikosR committed
3918
      if (event) {
XhmikosR's avatar
XhmikosR committed
3919
        context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
XhmikosR's avatar
Dist    
XhmikosR committed
3920
      }
Jacob Thornton's avatar
Jacob Thornton committed
3921

XhmikosR's avatar
XhmikosR committed
3922
3923
      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
3924
3925
3926
3927
        return;
      }

      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3928
      context._hoverState = HOVER_STATE_SHOW;
XhmikosR's avatar
Dist    
XhmikosR committed
3929
3930
3931
3932
3933

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

XhmikosR's avatar
Dist    
XhmikosR committed
3935
      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3936
        if (context._hoverState === HOVER_STATE_SHOW) {
Mark Otto's avatar
dist    
Mark Otto committed
3937
3938
          context.show();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3939
3940
      }, context.config.delay.show);
    };
Jacob Thornton's avatar
Jacob Thornton committed
3941

XhmikosR's avatar
Dist    
XhmikosR committed
3942
3943
    _proto._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3944
      context = context || Data.getData(event.target, dataKey);
Mark Otto's avatar
grunt    
Mark Otto committed
3945

XhmikosR's avatar
Dist    
XhmikosR committed
3946
      if (!context) {
XhmikosR's avatar
XhmikosR committed
3947
3948
        context = new this.constructor(event.target, this._getDelegateConfig());
        Data.setData(event.target, dataKey, context);
XhmikosR's avatar
Dist    
XhmikosR committed
3949
      }
Mark Otto's avatar
dist    
Mark Otto committed
3950

XhmikosR's avatar
Dist    
XhmikosR committed
3951
      if (event) {
XhmikosR's avatar
XhmikosR committed
3952
        context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
XhmikosR's avatar
Dist    
XhmikosR committed
3953
      }
Jacob Thornton's avatar
Jacob Thornton committed
3954

XhmikosR's avatar
Dist    
XhmikosR committed
3955
3956
3957
      if (context._isWithActiveTrigger()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3958

XhmikosR's avatar
Dist    
XhmikosR committed
3959
      clearTimeout(context._timeout);
XhmikosR's avatar
XhmikosR committed
3960
      context._hoverState = HOVER_STATE_OUT;
Jacob Thornton's avatar
Jacob Thornton committed
3961

XhmikosR's avatar
Dist    
XhmikosR committed
3962
3963
3964
3965
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3966

XhmikosR's avatar
Dist    
XhmikosR committed
3967
      context._timeout = setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
3968
        if (context._hoverState === HOVER_STATE_OUT) {
Mark Otto's avatar
dist    
Mark Otto committed
3969
3970
          context.hide();
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3971
3972
      }, context.config.delay.hide);
    };
Jacob Thornton's avatar
Jacob Thornton committed
3973

XhmikosR's avatar
Dist    
XhmikosR committed
3974
3975
3976
3977
    _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
Mark Otto's avatar
dist    
Mark Otto committed
3978
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3979
      }
Jacob Thornton's avatar
Jacob Thornton committed
3980

XhmikosR's avatar
Dist    
XhmikosR committed
3981
3982
      return false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3983

XhmikosR's avatar
Dist    
XhmikosR committed
3984
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
3985
      var dataAttributes = Manipulator.getDataAttributes(this.element);
XhmikosR's avatar
XhmikosR committed
3986
3987
3988
3989
3990
      Object.keys(dataAttributes).forEach(function (dataAttr) {
        if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
          delete dataAttributes[dataAttr];
        }
      });
XhmikosR's avatar
XhmikosR committed
3991
3992
3993
3994
3995

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
3998
3999
4000
      if (typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
For faster browsing, not all history is shown. View entire blame