bootstrap.esm.js 144 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
3001
3002
      return EventHandler.off(htmlElement, EVENT_KEY$5);
    });
XhmikosR's avatar
Dist.  
XhmikosR committed
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
    /**
     * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
     * Do not move `document` in `htmlElements` array
     * It will remove `Event.CLICK_DATA_API` event that should remain
     */

    EventHandler.off(document, Event$6.FOCUSIN);
    Data.removeData(this._element, DATA_KEY$5);
    this._config = null;
    this._element = null;
    this._dialog = null;
    this._backdrop = null;
    this._isShown = null;
    this._isBodyOverflowing = null;
    this._ignoreBackdropClick = null;
    this._isTransitioning = null;
    this._scrollbarWidth = null;
XhmikosR's avatar
XhmikosR committed
3020
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3021

XhmikosR's avatar
XhmikosR committed
3022
  _proto.handleUpdate = function handleUpdate() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3023
3024
    this._adjustDialog();
  } // Private
XhmikosR's avatar
XhmikosR committed
3025
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3026

XhmikosR's avatar
XhmikosR committed
3027
  _proto._getConfig = function _getConfig(config) {
3028
    config = _objectSpread2({}, Default$3, {}, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
3029
3030
    typeCheckConfig(NAME$5, config, DefaultType$3);
    return config;
XhmikosR's avatar
XhmikosR committed
3031
3032
3033
3034
  };

  _proto._showElement = function _showElement(relatedTarget) {
    var _this3 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3035

XhmikosR's avatar
XhmikosR committed
3036
    var transition = this._element.classList.contains(ClassName$5.FADE);
XhmikosR's avatar
Dist.  
XhmikosR committed
3037

XhmikosR's avatar
XhmikosR committed
3038
3039
    var modalBody = SelectorEngine.findOne(Selector$5.MODAL_BODY, this._dialog);

XhmikosR's avatar
Dist.  
XhmikosR committed
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
    if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
      // Don't move modal's DOM position
      document.body.appendChild(this._element);
    }

    this._element.style.display = 'block';

    this._element.removeAttribute('aria-hidden');

    this._element.setAttribute('aria-modal', true);

XhmikosR's avatar
XhmikosR committed
3051
3052
    if (this._dialog.classList.contains(ClassName$5.SCROLLABLE) && modalBody) {
      modalBody.scrollTop = 0;
XhmikosR's avatar
Dist.  
XhmikosR committed
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
    } else {
      this._element.scrollTop = 0;
    }

    if (transition) {
      reflow(this._element);
    }

    this._element.classList.add(ClassName$5.SHOW);

    if (this._config.focus) {
      this._enforceFocus();
    }

XhmikosR's avatar
XhmikosR committed
3067
3068
3069
    var transitionComplete = function transitionComplete() {
      if (_this3._config.focus) {
        _this3._element.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3070
3071
      }

XhmikosR's avatar
XhmikosR committed
3072
3073
3074
      _this3._isTransitioning = false;
      EventHandler.trigger(_this3._element, Event$6.SHOWN, {
        relatedTarget: relatedTarget
XhmikosR's avatar
Dist.  
XhmikosR committed
3075
3076
3077
3078
      });
    };

    if (transition) {
XhmikosR's avatar
XhmikosR committed
3079
      var transitionDuration = getTransitionDurationFromElement(this._dialog);
XhmikosR's avatar
Dist.  
XhmikosR committed
3080
3081
3082
3083
3084
      EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
      emulateTransitionEnd(this._dialog, transitionDuration);
    } else {
      transitionComplete();
    }
XhmikosR's avatar
XhmikosR committed
3085
3086
3087
3088
  };

  _proto._enforceFocus = function _enforceFocus() {
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3089
3090
3091

    EventHandler.off(document, Event$6.FOCUSIN); // guard against infinite focus loop

XhmikosR's avatar
XhmikosR committed
3092
3093
3094
    EventHandler.on(document, Event$6.FOCUSIN, function (event) {
      if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) {
        _this4._element.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3095
3096
      }
    });
XhmikosR's avatar
XhmikosR committed
3097
3098
3099
3100
  };

  _proto._setEscapeEvent = function _setEscapeEvent() {
    var _this5 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3101
3102

    if (this._isShown && this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
3103
      EventHandler.on(this._element, Event$6.KEYDOWN_DISMISS, function (event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3104
3105
        if (event.which === ESCAPE_KEYCODE$1) {
          event.preventDefault();
XhmikosR's avatar
XhmikosR committed
3106
3107

          _this5.hide();
XhmikosR's avatar
Dist.  
XhmikosR committed
3108
3109
        }
      });
3110
    } else {
XhmikosR's avatar
Dist.  
XhmikosR committed
3111
3112
      EventHandler.off(this._element, Event$6.KEYDOWN_DISMISS);
    }
XhmikosR's avatar
XhmikosR committed
3113
3114
3115
3116
  };

  _proto._setResizeEvent = function _setResizeEvent() {
    var _this6 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3117
3118

    if (this._isShown) {
3119
3120
      EventHandler.on(window, Event$6.RESIZE, function () {
        return _this6._adjustDialog();
XhmikosR's avatar
XhmikosR committed
3121
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
3122
3123
3124
    } else {
      EventHandler.off(window, Event$6.RESIZE);
    }
XhmikosR's avatar
XhmikosR committed
3125
3126
3127
3128
  };

  _proto._hideModal = function _hideModal() {
    var _this7 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3129
3130
3131
3132
3133
3134
3135
3136
3137

    this._element.style.display = 'none';

    this._element.setAttribute('aria-hidden', true);

    this._element.removeAttribute('aria-modal');

    this._isTransitioning = false;

XhmikosR's avatar
XhmikosR committed
3138
    this._showBackdrop(function () {
XhmikosR's avatar
Dist.  
XhmikosR committed
3139
3140
      document.body.classList.remove(ClassName$5.OPEN);

XhmikosR's avatar
XhmikosR committed
3141
      _this7._resetAdjustments();
XhmikosR's avatar
Dist.  
XhmikosR committed
3142

XhmikosR's avatar
XhmikosR committed
3143
      _this7._resetScrollbar();
XhmikosR's avatar
Dist.  
XhmikosR committed
3144

XhmikosR's avatar
XhmikosR committed
3145
      EventHandler.trigger(_this7._element, Event$6.HIDDEN);
XhmikosR's avatar
Dist.  
XhmikosR committed
3146
    });
XhmikosR's avatar
XhmikosR committed
3147
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3148

XhmikosR's avatar
XhmikosR committed
3149
  _proto._removeBackdrop = function _removeBackdrop() {
3150
    this._backdrop.parentNode.removeChild(this._backdrop);
XhmikosR's avatar
Dist.  
XhmikosR committed
3151

3152
    this._backdrop = null;
XhmikosR's avatar
XhmikosR committed
3153
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3154

XhmikosR's avatar
XhmikosR committed
3155
3156
3157
3158
  _proto._showBackdrop = function _showBackdrop(callback) {
    var _this8 = this;

    var animate = this._element.classList.contains(ClassName$5.FADE) ? ClassName$5.FADE : '';
XhmikosR's avatar
Dist.  
XhmikosR committed
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168

    if (this._isShown && this._config.backdrop) {
      this._backdrop = document.createElement('div');
      this._backdrop.className = ClassName$5.BACKDROP;

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

      document.body.appendChild(this._backdrop);
XhmikosR's avatar
XhmikosR committed
3169
3170
3171
      EventHandler.on(this._element, Event$6.CLICK_DISMISS, function (event) {
        if (_this8._ignoreBackdropClick) {
          _this8._ignoreBackdropClick = false;
XhmikosR's avatar
Dist.  
XhmikosR committed
3172
3173
3174
3175
3176
3177
3178
          return;
        }

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

XhmikosR's avatar
XhmikosR committed
3179
3180
        if (_this8._config.backdrop === 'static') {
          _this8._element.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3181
        } else {
XhmikosR's avatar
XhmikosR committed
3182
          _this8.hide();
XhmikosR's avatar
Dist.  
XhmikosR committed
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
        }
      });

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

      this._backdrop.classList.add(ClassName$5.SHOW);

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

XhmikosR's avatar
XhmikosR committed
3197
      var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
XhmikosR's avatar
Dist.  
XhmikosR committed
3198
3199
3200
3201
3202
      EventHandler.one(this._backdrop, TRANSITION_END, callback);
      emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
    } else if (!this._isShown && this._backdrop) {
      this._backdrop.classList.remove(ClassName$5.SHOW);

XhmikosR's avatar
XhmikosR committed
3203
3204
      var callbackRemove = function callbackRemove() {
        _this8._removeBackdrop();
XhmikosR's avatar
Dist.  
XhmikosR committed
3205

3206
        callback();
XhmikosR's avatar
Dist.  
XhmikosR committed
3207
3208
3209
      };

      if (this._element.classList.contains(ClassName$5.FADE)) {
XhmikosR's avatar
XhmikosR committed
3210
3211
        var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);

XhmikosR's avatar
Dist.  
XhmikosR committed
3212
        EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
XhmikosR's avatar
XhmikosR committed
3213
        emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
XhmikosR's avatar
Dist.  
XhmikosR committed
3214
3215
3216
      } else {
        callbackRemove();
      }
3217
    } else {
XhmikosR's avatar
Dist.  
XhmikosR committed
3218
3219
3220
3221
3222
      callback();
    }
  } // ----------------------------------------------------------------------
  // the following methods are used to handle overflowing modals
  // ----------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3223
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3224

XhmikosR's avatar
XhmikosR committed
3225
3226
  _proto._adjustDialog = function _adjustDialog() {
    var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
XhmikosR's avatar
Dist.  
XhmikosR committed
3227
3228

    if (!this._isBodyOverflowing && isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3229
      this._element.style.paddingLeft = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3230
3231
3232
    }

    if (this._isBodyOverflowing && !isModalOverflowing) {
XhmikosR's avatar
XhmikosR committed
3233
      this._element.style.paddingRight = this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3234
    }
XhmikosR's avatar
XhmikosR committed
3235
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3236

XhmikosR's avatar
XhmikosR committed
3237
  _proto._resetAdjustments = function _resetAdjustments() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3238
3239
    this._element.style.paddingLeft = '';
    this._element.style.paddingRight = '';
XhmikosR's avatar
XhmikosR committed
3240
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3241

XhmikosR's avatar
XhmikosR committed
3242
3243
  _proto._checkScrollbar = function _checkScrollbar() {
    var rect = document.body.getBoundingClientRect();
XhmikosR's avatar
Dist.  
XhmikosR committed
3244
3245
    this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
    this._scrollbarWidth = this._getScrollbarWidth();
XhmikosR's avatar
XhmikosR committed
3246
3247
3248
3249
  };

  _proto._setScrollbar = function _setScrollbar() {
    var _this9 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3250
3251
3252
3253
3254

    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
3255
3256
3257
      makeArray(SelectorEngine.find(Selector$5.FIXED_CONTENT)).forEach(function (element) {
        var actualPadding = element.style.paddingRight;
        var calculatedPadding = window.getComputedStyle(element)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3258
        Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3259
        element.style.paddingRight = parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3260
3261
      }); // Adjust sticky content margin

XhmikosR's avatar
XhmikosR committed
3262
3263
3264
      makeArray(SelectorEngine.find(Selector$5.STICKY_CONTENT)).forEach(function (element) {
        var actualMargin = element.style.marginRight;
        var calculatedMargin = window.getComputedStyle(element)['margin-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3265
        Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
XhmikosR's avatar
XhmikosR committed
3266
        element.style.marginRight = parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3267
3268
      }); // Adjust body padding

XhmikosR's avatar
XhmikosR committed
3269
3270
      var actualPadding = document.body.style.paddingRight;
      var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
XhmikosR's avatar
Dist.  
XhmikosR committed
3271
      Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
XhmikosR's avatar
XhmikosR committed
3272
      document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
3273
3274
3275
    }

    document.body.classList.add(ClassName$5.OPEN);
XhmikosR's avatar
XhmikosR committed
3276
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3277

XhmikosR's avatar
XhmikosR committed
3278
  _proto._resetScrollbar = function _resetScrollbar() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3279
    // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3280
3281
    makeArray(SelectorEngine.find(Selector$5.FIXED_CONTENT)).forEach(function (element) {
      var padding = Manipulator.getDataAttribute(element, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3282
3283
3284
3285
3286
3287
3288

      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
3289
3290
    makeArray(SelectorEngine.find("" + Selector$5.STICKY_CONTENT)).forEach(function (element) {
      var margin = Manipulator.getDataAttribute(element, 'margin-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3291
3292
3293
3294
3295
3296
3297

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

XhmikosR's avatar
XhmikosR committed
3298
    var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
XhmikosR's avatar
Dist.  
XhmikosR committed
3299
3300
3301
3302
3303
3304
3305

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

XhmikosR's avatar
XhmikosR committed
3308
  _proto._getScrollbarWidth = function _getScrollbarWidth() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3309
    // thx d.walsh
XhmikosR's avatar
XhmikosR committed
3310
    var scrollDiv = document.createElement('div');
XhmikosR's avatar
Dist.  
XhmikosR committed
3311
3312
    scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
    document.body.appendChild(scrollDiv);
XhmikosR's avatar
XhmikosR committed
3313
    var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
XhmikosR's avatar
Dist.  
XhmikosR committed
3314
3315
3316
    document.body.removeChild(scrollDiv);
    return scrollbarWidth;
  } // Static
XhmikosR's avatar
XhmikosR committed
3317
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3318

XhmikosR's avatar
XhmikosR committed
3319
  Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3320
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3321
      var data = Data.getData(this, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3322

3323
      var _config = _objectSpread2({}, Default$3, {}, Manipulator.getDataAttributes(this), {}, typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3324
3325
3326
3327
3328
3329
3330

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

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3331
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
3332
3333
3334
3335
3336
3337
3338
        }

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

XhmikosR's avatar
XhmikosR committed
3341
  Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3342
    return Data.getData(element, DATA_KEY$5);
XhmikosR's avatar
XhmikosR committed
3343
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3344

XhmikosR's avatar
XhmikosR committed
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
  _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
3359
3360
3361
3362
3363
3364
3365
3366
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


EventHandler.on(document, Event$6.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
XhmikosR's avatar
XhmikosR committed
3367
3368
  var _this10 = this;

XhmikosR's avatar
XhmikosR committed
3369
  var target = getElementFromSelector(this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3370
3371
3372
3373
3374

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

XhmikosR's avatar
XhmikosR committed
3375
  EventHandler.one(target, Event$6.SHOW, function (showEvent) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3376
3377
3378
3379
3380
    if (showEvent.defaultPrevented) {
      // only register focus restorer if modal will actually get shown
      return;
    }

XhmikosR's avatar
XhmikosR committed
3381
3382
3383
    EventHandler.one(target, Event$6.HIDDEN, function () {
      if (isVisible(_this10)) {
        _this10.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
3384
3385
3386
      }
    });
  });
XhmikosR's avatar
XhmikosR committed
3387
  var data = Data.getData(target, DATA_KEY$5);
XhmikosR's avatar
Dist.  
XhmikosR committed
3388
3389

  if (!data) {
3390
3391
    var config = _objectSpread2({}, Manipulator.getDataAttributes(target), {}, Manipulator.getDataAttributes(this));

XhmikosR's avatar
Dist.  
XhmikosR committed
3392
3393
3394
3395
3396
    data = new Modal(target, config);
  }

  data.show(this);
});
XhmikosR's avatar
XhmikosR committed
3397
var $$6 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
3398
3399
3400
3401
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
3402
 * add .modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist.  
XhmikosR committed
3403
3404
 */

3405
3406
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
3407
3408
3409
3410
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
3411

XhmikosR's avatar
XhmikosR committed
3412
3413
3414
  $$6.fn[NAME$5].noConflict = function () {
    $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
    return Modal.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
3415
3416
3417
3418
3419
3420
3421
3422
3423
  };
}

/**
 * --------------------------------------------------------------------------
 * Bootstrap (v4.3.1): util/sanitizer.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
XhmikosR's avatar
XhmikosR committed
3424
3425
var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
XhmikosR's avatar
Dist.  
XhmikosR committed
3426
3427
3428
3429
3430
3431
/**
 * 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
3432
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
XhmikosR's avatar
Dist.  
XhmikosR committed
3433
3434
3435
3436
3437
3438
/**
 * 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
3439
var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
XhmikosR's avatar
Dist.  
XhmikosR committed
3440

XhmikosR's avatar
XhmikosR committed
3441
3442
var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) {
  var attrName = attr.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3443
3444
3445
3446
3447
3448
3449
3450
3451

  if (allowedAttributeList.indexOf(attrName) !== -1) {
    if (uriAttrs.indexOf(attrName) !== -1) {
      return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
    }

    return true;
  }

XhmikosR's avatar
XhmikosR committed
3452
3453
3454
  var regExp = allowedAttributeList.filter(function (attrRegex) {
    return attrRegex instanceof RegExp;
  }); // Check if a regular expression validates the attribute.
XhmikosR's avatar
Dist.  
XhmikosR committed
3455

XhmikosR's avatar
XhmikosR committed
3456
  for (var i = 0, l = regExp.length; i < l; i++) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3457
3458
3459
3460
3461
3462
3463
3464
    if (attrName.match(regExp[i])) {
      return true;
    }
  }

  return false;
};

XhmikosR's avatar
XhmikosR committed
3465
var DefaultWhitelist = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
  // 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: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
};
function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  if (!unsafeHtml.length) {
    return unsafeHtml;
  }

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

XhmikosR's avatar
XhmikosR committed
3507
3508
3509
3510
  var domParser = new window.DOMParser();
  var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  var whitelistKeys = Object.keys(whiteList);
  var elements = makeArray(createdDocument.body.querySelectorAll('*'));
XhmikosR's avatar
Dist.  
XhmikosR committed
3511

XhmikosR's avatar
XhmikosR committed
3512
3513
3514
  var _loop = function _loop(i, len) {
    var el = elements[i];
    var elName = el.nodeName.toLowerCase();
XhmikosR's avatar
Dist.  
XhmikosR committed
3515
3516
3517

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

XhmikosR's avatar
XhmikosR committed
3521
3522
3523
    var attributeList = makeArray(el.attributes);
    var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
    attributeList.forEach(function (attr) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3524
3525
3526
3527
      if (!allowedAttribute(attr, whitelistedAttributes)) {
        el.removeAttribute(attr.nodeName);
      }
    });
XhmikosR's avatar
XhmikosR committed
3528
3529
3530
  };

  for (var i = 0, len = elements.length; i < len; i++) {
3531
    var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3532
3533

    if (_ret === "continue") continue;
XhmikosR's avatar
Dist.  
XhmikosR committed
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
  }

  return createdDocument.body.innerHTML;
}

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

XhmikosR's avatar
XhmikosR committed
3545
3546
3547
3548
3549
3550
3551
3552
var NAME$6 = 'tooltip';
var VERSION$6 = '4.3.1';
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
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
  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
3567
3568
  whiteList: 'object',
  popperConfig: '(null|object)'
XhmikosR's avatar
Dist.  
XhmikosR committed
3569
};
XhmikosR's avatar
XhmikosR committed
3570
var AttachmentMap$1 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3571
3572
3573
3574
3575
3576
  AUTO: 'auto',
  TOP: 'top',
  RIGHT: 'right',
  BOTTOM: 'bottom',
  LEFT: 'left'
};
XhmikosR's avatar
XhmikosR committed
3577
var Default$4 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
  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
3592
3593
  whiteList: DefaultWhitelist,
  popperConfig: null
XhmikosR's avatar
Dist.  
XhmikosR committed
3594
};
XhmikosR's avatar
XhmikosR committed
3595
var HoverState = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3596
3597
3598
  SHOW: 'show',
  OUT: 'out'
};
XhmikosR's avatar
XhmikosR committed
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
var Event$7 = {
  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
3610
};
XhmikosR's avatar
XhmikosR committed
3611
var ClassName$6 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3612
3613
3614
  FADE: 'fade',
  SHOW: 'show'
};
XhmikosR's avatar
XhmikosR committed
3615
var Selector$6 = {
Mark Otto's avatar
dist v5    
Mark Otto committed
3616
  TOOLTIP_INNER: '.tooltip-inner'
XhmikosR's avatar
Dist.  
XhmikosR committed
3617
};
XhmikosR's avatar
XhmikosR committed
3618
var Trigger = {
XhmikosR's avatar
Dist.  
XhmikosR committed
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
  HOVER: 'hover',
  FOCUS: 'focus',
  CLICK: 'click',
  MANUAL: 'manual'
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */

};

XhmikosR's avatar
XhmikosR committed
3631
3632
3633
3634
var Tooltip =
/*#__PURE__*/
function () {
  function Tooltip(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
    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
3656
  var _proto = Tooltip.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
3657

XhmikosR's avatar
XhmikosR committed
3658
3659
  // Public
  _proto.enable = function enable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3660
    this._isEnabled = true;
XhmikosR's avatar
XhmikosR committed
3661
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3662

XhmikosR's avatar
XhmikosR committed
3663
  _proto.disable = function disable() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3664
    this._isEnabled = false;
XhmikosR's avatar
XhmikosR committed
3665
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3666

XhmikosR's avatar
XhmikosR committed
3667
  _proto.toggleEnabled = function toggleEnabled() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3668
    this._isEnabled = !this._isEnabled;
XhmikosR's avatar
XhmikosR committed
3669
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3670

XhmikosR's avatar
XhmikosR committed
3671
  _proto.toggle = function toggle(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3672
3673
3674
3675
3676
    if (!this._isEnabled) {
      return;
    }

    if (event) {
XhmikosR's avatar
XhmikosR committed
3677
3678
      var dataKey = this.constructor.DATA_KEY;
      var context = Data.getData(event.delegateTarget, dataKey);
XhmikosR's avatar
Dist.  
XhmikosR committed
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700

      if (!context) {
        context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
        Data.setData(event.delegateTarget, dataKey, context);
      }

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

      if (context._isWithActiveTrigger()) {
        context._enter(null, context);
      } else {
        context._leave(null, context);
      }
    } else {
      if (this.getTipElement().classList.contains(ClassName$6.SHOW)) {
        this._leave(null, this);

        return;
      }

      this._enter(null, this);
    }
XhmikosR's avatar
XhmikosR committed
3701
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3702

XhmikosR's avatar
XhmikosR committed
3703
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3704
3705
3706
    clearTimeout(this._timeout);
    Data.removeData(this.element, this.constructor.DATA_KEY);
    EventHandler.off(this.element, this.constructor.EVENT_KEY);
Mark Otto's avatar
dist v5    
Mark Otto committed
3707
    EventHandler.off(SelectorEngine.closest(this.element, '.modal'), 'hide.bs.modal', this._hideModalHandler);
XhmikosR's avatar
Dist.  
XhmikosR committed
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717

    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
3718
    if (this._popper) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3719
3720
3721
3722
3723
3724
3725
      this._popper.destroy();
    }

    this._popper = null;
    this.element = null;
    this.config = null;
    this.tip = null;
XhmikosR's avatar
XhmikosR committed
3726
3727
3728
3729
  };

  _proto.show = function show() {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3730
3731
3732
3733
3734
3735

    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
3736
3737
3738
      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
3739
3740
3741
3742
3743

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

XhmikosR's avatar
XhmikosR committed
3744
3745
      var tip = this.getTipElement();
      var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist.  
XhmikosR committed
3746
3747
3748
3749
3750
3751
3752
3753
      tip.setAttribute('id', tipId);
      this.element.setAttribute('aria-describedby', tipId);
      this.setContent();

      if (this.config.animation) {
        tip.classList.add(ClassName$6.FADE);
      }

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

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

3758
      this._addAttachmentClass(attachment);
XhmikosR's avatar
Dist.  
XhmikosR committed
3759

XhmikosR's avatar
XhmikosR committed
3760
      var container = this._getContainer();
XhmikosR's avatar
Dist.  
XhmikosR committed
3761
3762
3763
3764
3765
3766
3767
3768

      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
3769
      this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
Dist.  
XhmikosR committed
3770
3771
3772
3773
3774
3775
      tip.classList.add(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
      // 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
3776
        makeArray(document.body.children).forEach(function (element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3777
3778
3779
3780
          EventHandler.on(element, 'mouseover', noop());
        });
      }

XhmikosR's avatar
XhmikosR committed
3781
3782
3783
      var complete = function complete() {
        if (_this.config.animation) {
          _this._fixTransition();
XhmikosR's avatar
Dist.  
XhmikosR committed
3784
3785
        }

XhmikosR's avatar
XhmikosR committed
3786
3787
3788
        var prevHoverState = _this._hoverState;
        _this._hoverState = null;
        EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
XhmikosR's avatar
Dist.  
XhmikosR committed
3789
3790

        if (prevHoverState === HoverState.OUT) {
XhmikosR's avatar
XhmikosR committed
3791
          _this._leave(null, _this);
XhmikosR's avatar
Dist.  
XhmikosR committed
3792
3793
3794
3795
        }
      };

      if (this.tip.classList.contains(ClassName$6.FADE)) {
XhmikosR's avatar
XhmikosR committed
3796
        var transitionDuration = getTransitionDurationFromElement(this.tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3797
3798
3799
3800
3801
3802
        EventHandler.one(this.tip, TRANSITION_END, complete);
        emulateTransitionEnd(this.tip, transitionDuration);
      } else {
        complete();
      }
    }
XhmikosR's avatar
XhmikosR committed
3803
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3804

3805
  _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
3806
    var _this2 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3807

XhmikosR's avatar
XhmikosR committed
3808
3809
3810
3811
    var tip = this.getTipElement();

    var complete = function complete() {
      if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3812
3813
3814
        tip.parentNode.removeChild(tip);
      }

XhmikosR's avatar
XhmikosR committed
3815
3816
3817
      _this2._cleanTipClass();

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

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

3821
      _this2._popper.destroy();
XhmikosR's avatar
Dist.  
XhmikosR committed
3822
3823
    };

XhmikosR's avatar
XhmikosR committed
3824
    var hideEvent = EventHandler.trigger(this.element, this.constructor.Event.HIDE);
XhmikosR's avatar
Dist.  
XhmikosR committed
3825
3826
3827
3828
3829
3830
3831
3832
3833

    if (hideEvent.defaultPrevented) {
      return;
    }

    tip.classList.remove(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
    // empty mouseover listeners we added for iOS support

    if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3834
3835
3836
      makeArray(document.body.children).forEach(function (element) {
        return EventHandler.off(element, 'mouseover', noop);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
3837
3838
3839
3840
3841
3842
3843
    }

    this._activeTrigger[Trigger.CLICK] = false;
    this._activeTrigger[Trigger.FOCUS] = false;
    this._activeTrigger[Trigger.HOVER] = false;

    if (this.tip.classList.contains(ClassName$6.FADE)) {
XhmikosR's avatar
XhmikosR committed
3844
      var transitionDuration = getTransitionDurationFromElement(tip);
XhmikosR's avatar
Dist.  
XhmikosR committed
3845
3846
3847
3848
3849
3850
3851
      EventHandler.one(tip, TRANSITION_END, complete);
      emulateTransitionEnd(tip, transitionDuration);
    } else {
      complete();
    }

    this._hoverState = '';
XhmikosR's avatar
XhmikosR committed
3852
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3853

XhmikosR's avatar
XhmikosR committed
3854
  _proto.update = function update() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3855
3856
3857
3858
    if (this._popper !== null) {
      this._popper.scheduleUpdate();
    }
  } // Protected
XhmikosR's avatar
XhmikosR committed
3859
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
3860

XhmikosR's avatar
XhmikosR committed
3861
  _proto.isWithContent = function isWithContent() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3862
    return Boolean(this.getTitle());
XhmikosR's avatar
XhmikosR committed
3863
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3864

XhmikosR's avatar
XhmikosR committed
3865
  _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3866
3867
3868
3869
    if (this.tip) {
      return this.tip;
    }

XhmikosR's avatar
XhmikosR committed
3870
    var element = document.createElement('div');
XhmikosR's avatar
Dist.  
XhmikosR committed
3871
3872
3873
    element.innerHTML = this.config.template;
    this.tip = element.children[0];
    return this.tip;
XhmikosR's avatar
XhmikosR committed
3874
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3875

XhmikosR's avatar
XhmikosR committed
3876
3877
  _proto.setContent = function setContent() {
    var tip = this.getTipElement();
XhmikosR's avatar
Dist.  
XhmikosR committed
3878
3879
3880
    this.setElementContent(SelectorEngine.findOne(Selector$6.TOOLTIP_INNER, tip), this.getTitle());
    tip.classList.remove(ClassName$6.FADE);
    tip.classList.remove(ClassName$6.SHOW);
XhmikosR's avatar
XhmikosR committed
3881
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3882

XhmikosR's avatar
XhmikosR committed
3883
  _proto.setElementContent = function setElementContent(element, content) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3884
3885
3886
3887
    if (element === null) {
      return;
    }

3888
    if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
      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 {
        element.innerText = content.textContent;
      }

      return;
    }

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

      element.innerHTML = content;
    } else {
      element.innerText = content;
    }
XhmikosR's avatar
XhmikosR committed
3915
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3916

XhmikosR's avatar
XhmikosR committed
3917
3918
  _proto.getTitle = function getTitle() {
    var title = this.element.getAttribute('data-original-title');
XhmikosR's avatar
Dist.  
XhmikosR committed
3919
3920
3921
3922
3923
3924
3925

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

XhmikosR's avatar
XhmikosR committed
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
  _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);
      }
    };
    return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  };

3957
3958
3959
3960
  _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
    this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
  };

XhmikosR's avatar
XhmikosR committed
3961
  _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3962
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
3963

XhmikosR's avatar
XhmikosR committed
3964
    var offset = {};
XhmikosR's avatar
Dist.  
XhmikosR committed
3965
3966

    if (typeof this.config.offset === 'function') {
XhmikosR's avatar
XhmikosR committed
3967
      offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
3968
        data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
XhmikosR's avatar
Dist.  
XhmikosR committed
3969
3970
3971
3972
3973
3974
3975
        return data;
      };
    } else {
      offset.offset = this.config.offset;
    }

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

XhmikosR's avatar
XhmikosR committed
3978
  _proto._getContainer = function _getContainer() {
XhmikosR's avatar
Dist.  
XhmikosR committed
3979
3980
3981
3982
3983
3984
3985
3986
3987
    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
3988
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3989

XhmikosR's avatar
XhmikosR committed
3990
  _proto._getAttachment = function _getAttachment(placement) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3991
    return AttachmentMap$1[placement.toUpperCase()];
XhmikosR's avatar
XhmikosR committed
3992
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
3993

XhmikosR's avatar
XhmikosR committed
3994
  _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3995
    var _this5 = this;
XhmikosR's avatar
XhmikosR committed
3996
3997
3998

    var triggers = this.config.trigger.split(' ');
    triggers.forEach(function (trigger) {
XhmikosR's avatar
Dist.  
XhmikosR committed
3999
      if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
4000
        EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
For faster browsing, not all history is shown. View entire blame