bootstrap.js 153 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
3001
3002
3003
3004
       * `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
       */
Mark Otto's avatar
grunt    
Mark Otto committed
3005

XhmikosR's avatar
XhmikosR committed
3006
3007
      EventHandler.off(document, Event$6.FOCUSIN);
      Data.removeData(this._element, DATA_KEY$5);
XhmikosR's avatar
Dist    
XhmikosR committed
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
      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;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3018

XhmikosR's avatar
Dist    
XhmikosR committed
3019
3020
    _proto.handleUpdate = function handleUpdate() {
      this._adjustDialog();
Mark Otto's avatar
Mark Otto committed
3021
3022
    } // Private
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3023

XhmikosR's avatar
Dist    
XhmikosR committed
3024
    _proto._getConfig = function _getConfig(config) {
3025
      config = _objectSpread2({}, Default$3, {}, config);
XhmikosR's avatar
XhmikosR committed
3026
      typeCheckConfig(NAME$5, config, DefaultType$3);
XhmikosR's avatar
Dist    
XhmikosR committed
3027
3028
      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3029

XhmikosR's avatar
Dist    
XhmikosR committed
3030
3031
    _proto._showElement = function _showElement(relatedTarget) {
      var _this3 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3032

XhmikosR's avatar
XhmikosR committed
3033
      var transition = this._element.classList.contains(ClassName$5.FADE);
Mark Otto's avatar
dist    
Mark Otto committed
3034

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

XhmikosR's avatar
Dist    
XhmikosR committed
3037
3038
3039
3040
      if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
        // Don't move modal's DOM position
        document.body.appendChild(this._element);
      }
Mark Otto's avatar
dist    
Mark Otto committed
3041

XhmikosR's avatar
Dist    
XhmikosR committed
3042
      this._element.style.display = 'block';
Jacob Thornton's avatar
Jacob Thornton committed
3043

XhmikosR's avatar
Dist    
XhmikosR committed
3044
      this._element.removeAttribute('aria-hidden');
Mark Otto's avatar
grunt    
Mark Otto committed
3045

Mark Otto's avatar
dist    
Mark Otto committed
3046
3047
      this._element.setAttribute('aria-modal', true);

XhmikosR's avatar
XhmikosR committed
3048
3049
      if (this._dialog.classList.contains(ClassName$5.SCROLLABLE) && modalBody) {
        modalBody.scrollTop = 0;
Mark Otto's avatar
Mark Otto committed
3050
3051
3052
      } else {
        this._element.scrollTop = 0;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
3053

XhmikosR's avatar
Dist    
XhmikosR committed
3054
      if (transition) {
XhmikosR's avatar
XhmikosR committed
3055
        reflow(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
3056
      }
Mark Otto's avatar
grunt    
Mark Otto committed
3057

XhmikosR's avatar
XhmikosR committed
3058
      this._element.classList.add(ClassName$5.SHOW);
Mark Otto's avatar
dist    
Mark Otto committed
3059

XhmikosR's avatar
Dist    
XhmikosR committed
3060
3061
3062
      if (this._config.focus) {
        this._enforceFocus();
      }
Mark Otto's avatar
dist    
Mark Otto committed
3063

XhmikosR's avatar
Dist    
XhmikosR committed
3064
3065
3066
      var transitionComplete = function transitionComplete() {
        if (_this3._config.focus) {
          _this3._element.focus();
Jacob Thornton's avatar
Jacob Thornton committed
3067
        }
Mark Otto's avatar
dist    
Mark Otto committed
3068

XhmikosR's avatar
Dist    
XhmikosR committed
3069
        _this3._isTransitioning = false;
XhmikosR's avatar
XhmikosR committed
3070
3071
3072
        EventHandler.trigger(_this3._element, Event$6.SHOWN, {
          relatedTarget: relatedTarget
        });
Mark Otto's avatar
grunt    
Mark Otto committed
3073
3074
      };

XhmikosR's avatar
Dist    
XhmikosR committed
3075
      if (transition) {
XhmikosR's avatar
XhmikosR committed
3076
3077
3078
        var transitionDuration = getTransitionDurationFromElement(this._dialog);
        EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
        emulateTransitionEnd(this._dialog, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3079
3080
3081
3082
      } else {
        transitionComplete();
      }
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3083

XhmikosR's avatar
Dist    
XhmikosR committed
3084
3085
    _proto._enforceFocus = function _enforceFocus() {
      var _this4 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
3086

XhmikosR's avatar
XhmikosR committed
3087
3088
3089
3090
      EventHandler.off(document, Event$6.FOCUSIN); // guard against infinite focus loop

      EventHandler.on(document, Event$6.FOCUSIN, function (event) {
        if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) {
XhmikosR's avatar
Dist    
XhmikosR committed
3091
          _this4._element.focus();
Mark Otto's avatar
dist    
Mark Otto committed
3092
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3093
3094
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
3095

XhmikosR's avatar
Dist    
XhmikosR committed
3096
3097
    _proto._setEscapeEvent = function _setEscapeEvent() {
      var _this5 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
3098

XhmikosR's avatar
Dist    
XhmikosR committed
3099
      if (this._isShown && this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
3100
        EventHandler.on(this._element, Event$6.KEYDOWN_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
3101
3102
          if (event.which === ESCAPE_KEYCODE$1) {
            event.preventDefault();
Mark Otto's avatar
grunt    
Mark Otto committed
3103

XhmikosR's avatar
Dist    
XhmikosR committed
3104
3105
3106
            _this5.hide();
          }
        });
3107
      } else {
XhmikosR's avatar
XhmikosR committed
3108
        EventHandler.off(this._element, Event$6.KEYDOWN_DISMISS);
XhmikosR's avatar
Dist    
XhmikosR committed
3109
3110
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3111

XhmikosR's avatar
Dist    
XhmikosR committed
3112
3113
    _proto._setResizeEvent = function _setResizeEvent() {
      var _this6 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3114

XhmikosR's avatar
Dist    
XhmikosR committed
3115
      if (this._isShown) {
3116
3117
        EventHandler.on(window, Event$6.RESIZE, function () {
          return _this6._adjustDialog();
XhmikosR's avatar
Dist    
XhmikosR committed
3118
3119
        });
      } else {
XhmikosR's avatar
XhmikosR committed
3120
        EventHandler.off(window, Event$6.RESIZE);
XhmikosR's avatar
Dist    
XhmikosR committed
3121
3122
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3123

XhmikosR's avatar
Dist    
XhmikosR committed
3124
3125
    _proto._hideModal = function _hideModal() {
      var _this7 = this;
Mark Otto's avatar
dist    
Mark Otto committed
3126

XhmikosR's avatar
Dist    
XhmikosR committed
3127
      this._element.style.display = 'none';
Mark Otto's avatar
dist    
Mark Otto committed
3128

XhmikosR's avatar
Dist    
XhmikosR committed
3129
      this._element.setAttribute('aria-hidden', true);
Mark Otto's avatar
dist    
Mark Otto committed
3130

Mark Otto's avatar
dist    
Mark Otto committed
3131
3132
      this._element.removeAttribute('aria-modal');

XhmikosR's avatar
Dist    
XhmikosR committed
3133
      this._isTransitioning = false;
Mark Otto's avatar
dist    
Mark Otto committed
3134

XhmikosR's avatar
Dist    
XhmikosR committed
3135
      this._showBackdrop(function () {
XhmikosR's avatar
XhmikosR committed
3136
        document.body.classList.remove(ClassName$5.OPEN);
Mark Otto's avatar
dist    
Mark Otto committed
3137

XhmikosR's avatar
Dist    
XhmikosR committed
3138
        _this7._resetAdjustments();
Mark Otto's avatar
dist    
Mark Otto committed
3139

XhmikosR's avatar
Dist    
XhmikosR committed
3140
        _this7._resetScrollbar();
Jacob Thornton's avatar
Jacob Thornton committed
3141

XhmikosR's avatar
XhmikosR committed
3142
        EventHandler.trigger(_this7._element, Event$6.HIDDEN);
XhmikosR's avatar
Dist    
XhmikosR committed
3143
3144
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
3145

XhmikosR's avatar
Dist    
XhmikosR committed
3146
    _proto._removeBackdrop = function _removeBackdrop() {
3147
      this._backdrop.parentNode.removeChild(this._backdrop);
XhmikosR's avatar
XhmikosR committed
3148

3149
      this._backdrop = null;
XhmikosR's avatar
Dist    
XhmikosR committed
3150
    };
Jacob Thornton's avatar
Jacob Thornton committed
3151

XhmikosR's avatar
Dist    
XhmikosR committed
3152
3153
    _proto._showBackdrop = function _showBackdrop(callback) {
      var _this8 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3154

XhmikosR's avatar
XhmikosR committed
3155
      var animate = this._element.classList.contains(ClassName$5.FADE) ? ClassName$5.FADE : '';
Jacob Thornton's avatar
Jacob Thornton committed
3156

XhmikosR's avatar
Dist    
XhmikosR committed
3157
3158
3159
      if (this._isShown && this._config.backdrop) {
        this._backdrop = document.createElement('div');
        this._backdrop.className = ClassName$5.BACKDROP;
Mark Otto's avatar
grunt    
Mark Otto committed
3160

XhmikosR's avatar
Dist    
XhmikosR committed
3161
3162
3163
        if (animate) {
          this._backdrop.classList.add(animate);
        }
Jacob Thornton's avatar
Jacob Thornton committed
3164

XhmikosR's avatar
XhmikosR committed
3165
3166
        document.body.appendChild(this._backdrop);
        EventHandler.on(this._element, Event$6.CLICK_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
3167
3168
          if (_this8._ignoreBackdropClick) {
            _this8._ignoreBackdropClick = false;
Jacob Thornton's avatar
Jacob Thornton committed
3169
3170
            return;
          }
Mark Otto's avatar
dist    
Mark Otto committed
3171

XhmikosR's avatar
Dist    
XhmikosR committed
3172
          if (event.target !== event.currentTarget) {
Jacob Thornton's avatar
Jacob Thornton committed
3173
3174
            return;
          }
Mark Otto's avatar
dist    
Mark Otto committed
3175

XhmikosR's avatar
Dist    
XhmikosR committed
3176
3177
3178
3179
3180
3181
          if (_this8._config.backdrop === 'static') {
            _this8._element.focus();
          } else {
            _this8.hide();
          }
        });
Jacob Thornton's avatar
Jacob Thornton committed
3182

XhmikosR's avatar
Dist    
XhmikosR committed
3183
        if (animate) {
XhmikosR's avatar
XhmikosR committed
3184
          reflow(this._backdrop);
XhmikosR's avatar
Dist    
XhmikosR committed
3185
        }
Jacob Thornton's avatar
Jacob Thornton committed
3186

XhmikosR's avatar
XhmikosR committed
3187
        this._backdrop.classList.add(ClassName$5.SHOW);
Jacob Thornton's avatar
Jacob Thornton committed
3188

XhmikosR's avatar
Dist    
XhmikosR committed
3189
        if (!animate) {
Jacob Thornton's avatar
Jacob Thornton committed
3190
          callback();
XhmikosR's avatar
Dist    
XhmikosR committed
3191
          return;
Jacob Thornton's avatar
Jacob Thornton committed
3192
3193
        }

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

XhmikosR's avatar
Dist    
XhmikosR committed
3200
3201
        var callbackRemove = function callbackRemove() {
          _this8._removeBackdrop();
Jacob Thornton's avatar
Jacob Thornton committed
3202

3203
          callback();
XhmikosR's avatar
Dist    
XhmikosR committed
3204
3205
        };

XhmikosR's avatar
XhmikosR committed
3206
3207
        if (this._element.classList.contains(ClassName$5.FADE)) {
          var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
Mark Otto's avatar
grunt    
Mark Otto committed
3208

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
3225
3226
3227
      if (!this._isBodyOverflowing && isModalOverflowing) {
        this._element.style.paddingLeft = this._scrollbarWidth + "px";
      }
Mark Otto's avatar
dist    
Mark Otto committed
3228

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

XhmikosR's avatar
Dist    
XhmikosR committed
3234
3235
3236
3237
    _proto._resetAdjustments = function _resetAdjustments() {
      this._element.style.paddingLeft = '';
      this._element.style.paddingRight = '';
    };
Mark Otto's avatar
dist    
Mark Otto committed
3238

XhmikosR's avatar
Dist    
XhmikosR committed
3239
3240
3241
3242
3243
    _proto._checkScrollbar = function _checkScrollbar() {
      var rect = document.body.getBoundingClientRect();
      this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
      this._scrollbarWidth = this._getScrollbarWidth();
    };
Mark Otto's avatar
dist    
Mark Otto committed
3244

XhmikosR's avatar
Dist    
XhmikosR committed
3245
3246
3247
3248
3249
3250
    _proto._setScrollbar = function _setScrollbar() {
      var _this9 = this;

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

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

        var actualPadding = document.body.style.paddingRight;
XhmikosR's avatar
XhmikosR committed
3267
3268
3269
        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
3270
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3271

XhmikosR's avatar
XhmikosR committed
3272
      document.body.classList.add(ClassName$5.OPEN);
XhmikosR's avatar
Dist    
XhmikosR committed
3273
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3274

XhmikosR's avatar
Dist    
XhmikosR committed
3275
3276
    _proto._resetScrollbar = function _resetScrollbar() {
      // Restore fixed content padding
XhmikosR's avatar
XhmikosR committed
3277
3278
3279
3280
3281
3282
3283
3284
      makeArray(SelectorEngine.find(Selector$5.FIXED_CONTENT)).forEach(function (element) {
        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
3285

XhmikosR's avatar
XhmikosR committed
3286
3287
      makeArray(SelectorEngine.find("" + Selector$5.STICKY_CONTENT)).forEach(function (element) {
        var margin = Manipulator.getDataAttribute(element, 'margin-right');
Mark Otto's avatar
dist    
Mark Otto committed
3288

XhmikosR's avatar
Dist    
XhmikosR committed
3289
        if (typeof margin !== 'undefined') {
XhmikosR's avatar
XhmikosR committed
3290
3291
          Manipulator.removeDataAttribute(element, 'margin-right');
          element.style.marginRight = margin;
XhmikosR's avatar
Dist    
XhmikosR committed
3292
3293
        }
      }); // Restore body padding
Jacob Thornton's avatar
Jacob Thornton committed
3294

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

XhmikosR's avatar
Dist.    
XhmikosR committed
3297
3298
3299
      if (typeof padding === 'undefined') {
        document.body.style.paddingRight = '';
      } else {
XhmikosR's avatar
XhmikosR committed
3300
3301
3302
        Manipulator.removeDataAttribute(document.body, 'padding-right');
        document.body.style.paddingRight = padding;
      }
XhmikosR's avatar
Dist    
XhmikosR committed
3303
    };
Mark Otto's avatar
grunt    
Mark Otto committed
3304

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

XhmikosR's avatar
XhmikosR committed
3316
    Modal.jQueryInterface = function jQueryInterface(config, relatedTarget) {
XhmikosR's avatar
Dist    
XhmikosR committed
3317
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
3318
        var data = Data.getData(this, DATA_KEY$5);
Mark Otto's avatar
grunt    
Mark Otto committed
3319

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

XhmikosR's avatar
Dist    
XhmikosR committed
3322
3323
3324
3325
3326
3327
3328
        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
3329
          }
Mark Otto's avatar
dist    
Mark Otto committed
3330

XhmikosR's avatar
Dist    
XhmikosR committed
3331
3332
3333
          data[config](relatedTarget);
        } else if (_config.show) {
          data.show(relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
3334
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3335
3336
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
3337

XhmikosR's avatar
XhmikosR committed
3338
    Modal.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
3339
3340
3341
      return Data.getData(element, DATA_KEY$5);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
    _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
3353

XhmikosR's avatar
Dist    
XhmikosR committed
3354
3355
3356
3357
3358
3359
3360
    return Modal;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
3361
3362


XhmikosR's avatar
XhmikosR committed
3363
  EventHandler.on(document, Event$6.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
3364
    var _this10 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3365

XhmikosR's avatar
XhmikosR committed
3366
    var target = getElementFromSelector(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3367
3368
3369
3370
3371

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

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

XhmikosR's avatar
XhmikosR committed
3378
3379
      EventHandler.one(target, Event$6.HIDDEN, function () {
        if (isVisible(_this10)) {
XhmikosR's avatar
Dist    
XhmikosR committed
3380
          _this10.focus();
Jacob Thornton's avatar
Jacob Thornton committed
3381
        }
Mark Otto's avatar
dist    
Mark Otto committed
3382
3383
      });
    });
XhmikosR's avatar
XhmikosR committed
3384
    var data = Data.getData(target, DATA_KEY$5);
Mark Otto's avatar
dist    
Mark Otto committed
3385

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

XhmikosR's avatar
XhmikosR committed
3389
3390
3391
3392
      data = new Modal(target, config);
    }

    data.show(this);
XhmikosR's avatar
Dist    
XhmikosR committed
3393
  });
XhmikosR's avatar
XhmikosR committed
3394
  var $$6 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
3395
3396
3397
3398
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
3399
   * add .modal to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
3400
   */
Jacob Thornton's avatar
Jacob Thornton committed
3401

3402
3403
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
3404
3405
3406
3407
  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
3408

XhmikosR's avatar
XhmikosR committed
3409
3410
3411
    $$6.fn[NAME$5].noConflict = function () {
      $$6.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
      return Modal.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
3412
3413
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
3414

XhmikosR's avatar
XhmikosR committed
3415
3416
  /**
   * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
3417
   * Bootstrap (v4.3.1): util/sanitizer.js
XhmikosR's avatar
XhmikosR committed
3418
3419
3420
3421
3422
   * 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
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
  /**
   * 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
   */

  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  /**
   * 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
   */

  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;

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

    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;
    }

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

    for (var i = 0, l = regExp.length; i < l; i++) {
      if (attrName.match(regExp[i])) {
        return true;
      }
    }

    return false;
  };

XhmikosR's avatar
XhmikosR committed
3462
3463
3464
3465
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
  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: [],
    img: ['src', 'alt', 'title', 'width', 'height'],
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  };
  function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
XhmikosR's avatar
XhmikosR committed
3496
    if (!unsafeHtml.length) {
XhmikosR's avatar
XhmikosR committed
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
      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
3507
    var elements = makeArray(createdDocument.body.querySelectorAll('*'));
XhmikosR's avatar
XhmikosR committed
3508
3509
3510
3511
3512

    var _loop = function _loop(i, len) {
      var el = elements[i];
      var elName = el.nodeName.toLowerCase();

XhmikosR's avatar
XhmikosR committed
3513
      if (whitelistKeys.indexOf(elName) === -1) {
XhmikosR's avatar
XhmikosR committed
3514
3515
3516
3517
        el.parentNode.removeChild(el);
        return "continue";
      }

XhmikosR's avatar
XhmikosR committed
3518
      var attributeList = makeArray(el.attributes);
XhmikosR's avatar
XhmikosR committed
3519
3520
3521
3522
3523
3524
3525
3526
3527
      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++) {
3528
      var _ret = _loop(i);
XhmikosR's avatar
XhmikosR committed
3529
3530
3531
3532
3533
3534
3535

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

    return createdDocument.body.innerHTML;
  }

XhmikosR's avatar
Dist    
XhmikosR committed
3536
3537
3538
3539
3540
3541
3542
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

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

  var Tooltip =
  /*#__PURE__*/
  function () {
    function Tooltip(element, config) {
      if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
3632
        throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)');
XhmikosR's avatar
Dist    
XhmikosR committed
3633
      } // private
Mark Otto's avatar
dist    
Mark Otto committed
3634
3635


XhmikosR's avatar
Dist    
XhmikosR committed
3636
3637
3638
3639
3640
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._popper = null; // Protected
Jacob Thornton's avatar
Jacob Thornton committed
3641

XhmikosR's avatar
Dist    
XhmikosR committed
3642
3643
3644
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;
Jacob Thornton's avatar
Jacob Thornton committed
3645

XhmikosR's avatar
Dist    
XhmikosR committed
3646
      this._setListeners();
XhmikosR's avatar
XhmikosR committed
3647
3648

      Data.setData(element, this.constructor.DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
3649
    } // Getters
Jacob Thornton's avatar
Jacob Thornton committed
3650
3651


XhmikosR's avatar
Dist    
XhmikosR committed
3652
    var _proto = Tooltip.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
3653

XhmikosR's avatar
Dist    
XhmikosR committed
3654
3655
3656
3657
    // Public
    _proto.enable = function enable() {
      this._isEnabled = true;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3658

XhmikosR's avatar
Dist    
XhmikosR committed
3659
3660
3661
    _proto.disable = function disable() {
      this._isEnabled = false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3662

XhmikosR's avatar
Dist    
XhmikosR committed
3663
3664
3665
    _proto.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3666

XhmikosR's avatar
Dist    
XhmikosR committed
3667
3668
3669
3670
    _proto.toggle = function toggle(event) {
      if (!this._isEnabled) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3671

XhmikosR's avatar
Dist    
XhmikosR committed
3672
3673
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
XhmikosR's avatar
XhmikosR committed
3674
        var context = Data.getData(event.delegateTarget, dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
3675

XhmikosR's avatar
Dist    
XhmikosR committed
3676
        if (!context) {
XhmikosR's avatar
XhmikosR committed
3677
3678
          context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
          Data.setData(event.delegateTarget, dataKey, context);
Mark Otto's avatar
dist    
Mark Otto committed
3679
        }
Jacob Thornton's avatar
Jacob Thornton committed
3680

XhmikosR's avatar
Dist    
XhmikosR committed
3681
        context._activeTrigger.click = !context._activeTrigger.click;
Jacob Thornton's avatar
Jacob Thornton committed
3682

XhmikosR's avatar
Dist    
XhmikosR committed
3683
3684
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
Mark Otto's avatar
dist    
Mark Otto committed
3685
        } else {
XhmikosR's avatar
Dist    
XhmikosR committed
3686
3687
3688
          context._leave(null, context);
        }
      } else {
XhmikosR's avatar
XhmikosR committed
3689
        if (this.getTipElement().classList.contains(ClassName$6.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
3690
          this._leave(null, this);
Jacob Thornton's avatar
Jacob Thornton committed
3691

XhmikosR's avatar
Dist    
XhmikosR committed
3692
          return;
Mark Otto's avatar
dist    
Mark Otto committed
3693
        }
Jacob Thornton's avatar
Jacob Thornton committed
3694

XhmikosR's avatar
Dist    
XhmikosR committed
3695
3696
3697
        this._enter(null, this);
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
3698

XhmikosR's avatar
Dist    
XhmikosR committed
3699
3700
    _proto.dispose = function dispose() {
      clearTimeout(this._timeout);
XhmikosR's avatar
XhmikosR committed
3701
3702
      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
3703
      EventHandler.off(SelectorEngine.closest(this.element, '.modal'), 'hide.bs.modal', this._hideModalHandler);
Jacob Thornton's avatar
Jacob Thornton committed
3704

XhmikosR's avatar
Dist    
XhmikosR committed
3705
      if (this.tip) {
XhmikosR's avatar
XhmikosR committed
3706
        this.tip.parentNode.removeChild(this.tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3707
      }
Mark Otto's avatar
dist    
Mark Otto committed
3708

XhmikosR's avatar
Dist    
XhmikosR committed
3709
3710
3711
3712
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
Mark Otto's avatar
grunt    
Mark Otto committed
3713

XhmikosR's avatar
XhmikosR committed
3714
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
3715
3716
        this._popper.destroy();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3717

XhmikosR's avatar
Dist    
XhmikosR committed
3718
3719
3720
3721
3722
      this._popper = null;
      this.element = null;
      this.config = null;
      this.tip = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3723

XhmikosR's avatar
Dist    
XhmikosR committed
3724
3725
    _proto.show = function show() {
      var _this = this;
Jacob Thornton's avatar
Jacob Thornton committed
3726

XhmikosR's avatar
XhmikosR committed
3727
      if (this.element.style.display === 'none') {
XhmikosR's avatar
Dist    
XhmikosR committed
3728
3729
        throw new Error('Please use show on visible elements');
      }
Mark Otto's avatar
dist    
Mark Otto committed
3730

XhmikosR's avatar
Dist    
XhmikosR committed
3731
      if (this.isWithContent() && this._isEnabled) {
XhmikosR's avatar
XhmikosR committed
3732
3733
        var showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW);
        var shadowRoot = findShadowRoot(this.element);
XhmikosR's avatar
Dist.    
XhmikosR committed
3734
        var isInTheDom = shadowRoot === null ? this.element.ownerDocument.documentElement.contains(this.element) : shadowRoot.contains(this.element);
Jacob Thornton's avatar
Jacob Thornton committed
3735

XhmikosR's avatar
XhmikosR committed
3736
        if (showEvent.defaultPrevented || !isInTheDom) {
XhmikosR's avatar
Dist    
XhmikosR committed
3737
3738
          return;
        }
Mark Otto's avatar
dist    
Mark Otto committed
3739

XhmikosR's avatar
Dist    
XhmikosR committed
3740
        var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3741
        var tipId = getUID(this.constructor.NAME);
XhmikosR's avatar
Dist    
XhmikosR committed
3742
3743
3744
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
        this.setContent();
Jacob Thornton's avatar
Jacob Thornton committed
3745

XhmikosR's avatar
Dist    
XhmikosR committed
3746
        if (this.config.animation) {
XhmikosR's avatar
XhmikosR committed
3747
          tip.classList.add(ClassName$6.FADE);
XhmikosR's avatar
Dist    
XhmikosR committed
3748
        }
Jacob Thornton's avatar
Jacob Thornton committed
3749

XhmikosR's avatar
Dist    
XhmikosR committed
3750
        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
3751

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

3754
        this._addAttachmentClass(attachment);
Mark Otto's avatar
dist    
Mark Otto committed
3755
3756
3757

        var container = this._getContainer();

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

XhmikosR's avatar
XhmikosR committed
3760
3761
        if (!this.element.ownerDocument.documentElement.contains(this.tip)) {
          container.appendChild(tip);
XhmikosR's avatar
Dist    
XhmikosR committed
3762
3763
        }

XhmikosR's avatar
XhmikosR committed
3764
        EventHandler.trigger(this.element, this.constructor.Event.INSERTED);
XhmikosR's avatar
XhmikosR committed
3765
        this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
XhmikosR's avatar
XhmikosR committed
3766
        tip.classList.add(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
XhmikosR's avatar
Dist    
XhmikosR committed
3767
3768
3769
        // 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
3770

XhmikosR's avatar
Dist    
XhmikosR committed
3771
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3772
3773
3774
          makeArray(document.body.children).forEach(function (element) {
            EventHandler.on(element, 'mouseover', noop());
          });
XhmikosR's avatar
Dist    
XhmikosR committed
3775
        }
Mark Otto's avatar
grunt    
Mark Otto committed
3776

XhmikosR's avatar
Dist    
XhmikosR committed
3777
3778
3779
3780
        var complete = function complete() {
          if (_this.config.animation) {
            _this._fixTransition();
          }
Mark Otto's avatar
dist    
Mark Otto committed
3781

XhmikosR's avatar
Dist    
XhmikosR committed
3782
3783
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
XhmikosR's avatar
XhmikosR committed
3784
          EventHandler.trigger(_this.element, _this.constructor.Event.SHOWN);
Jacob Thornton's avatar
Jacob Thornton committed
3785

XhmikosR's avatar
Dist    
XhmikosR committed
3786
3787
          if (prevHoverState === HoverState.OUT) {
            _this._leave(null, _this);
Mark Otto's avatar
dist    
Mark Otto committed
3788
          }
XhmikosR's avatar
Dist    
XhmikosR committed
3789
3790
        };

XhmikosR's avatar
XhmikosR committed
3791
3792
3793
3794
        if (this.tip.classList.contains(ClassName$6.FADE)) {
          var transitionDuration = getTransitionDurationFromElement(this.tip);
          EventHandler.one(this.tip, TRANSITION_END, complete);
          emulateTransitionEnd(this.tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3795
3796
        } else {
          complete();
Mark Otto's avatar
dist    
Mark Otto committed
3797
        }
XhmikosR's avatar
Dist    
XhmikosR committed
3798
3799
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3800

3801
    _proto.hide = function hide() {
XhmikosR's avatar
Dist    
XhmikosR committed
3802
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3803

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

XhmikosR's avatar
Dist    
XhmikosR committed
3806
3807
3808
3809
      var complete = function complete() {
        if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
          tip.parentNode.removeChild(tip);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
3810

XhmikosR's avatar
Dist    
XhmikosR committed
3811
        _this2._cleanTipClass();
Mark Otto's avatar
dist    
Mark Otto committed
3812

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

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

3817
        _this2._popper.destroy();
XhmikosR's avatar
Dist    
XhmikosR committed
3818
      };
Mark Otto's avatar
grunt    
Mark Otto committed
3819

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

XhmikosR's avatar
XhmikosR committed
3822
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
3823
3824
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3825

XhmikosR's avatar
XhmikosR committed
3826
      tip.classList.remove(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
XhmikosR's avatar
Dist    
XhmikosR committed
3827
      // empty mouseover listeners we added for iOS support
Mark Otto's avatar
dist    
Mark Otto committed
3828

XhmikosR's avatar
Dist    
XhmikosR committed
3829
      if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
3830
3831
3832
        makeArray(document.body.children).forEach(function (element) {
          return EventHandler.off(element, 'mouseover', noop);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
3833
      }
Jacob Thornton's avatar
Jacob Thornton committed
3834

XhmikosR's avatar
Dist    
XhmikosR committed
3835
3836
3837
      this._activeTrigger[Trigger.CLICK] = false;
      this._activeTrigger[Trigger.FOCUS] = false;
      this._activeTrigger[Trigger.HOVER] = false;
Jacob Thornton's avatar
Jacob Thornton committed
3838

XhmikosR's avatar
XhmikosR committed
3839
3840
3841
3842
      if (this.tip.classList.contains(ClassName$6.FADE)) {
        var transitionDuration = getTransitionDurationFromElement(tip);
        EventHandler.one(tip, TRANSITION_END, complete);
        emulateTransitionEnd(tip, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3843
3844
3845
      } else {
        complete();
      }
Jacob Thornton's avatar
Jacob Thornton committed
3846

XhmikosR's avatar
Dist    
XhmikosR committed
3847
3848
      this._hoverState = '';
    };
Jacob Thornton's avatar
Jacob Thornton committed
3849

XhmikosR's avatar
Dist    
XhmikosR committed
3850
3851
3852
3853
    _proto.update = function update() {
      if (this._popper !== null) {
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
3854
3855
    } // Protected
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3856

XhmikosR's avatar
Dist    
XhmikosR committed
3857
3858
3859
    _proto.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };
Jacob Thornton's avatar
Jacob Thornton committed
3860

XhmikosR's avatar
Dist    
XhmikosR committed
3861
    _proto.getTipElement = function getTipElement() {
XhmikosR's avatar
XhmikosR committed
3862
3863
3864
3865
3866
3867
3868
      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
3869
3870
      return this.tip;
    };
Jacob Thornton's avatar
Jacob Thornton committed
3871

XhmikosR's avatar
Dist    
XhmikosR committed
3872
3873
    _proto.setContent = function setContent() {
      var tip = this.getTipElement();
XhmikosR's avatar
XhmikosR committed
3874
3875
3876
      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
Dist    
XhmikosR committed
3877
    };
Jacob Thornton's avatar
Jacob Thornton committed
3878

XhmikosR's avatar
XhmikosR committed
3879
3880
3881
3882
3883
    _proto.setElementContent = function setElementContent(element, content) {
      if (element === null) {
        return;
      }

3884
      if (typeof content === 'object' && isElement(content)) {
XhmikosR's avatar
XhmikosR committed
3885
3886
3887
3888
3889
        if (content.jquery) {
          content = content[0];
        } // content is a DOM node or a jQuery


XhmikosR's avatar
XhmikosR committed
3890
        if (this.config.html) {
XhmikosR's avatar
XhmikosR committed
3891
3892
3893
          if (content.parentNode !== element) {
            element.innerHTML = '';
            element.appendChild(content);
Mark Otto's avatar
dist    
Mark Otto committed
3894
3895
          }
        } else {
XhmikosR's avatar
XhmikosR committed
3896
          element.innerText = content.textContent;
Mark Otto's avatar
dist    
Mark Otto committed
3897
        }
XhmikosR's avatar
XhmikosR committed
3898
3899
3900
3901
3902
3903
3904
3905
3906

        return;
      }

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

XhmikosR's avatar
XhmikosR committed
3907
        element.innerHTML = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3908
      } else {
XhmikosR's avatar
XhmikosR committed
3909
        element.innerText = content;
XhmikosR's avatar
Dist    
XhmikosR committed
3910
3911
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
3912

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

XhmikosR's avatar
Dist    
XhmikosR committed
3916
3917
3918
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
      }
Jacob Thornton's avatar
Jacob Thornton committed
3919

XhmikosR's avatar
Dist    
XhmikosR committed
3920
      return title;
Mark Otto's avatar
Mark Otto committed
3921
3922
    } // Private
    ;
Jacob Thornton's avatar
Jacob Thornton committed
3923

XhmikosR's avatar
XhmikosR committed
3924
3925
3926
3927
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
    _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);
    };

3953
3954
3955
3956
    _proto._addAttachmentClass = function _addAttachmentClass(attachment) {
      this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
    };

Mark Otto's avatar
Mark Otto committed
3957
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
XhmikosR committed
3958
      var _this4 = this;
Mark Otto's avatar
Mark Otto committed
3959
3960
3961
3962
3963

      var offset = {};

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

      return offset;
    };

Mark Otto's avatar
dist    
Mark Otto committed
3974
3975
3976
3977
3978
    _proto._getContainer = function _getContainer() {
      if (this.config.container === false) {
        return document.body;
      }

XhmikosR's avatar
XhmikosR committed
3979
3980
      if (isElement(this.config.container)) {
        return this.config.container;
Mark Otto's avatar
dist    
Mark Otto committed
3981
3982
      }

XhmikosR's avatar
XhmikosR committed
3983
      return SelectorEngine.findOne(this.config.container);
Mark Otto's avatar
dist    
Mark Otto committed
3984
3985
    };

XhmikosR's avatar
Dist    
XhmikosR committed
3986
3987
3988
    _proto._getAttachment = function _getAttachment(placement) {
      return AttachmentMap$1[placement.toUpperCase()];
    };
Mark Otto's avatar
dist    
Mark Otto committed
3989

XhmikosR's avatar
Dist    
XhmikosR committed
3990
    _proto._setListeners = function _setListeners() {
XhmikosR's avatar
XhmikosR committed
3991
      var _this5 = this;
Jacob Thornton's avatar
Jacob Thornton committed
3992

XhmikosR's avatar
Dist    
XhmikosR committed
3993
3994
3995
      var triggers = this.config.trigger.split(' ');
      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
XhmikosR's avatar
XhmikosR committed
3996
3997
          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
3998
          });
XhmikosR's avatar
Dist    
XhmikosR committed
3999
        } else if (trigger !== Trigger.MANUAL) {
XhmikosR's avatar
XhmikosR committed
4000
          var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
For faster browsing, not all history is shown. View entire blame