bootstrap.bundle.js 239 KB
Newer Older
Mark Otto's avatar
dist    
Mark Otto committed
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039

      data.hide = false;
      data.attributes['x-out-of-boundaries'] = false;
    }

    return data;
  }

  /**
   * @function
   * @memberof Modifiers
   * @argument {Object} data - The data object generated by `update` method
   * @argument {Object} options - Modifiers configuration and options
   * @returns {Object} The data object, properly modified
   */
  function inner(data) {
    var placement = data.placement;
    var basePlacement = placement.split('-')[0];
    var _data$offsets = data.offsets,
        popper = _data$offsets.popper,
        reference = _data$offsets.reference;

    var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;

    var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;

    popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);

    data.placement = getOppositePlacement(placement);
    data.offsets.popper = getClientRect(popper);

    return data;
  }

  /**
   * Modifier function, each modifier can have a function of this type assigned
   * to its `fn` property.<br />
   * These functions will be called on each update, this means that you must
   * make sure they are performant enough to avoid performance bottlenecks.
Mark Otto's avatar
dist  
Mark Otto committed
4040
   *
Mark Otto's avatar
dist    
Mark Otto committed
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
   * @function ModifierFn
   * @argument {dataObject} data - The data object generated by `update` method
   * @argument {Object} options - Modifiers configuration and options
   * @returns {dataObject} The data object, properly modified
   */

  /**
   * Modifiers are plugins used to alter the behavior of your poppers.<br />
   * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
   * needed by the library.
Mark Otto's avatar
dist  
Mark Otto committed
4051
   *
Mark Otto's avatar
dist    
Mark Otto committed
4052
4053
4054
   * Usually you don't want to override the `order`, `fn` and `onLoad` props.
   * All the other properties are configurations that could be tweaked.
   * @namespace modifiers
Mark Otto's avatar
dist  
Mark Otto committed
4055
   */
Mark Otto's avatar
dist    
Mark Otto committed
4056
  var modifiers = {
Mark Otto's avatar
dist  
Mark Otto committed
4057
    /**
Mark Otto's avatar
dist    
Mark Otto committed
4058
4059
4060
4061
4062
4063
     * Modifier used to shift the popper on the start or end of its reference
     * element.<br />
     * It will read the variation of the `placement` property.<br />
     * It can be one either `-end` or `-start`.
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
4064
     */
Mark Otto's avatar
dist    
Mark Otto committed
4065
4066
4067
4068
4069
4070
4071
4072
4073
    shift: {
      /** @prop {number} order=100 - Index used to define the order of execution */
      order: 100,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: shift
    },

Mark Otto's avatar
dist  
Mark Otto committed
4074
    /**
Mark Otto's avatar
dist    
Mark Otto committed
4075
4076
4077
     * The `offset` modifier can shift your popper on both its axis.
     *
     * It accepts the following units:
Mark Otto's avatar
dist    
Mark Otto committed
4078
     * - `px` or unit-less, interpreted as pixels
Mark Otto's avatar
dist    
Mark Otto committed
4079
4080
4081
4082
4083
4084
4085
     * - `%` or `%r`, percentage relative to the length of the reference element
     * - `%p`, percentage relative to the length of the popper element
     * - `vw`, CSS viewport width unit
     * - `vh`, CSS viewport height unit
     *
     * For length is intended the main axis relative to the placement of the popper.<br />
     * This means that if the placement is `top` or `bottom`, the length will be the
Mark Otto's avatar
dist    
Mark Otto committed
4086
     * `width`. In case of `left` or `right`, it will be the `height`.
Mark Otto's avatar
dist    
Mark Otto committed
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
     *
     * You can provide a single value (as `Number` or `String`), or a pair of values
     * as `String` divided by a comma or one (or more) white spaces.<br />
     * The latter is a deprecated method because it leads to confusion and will be
     * removed in v2.<br />
     * Additionally, it accepts additions and subtractions between different units.
     * Note that multiplications and divisions aren't supported.
     *
     * Valid examples are:
     * ```
     * 10
     * '10%'
     * '10, 10'
     * '10%, 10'
     * '10 + 10%'
     * '10 - 5vh + 3%'
     * '-10px + 5vh, 5px - 6%'
     * ```
     * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
     * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
Mark Otto's avatar
dist    
Mark Otto committed
4107
     * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
Mark Otto's avatar
dist    
Mark Otto committed
4108
4109
4110
     *
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
4111
     */
Mark Otto's avatar
dist    
Mark Otto committed
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
    offset: {
      /** @prop {number} order=200 - Index used to define the order of execution */
      order: 200,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: offset,
      /** @prop {Number|String} offset=0
       * The offset value as described in the modifier description
       */
      offset: 0
    },

Mark Otto's avatar
dist  
Mark Otto committed
4125
    /**
Mark Otto's avatar
dist    
Mark Otto committed
4126
4127
     * Modifier used to prevent the popper from being positioned outside the boundary.
     *
Mark Otto's avatar
dist    
Mark Otto committed
4128
     * A scenario exists where the reference itself is not within the boundaries.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
     * We can say it has "escaped the boundaries" — or just "escaped".<br />
     * In this case we need to decide whether the popper should either:
     *
     * - detach from the reference and remain "trapped" in the boundaries, or
     * - if it should ignore the boundary and "escape with its reference"
     *
     * When `escapeWithReference` is set to`true` and reference is completely
     * outside its boundaries, the popper will overflow (or completely leave)
     * the boundaries in order to remain attached to the edge of the reference.
     *
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
4141
     */
Mark Otto's avatar
dist    
Mark Otto committed
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
    preventOverflow: {
      /** @prop {number} order=300 - Index used to define the order of execution */
      order: 300,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: preventOverflow,
      /**
       * @prop {Array} [priority=['left','right','top','bottom']]
       * Popper will try to prevent overflow following these priorities by default,
       * then, it could overflow on the left and on top of the `boundariesElement`
       */
      priority: ['left', 'right', 'top', 'bottom'],
      /**
       * @prop {number} padding=5
       * Amount of pixel used to define a minimum distance between the boundaries
Mark Otto's avatar
dist    
Mark Otto committed
4158
       * and the popper. This makes sure the popper always has a little padding
Mark Otto's avatar
dist    
Mark Otto committed
4159
4160
4161
4162
4163
       * between the edges of its container
       */
      padding: 5,
      /**
       * @prop {String|HTMLElement} boundariesElement='scrollParent'
Mark Otto's avatar
dist    
Mark Otto committed
4164
       * Boundaries used by the modifier. Can be `scrollParent`, `window`,
Mark Otto's avatar
dist    
Mark Otto committed
4165
4166
4167
4168
       * `viewport` or any DOM element.
       */
      boundariesElement: 'scrollParent'
    },
Mark Otto's avatar
dist  
Mark Otto committed
4169
4170

    /**
Mark Otto's avatar
dist    
Mark Otto committed
4171
4172
4173
4174
     * Modifier used to make sure the reference and its popper stay near each other
     * without leaving any gap between the two. Especially useful when the arrow is
     * enabled and you want to ensure that it points to its reference element.
     * It cares only about the first axis. You can still have poppers with margin
Mark Otto's avatar
dist    
Mark Otto committed
4175
4176
4177
     * between the popper and its reference element.
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
4178
     */
Mark Otto's avatar
dist    
Mark Otto committed
4179
4180
4181
4182
4183
4184
4185
4186
    keepTogether: {
      /** @prop {number} order=400 - Index used to define the order of execution */
      order: 400,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: keepTogether
    },
Mark Otto's avatar
dist  
Mark Otto committed
4187

Mark Otto's avatar
dist    
Mark Otto committed
4188
4189
4190
4191
    /**
     * This modifier is used to move the `arrowElement` of the popper to make
     * sure it is positioned between the reference element and its popper element.
     * It will read the outer size of the `arrowElement` node to detect how many
Mark Otto's avatar
dist    
Mark Otto committed
4192
     * pixels of conjunction are needed.
Mark Otto's avatar
dist    
Mark Otto committed
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
     *
     * It has no effect if no `arrowElement` is provided.
     * @memberof modifiers
     * @inner
     */
    arrow: {
      /** @prop {number} order=500 - Index used to define the order of execution */
      order: 500,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: arrow,
      /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
      element: '[x-arrow]'
    },
Mark Otto's avatar
dist  
Mark Otto committed
4208

Mark Otto's avatar
dist    
Mark Otto committed
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
    /**
     * Modifier used to flip the popper's placement when it starts to overlap its
     * reference element.
     *
     * Requires the `preventOverflow` modifier before it in order to work.
     *
     * **NOTE:** this modifier will interrupt the current update cycle and will
     * restart it if it detects the need to flip the placement.
     * @memberof modifiers
     * @inner
     */
    flip: {
      /** @prop {number} order=600 - Index used to define the order of execution */
      order: 600,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: flip,
      /**
       * @prop {String|Array} behavior='flip'
       * The behavior used to change the popper's placement. It can be one of
       * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
Mark Otto's avatar
dist    
Mark Otto committed
4231
       * placements (with optional variations)
Mark Otto's avatar
dist    
Mark Otto committed
4232
4233
4234
4235
4236
4237
4238
4239
4240
       */
      behavior: 'flip',
      /**
       * @prop {number} padding=5
       * The popper will flip if it hits the edges of the `boundariesElement`
       */
      padding: 5,
      /**
       * @prop {String|HTMLElement} boundariesElement='viewport'
Mark Otto's avatar
dist    
Mark Otto committed
4241
4242
4243
       * The element which will define the boundaries of the popper position.
       * The popper will never be placed outside of the defined boundaries
       * (except if `keepTogether` is enabled)
Mark Otto's avatar
dist    
Mark Otto committed
4244
       */
XhmikosR's avatar
XhmikosR committed
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
      boundariesElement: 'viewport',
      /**
       * @prop {Boolean} flipVariations=false
       * The popper will switch placement variation between `-start` and `-end` when
       * the reference element overlaps its boundaries.
       *
       * The original placement should have a set variation.
       */
      flipVariations: false,
      /**
       * @prop {Boolean} flipVariationsByContent=false
       * The popper will switch placement variation between `-start` and `-end` when
       * the popper element overlaps its reference boundaries.
       *
       * The original placement should have a set variation.
       */
      flipVariationsByContent: false
Mark Otto's avatar
dist    
Mark Otto committed
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
    },

    /**
     * Modifier used to make the popper flow toward the inner of the reference element.
     * By default, when this modifier is disabled, the popper will be placed outside
     * the reference element.
     * @memberof modifiers
     * @inner
     */
    inner: {
      /** @prop {number} order=700 - Index used to define the order of execution */
      order: 700,
      /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
      enabled: false,
      /** @prop {ModifierFn} */
      fn: inner
    },

    /**
     * Modifier used to hide the popper when its reference element is outside of the
     * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
     * be used to hide with a CSS selector the popper when its reference is
     * out of boundaries.
     *
     * Requires the `preventOverflow` modifier before it in order to work.
     * @memberof modifiers
     * @inner
     */
    hide: {
      /** @prop {number} order=800 - Index used to define the order of execution */
      order: 800,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: hide
    },

    /**
     * Computes the style that will be applied to the popper element to gets
     * properly positioned.
     *
     * Note that this modifier will not touch the DOM, it just prepares the styles
     * so that `applyStyle` modifier can apply it. This separation is useful
     * in case you need to replace `applyStyle` with a custom implementation.
     *
     * This modifier has `850` as `order` value to maintain backward compatibility
     * with previous versions of Popper.js. Expect the modifiers ordering method
     * to change in future major versions of the library.
     *
     * @memberof modifiers
     * @inner
     */
    computeStyle: {
      /** @prop {number} order=850 - Index used to define the order of execution */
      order: 850,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: computeStyle,
      /**
       * @prop {Boolean} gpuAcceleration=true
Mark Otto's avatar
dist    
Mark Otto committed
4323
4324
       * If true, it uses the CSS 3D transformation to position the popper.
       * Otherwise, it will use the `top` and `left` properties
Mark Otto's avatar
dist    
Mark Otto committed
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
       */
      gpuAcceleration: true,
      /**
       * @prop {string} [x='bottom']
       * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
       * Change this if your popper should grow in a direction different from `bottom`
       */
      x: 'bottom',
      /**
       * @prop {string} [x='left']
       * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
       * Change this if your popper should grow in a direction different from `right`
       */
      y: 'right'
    },

    /**
     * Applies the computed styles to the popper element.
     *
     * All the DOM manipulations are limited to this modifier. This is useful in case
     * you want to integrate Popper.js inside a framework or view library and you
     * want to delegate all the DOM manipulations to it.
     *
     * Note that if you disable this modifier, you must make sure the popper element
     * has its position set to `absolute` before Popper.js can do its work!
     *
Mark Otto's avatar
dist    
Mark Otto committed
4351
     * Just disable this modifier and define your own to achieve the desired effect.
Mark Otto's avatar
dist    
Mark Otto committed
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
     *
     * @memberof modifiers
     * @inner
     */
    applyStyle: {
      /** @prop {number} order=900 - Index used to define the order of execution */
      order: 900,
      /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
      enabled: true,
      /** @prop {ModifierFn} */
      fn: applyStyle,
      /** @prop {Function} */
      onLoad: applyStyleOnLoad,
      /**
       * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
       * @prop {Boolean} gpuAcceleration=true
Mark Otto's avatar
dist    
Mark Otto committed
4368
4369
       * If true, it uses the CSS 3D transformation to position the popper.
       * Otherwise, it will use the `top` and `left` properties
Mark Otto's avatar
dist    
Mark Otto committed
4370
4371
4372
4373
       */
      gpuAcceleration: undefined
    }
  };
Mark Otto's avatar
dist  
Mark Otto committed
4374
4375

  /**
Mark Otto's avatar
dist    
Mark Otto committed
4376
4377
   * The `dataObject` is an object containing all the information used by Popper.js.
   * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
Mark Otto's avatar
dist    
Mark Otto committed
4378
4379
4380
4381
4382
   * @name dataObject
   * @property {Object} data.instance The Popper.js instance
   * @property {String} data.placement Placement applied to popper
   * @property {String} data.originalPlacement Placement originally defined on init
   * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
Mark Otto's avatar
dist    
Mark Otto committed
4383
   * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
Mark Otto's avatar
dist    
Mark Otto committed
4384
   * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
Mark Otto's avatar
dist    
Mark Otto committed
4385
4386
   * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
   * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
Mark Otto's avatar
dist    
Mark Otto committed
4387
   * @property {Object} data.boundaries Offsets of the popper boundaries
Mark Otto's avatar
dist    
Mark Otto committed
4388
   * @property {Object} data.offsets The measurements of popper, reference and arrow elements
Mark Otto's avatar
dist    
Mark Otto committed
4389
4390
4391
   * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
   * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
   * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
Mark Otto's avatar
dist  
Mark Otto committed
4392
4393
4394
   */

  /**
Mark Otto's avatar
dist    
Mark Otto committed
4395
   * Default options provided to Popper.js constructor.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4396
4397
4398
   * These can be overridden using the `options` argument of Popper.js.<br />
   * To override an option, simply pass an object with the same
   * structure of the `options` object, as the 3rd argument. For example:
Mark Otto's avatar
dist    
Mark Otto committed
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
   * ```
   * new Popper(ref, pop, {
   *   modifiers: {
   *     preventOverflow: { enabled: false }
   *   }
   * })
   * ```
   * @type {Object}
   * @static
   * @memberof Popper
Mark Otto's avatar
dist  
Mark Otto committed
4409
   */
Mark Otto's avatar
dist    
Mark Otto committed
4410
4411
  var Defaults = {
    /**
Mark Otto's avatar
dist    
Mark Otto committed
4412
     * Popper's placement.
Mark Otto's avatar
dist    
Mark Otto committed
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
     * @prop {Popper.placements} placement='bottom'
     */
    placement: 'bottom',

    /**
     * Set this to true if you want popper to position it self in 'fixed' mode
     * @prop {Boolean} positionFixed=false
     */
    positionFixed: false,

    /**
Mark Otto's avatar
dist    
Mark Otto committed
4424
     * Whether events (resize, scroll) are initially enabled.
Mark Otto's avatar
dist    
Mark Otto committed
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
     * @prop {Boolean} eventsEnabled=true
     */
    eventsEnabled: true,

    /**
     * Set to true if you want to automatically remove the popper when
     * you call the `destroy` method.
     * @prop {Boolean} removeOnDestroy=false
     */
    removeOnDestroy: false,

    /**
     * Callback called when the popper is created.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4438
     * By default, it is set to no-op.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4439
4440
4441
4442
4443
4444
     * Access Popper.js instance with `data.instance`.
     * @prop {onCreate}
     */
    onCreate: function onCreate() {},

    /**
Mark Otto's avatar
dist    
Mark Otto committed
4445
     * Callback called when the popper is updated. This callback is not called
Mark Otto's avatar
dist    
Mark Otto committed
4446
4447
     * on the initialization/creation of the popper, but only on subsequent
     * updates.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4448
     * By default, it is set to no-op.<br />
Mark Otto's avatar
dist    
Mark Otto committed
4449
4450
4451
4452
4453
4454
4455
     * Access Popper.js instance with `data.instance`.
     * @prop {onUpdate}
     */
    onUpdate: function onUpdate() {},

    /**
     * List of modifiers used to modify the offsets before they are applied to the popper.
Mark Otto's avatar
dist    
Mark Otto committed
4456
     * They provide most of the functionalities of Popper.js.
Mark Otto's avatar
dist    
Mark Otto committed
4457
4458
4459
4460
     * @prop {modifiers}
     */
    modifiers: modifiers
  };
Mark Otto's avatar
dist  
Mark Otto committed
4461
4462

  /**
Mark Otto's avatar
dist    
Mark Otto committed
4463
4464
   * @callback onCreate
   * @param {dataObject} data
Mark Otto's avatar
dist  
Mark Otto committed
4465
   */
Mark Otto's avatar
dist    
Mark Otto committed
4466

Mark Otto's avatar
dist  
Mark Otto committed
4467
  /**
Mark Otto's avatar
dist    
Mark Otto committed
4468
4469
   * @callback onUpdate
   * @param {dataObject} data
Mark Otto's avatar
dist  
Mark Otto committed
4470
4471
   */

Mark Otto's avatar
dist    
Mark Otto committed
4472
4473
4474
4475
  // Utils
  // Methods
  var Popper = function () {
    /**
Mark Otto's avatar
dist    
Mark Otto committed
4476
     * Creates a new Popper.js instance.
Mark Otto's avatar
dist    
Mark Otto committed
4477
     * @class Popper
XhmikosR's avatar
XhmikosR committed
4478
4479
     * @param {Element|referenceObject} reference - The reference element used to position the popper
     * @param {Element} popper - The HTML / XML element used as the popper
Mark Otto's avatar
dist    
Mark Otto committed
4480
4481
4482
4483
4484
4485
4486
4487
     * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
     * @return {Object} instance - The generated Popper.js instance
     */
    function Popper(reference, popper) {
      var _this = this;

      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
      classCallCheck(this, Popper);
Mark Otto's avatar
dist  
Mark Otto committed
4488

Mark Otto's avatar
dist    
Mark Otto committed
4489
4490
4491
      this.scheduleUpdate = function () {
        return requestAnimationFrame(_this.update);
      };
Mark Otto's avatar
dist  
Mark Otto committed
4492

Mark Otto's avatar
dist    
Mark Otto committed
4493
4494
4495
4496
      // make update() debounced, so that it only runs at most once-per-tick
      this.update = debounce(this.update.bind(this));

      // with {} we create a new object with the options inside it
XhmikosR's avatar
XhmikosR committed
4497
      this.options = _extends$1({}, Popper.Defaults, options);
Mark Otto's avatar
dist    
Mark Otto committed
4498
4499
4500
4501
4502
4503
4504

      // init state
      this.state = {
        isDestroyed: false,
        isCreated: false,
        scrollParents: []
      };
Mark Otto's avatar
dist  
Mark Otto committed
4505

Mark Otto's avatar
dist    
Mark Otto committed
4506
4507
4508
      // get reference and popper elements (allow jQuery wrappers)
      this.reference = reference && reference.jquery ? reference[0] : reference;
      this.popper = popper && popper.jquery ? popper[0] : popper;
Mark Otto's avatar
dist  
Mark Otto committed
4509

Mark Otto's avatar
dist    
Mark Otto committed
4510
4511
      // Deep merge modifiers options
      this.options.modifiers = {};
XhmikosR's avatar
XhmikosR committed
4512
4513
      Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
        _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
Mark Otto's avatar
dist    
Mark Otto committed
4514
      });
Mark Otto's avatar
dist  
Mark Otto committed
4515

Mark Otto's avatar
dist    
Mark Otto committed
4516
4517
      // Refactoring modifiers' list (Object => Array)
      this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
XhmikosR's avatar
XhmikosR committed
4518
        return _extends$1({
Mark Otto's avatar
dist    
Mark Otto committed
4519
4520
4521
4522
4523
4524
4525
          name: name
        }, _this.options.modifiers[name]);
      })
      // sort the modifiers by order
      .sort(function (a, b) {
        return a.order - b.order;
      });
Mark Otto's avatar
dist  
Mark Otto committed
4526

Mark Otto's avatar
dist    
Mark Otto committed
4527
4528
4529
4530
4531
4532
4533
4534
4535
      // modifiers have the ability to execute arbitrary code when Popper.js get inited
      // such code is executed in the same order of its modifier
      // they could add new properties to their options configuration
      // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
      this.modifiers.forEach(function (modifierOptions) {
        if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
          modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
        }
      });
Mark Otto's avatar
dist  
Mark Otto committed
4536

Mark Otto's avatar
dist    
Mark Otto committed
4537
4538
      // fire the first update to position the popper in the right place
      this.update();
Mark Otto's avatar
dist  
Mark Otto committed
4539

Mark Otto's avatar
dist    
Mark Otto committed
4540
4541
4542
4543
      var eventsEnabled = this.options.eventsEnabled;
      if (eventsEnabled) {
        // setup event listeners, they will take care of update the position in specific situations
        this.enableEventListeners();
Mark Otto's avatar
dist  
Mark Otto committed
4544
4545
      }

Mark Otto's avatar
dist    
Mark Otto committed
4546
      this.state.eventsEnabled = eventsEnabled;
Mark Otto's avatar
dist  
Mark Otto committed
4547
4548
    }

Mark Otto's avatar
dist    
Mark Otto committed
4549
4550
    // We can't use class properties because they don't get listed in the
    // class prototype and break stuff like Sinon stubs
Mark Otto's avatar
dist  
Mark Otto committed
4551
4552


Mark Otto's avatar
dist    
Mark Otto committed
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
    createClass(Popper, [{
      key: 'update',
      value: function update$$1() {
        return update.call(this);
      }
    }, {
      key: 'destroy',
      value: function destroy$$1() {
        return destroy.call(this);
      }
    }, {
      key: 'enableEventListeners',
      value: function enableEventListeners$$1() {
        return enableEventListeners.call(this);
      }
    }, {
      key: 'disableEventListeners',
      value: function disableEventListeners$$1() {
        return disableEventListeners.call(this);
      }
Mark Otto's avatar
dist  
Mark Otto committed
4573

Mark Otto's avatar
dist    
Mark Otto committed
4574
      /**
Mark Otto's avatar
dist    
Mark Otto committed
4575
       * Schedules an update. It will run on the next UI update available.
Mark Otto's avatar
dist    
Mark Otto committed
4576
4577
4578
       * @method scheduleUpdate
       * @memberof Popper
       */
Mark Otto's avatar
dist  
Mark Otto committed
4579
4580


Mark Otto's avatar
dist    
Mark Otto committed
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
      /**
       * Collection of utilities useful when writing custom modifiers.
       * Starting from version 1.7, this method is available only if you
       * include `popper-utils.js` before `popper.js`.
       *
       * **DEPRECATION**: This way to access PopperUtils is deprecated
       * and will be removed in v2! Use the PopperUtils module directly instead.
       * Due to the high instability of the methods contained in Utils, we can't
       * guarantee them to follow semver. Use them at your own risk!
       * @static
       * @private
       * @type {Object}
       * @deprecated since version 1.8
       * @member Utils
       * @memberof Popper
       */
Mark Otto's avatar
dist  
Mark Otto committed
4597

Mark Otto's avatar
dist    
Mark Otto committed
4598
4599
4600
    }]);
    return Popper;
  }();
Mark Otto's avatar
dist  
Mark Otto committed
4601
4602

  /**
Mark Otto's avatar
dist    
Mark Otto committed
4603
4604
4605
4606
4607
4608
4609
4610
4611
   * The `referenceObject` is an object that provides an interface compatible with Popper.js
   * and lets you use it as replacement of a real DOM node.<br />
   * You can use this method to position a popper relatively to a set of coordinates
   * in case you don't have a DOM node to use as reference.
   *
   * ```
   * new Popper(referenceObject, popperNode);
   * ```
   *
Mark Otto's avatar
dist    
Mark Otto committed
4612
   * NB: This feature isn't supported in Internet Explorer 10.
Mark Otto's avatar
dist    
Mark Otto committed
4613
4614
4615
4616
4617
4618
4619
   * @name referenceObject
   * @property {Function} data.getBoundingClientRect
   * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
   * @property {number} data.clientWidth
   * An ES6 getter that will return the width of the virtual reference element.
   * @property {number} data.clientHeight
   * An ES6 getter that will return the height of the virtual reference element.
Mark Otto's avatar
dist  
Mark Otto committed
4620
   */
Mark Otto's avatar
dist    
Mark Otto committed
4621
4622
4623
4624
4625
4626


  Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  Popper.placements = placements;
  Popper.Defaults = Defaults;

XhmikosR's avatar
Dist    
XhmikosR committed
4627
4628
4629
4630
4631
4632
4633
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$4 = 'dropdown';
XhmikosR's avatar
XhmikosR committed
4634
  var VERSION$4 = '5.0.0-alpha3';
XhmikosR's avatar
Dist    
XhmikosR committed
4635
4636
4637
  var DATA_KEY$4 = 'bs.dropdown';
  var EVENT_KEY$4 = "." + DATA_KEY$4;
  var DATA_API_KEY$4 = '.data-api';
XhmikosR's avatar
XhmikosR committed
4638
4639
4640
4641
4642
4643
4644
4645
  var ESCAPE_KEY = 'Escape';
  var SPACE_KEY = 'Space';
  var TAB_KEY = 'Tab';
  var ARROW_UP_KEY = 'ArrowUp';
  var ARROW_DOWN_KEY = 'ArrowDown';
  var RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button

  var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEY + "|" + ARROW_DOWN_KEY + "|" + ESCAPE_KEY);
XhmikosR's avatar
XhmikosR committed
4646
4647
4648
4649
4650
4651
4652
4653
  var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
  var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
  var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
  var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
  var EVENT_CLICK = "click" + EVENT_KEY$4;
  var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
  var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
  var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
XhmikosR's avatar
XhmikosR committed
4654
  var CLASS_NAME_DISABLED = 'disabled';
XhmikosR's avatar
XhmikosR committed
4655
4656
4657
4658
4659
4660
4661
  var CLASS_NAME_SHOW$1 = 'show';
  var CLASS_NAME_DROPUP = 'dropup';
  var CLASS_NAME_DROPRIGHT = 'dropright';
  var CLASS_NAME_DROPLEFT = 'dropleft';
  var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
  var CLASS_NAME_NAVBAR = 'navbar';
  var CLASS_NAME_POSITION_STATIC = 'position-static';
XhmikosR's avatar
XhmikosR committed
4662
  var SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="dropdown"]';
XhmikosR's avatar
XhmikosR committed
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
  var SELECTOR_FORM_CHILD = '.dropdown form';
  var SELECTOR_MENU = '.dropdown-menu';
  var SELECTOR_NAVBAR_NAV = '.navbar-nav';
  var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  var PLACEMENT_TOP = 'top-start';
  var PLACEMENT_TOPEND = 'top-end';
  var PLACEMENT_BOTTOM = 'bottom-start';
  var PLACEMENT_BOTTOMEND = 'bottom-end';
  var PLACEMENT_RIGHT = 'right-start';
  var PLACEMENT_LEFT = 'left-start';
XhmikosR's avatar
Dist    
XhmikosR committed
4673
4674
4675
4676
4677
  var Default$2 = {
    offset: 0,
    flip: true,
    boundary: 'scrollParent',
    reference: 'toggle',
XhmikosR's avatar
XhmikosR committed
4678
4679
    display: 'dynamic',
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
4680
4681
4682
4683
4684
4685
  };
  var DefaultType$2 = {
    offset: '(number|string|function)',
    flip: 'boolean',
    boundary: '(string|element)',
    reference: '(string|element)',
XhmikosR's avatar
XhmikosR committed
4686
4687
    display: 'string',
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
4688
  };
XhmikosR's avatar
XhmikosR committed
4689
4690
4691
4692
4693
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
4694

XhmikosR's avatar
XhmikosR committed
4695
  var Dropdown = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
4696
4697
4698
4699
4700
4701
    function Dropdown(element, config) {
      this._element = element;
      this._popper = null;
      this._config = this._getConfig(config);
      this._menu = this._getMenuElement();
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
dist    
Mark Otto committed
4702

XhmikosR's avatar
Dist    
XhmikosR committed
4703
      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
4704
4705

      Data.setData(element, DATA_KEY$4, this);
XhmikosR's avatar
Dist    
XhmikosR committed
4706
    } // Getters
Mark Otto's avatar
dist    
Mark Otto committed
4707

Mark Otto's avatar
dist  
Mark Otto committed
4708

XhmikosR's avatar
Dist    
XhmikosR committed
4709
    var _proto = Dropdown.prototype;
Mark Otto's avatar
dist  
Mark Otto committed
4710

XhmikosR's avatar
Dist    
XhmikosR committed
4711
4712
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
4713
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4714
4715
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
4716

XhmikosR's avatar
XhmikosR committed
4717
      var isActive = this._element.classList.contains(CLASS_NAME_SHOW$1);
Mark Otto's avatar
dist  
Mark Otto committed
4718

XhmikosR's avatar
XhmikosR committed
4719
      Dropdown.clearMenus();
Mark Otto's avatar
dist  
Mark Otto committed
4720

XhmikosR's avatar
Dist    
XhmikosR committed
4721
4722
4723
      if (isActive) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
4724

XhmikosR's avatar
XhmikosR committed
4725
4726
4727
4728
      this.show();
    };

    _proto.show = function show() {
XhmikosR's avatar
XhmikosR committed
4729
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
XhmikosR committed
4730
4731
4732
4733
        return;
      }

      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
4734
4735
4736
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
4737
      var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, relatedTarget);
Mark Otto's avatar
dist  
Mark Otto committed
4738

XhmikosR's avatar
XhmikosR committed
4739
      if (showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
4740
        return;
XhmikosR's avatar
XhmikosR committed
4741
      } // Totally disable Popper for Dropdowns in Navbar
Mark Otto's avatar
dist    
Mark Otto committed
4742

Mark Otto's avatar
dist  
Mark Otto committed
4743

XhmikosR's avatar
Dist    
XhmikosR committed
4744
4745
      if (!this._inNavbar) {
        if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
4746
          throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
Mark Otto's avatar
dist    
Mark Otto committed
4747
        }
Mark Otto's avatar
dist  
Mark Otto committed
4748

XhmikosR's avatar
Dist    
XhmikosR committed
4749
        var referenceElement = this._element;
Mark Otto's avatar
dist  
Mark Otto committed
4750

XhmikosR's avatar
Dist    
XhmikosR committed
4751
4752
        if (this._config.reference === 'parent') {
          referenceElement = parent;
XhmikosR's avatar
XhmikosR committed
4753
        } else if (isElement(this._config.reference)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4754
          referenceElement = this._config.reference; // Check if it's jQuery element
Mark Otto's avatar
dist    
Mark Otto committed
4755

XhmikosR's avatar
Dist    
XhmikosR committed
4756
4757
          if (typeof this._config.reference.jquery !== 'undefined') {
            referenceElement = this._config.reference[0];
Mark Otto's avatar
dist    
Mark Otto committed
4758
          }
XhmikosR's avatar
Dist    
XhmikosR committed
4759
4760
4761
        } // If boundary is not `scrollParent`, then set position to `static`
        // to allow the menu to "escape" the scroll parent's boundaries
        // https://github.com/twbs/bootstrap/issues/24251
Mark Otto's avatar
dist    
Mark Otto committed
4762

Mark Otto's avatar
dist    
Mark Otto committed
4763

XhmikosR's avatar
Dist    
XhmikosR committed
4764
        if (this._config.boundary !== 'scrollParent') {
XhmikosR's avatar
XhmikosR committed
4765
          parent.classList.add(CLASS_NAME_POSITION_STATIC);
XhmikosR's avatar
Dist    
XhmikosR committed
4766
        }
Mark Otto's avatar
dist    
Mark Otto committed
4767

XhmikosR's avatar
Dist    
XhmikosR committed
4768
4769
4770
4771
4772
        this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
      } // 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
Mark Otto's avatar
dist    
Mark Otto committed
4773

Mark Otto's avatar
dist    
Mark Otto committed
4774

XhmikosR's avatar
XhmikosR committed
4775
      if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
XhmikosR's avatar
XhmikosR committed
4776
4777
4778
        var _ref;

        (_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
4779
4780
          return EventHandler.on(elem, 'mouseover', null, noop());
        });
XhmikosR's avatar
Dist    
XhmikosR committed
4781
      }
Mark Otto's avatar
dist    
Mark Otto committed
4782

XhmikosR's avatar
Dist    
XhmikosR committed
4783
      this._element.focus();
Mark Otto's avatar
dist    
Mark Otto committed
4784

XhmikosR's avatar
Dist    
XhmikosR committed
4785
      this._element.setAttribute('aria-expanded', true);
Mark Otto's avatar
dist  
Mark Otto committed
4786

Mark Otto's avatar
Mark Otto committed
4787
4788
4789
4790
      this._menu.classList.toggle(CLASS_NAME_SHOW$1);

      this._element.classList.toggle(CLASS_NAME_SHOW$1);

XhmikosR's avatar
XhmikosR committed
4791
      EventHandler.trigger(parent, EVENT_SHOWN$1, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
4792
    };
Mark Otto's avatar
dist    
Mark Otto committed
4793

XhmikosR's avatar
Dist    
XhmikosR committed
4794
    _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
4795
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4796
4797
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
4798

XhmikosR's avatar
XhmikosR committed
4799
      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
4800
4801
4802
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
4803
      var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
4804

XhmikosR's avatar
XhmikosR committed
4805
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
4806
4807
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
4808

XhmikosR's avatar
XhmikosR committed
4809
4810
4811
4812
      if (this._popper) {
        this._popper.destroy();
      }

Mark Otto's avatar
Mark Otto committed
4813
4814
4815
4816
      this._menu.classList.toggle(CLASS_NAME_SHOW$1);

      this._element.classList.toggle(CLASS_NAME_SHOW$1);

XhmikosR's avatar
XhmikosR committed
4817
      EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
4818
    };
Mark Otto's avatar
dist  
Mark Otto committed
4819

XhmikosR's avatar
Dist    
XhmikosR committed
4820
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
4821
4822
      Data.removeData(this._element, DATA_KEY$4);
      EventHandler.off(this._element, EVENT_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
4823
4824
      this._element = null;
      this._menu = null;
Mark Otto's avatar
dist    
Mark Otto committed
4825

XhmikosR's avatar
XhmikosR committed
4826
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
4827
        this._popper.destroy();
Mark Otto's avatar
dist  
Mark Otto committed
4828

XhmikosR's avatar
Dist    
XhmikosR committed
4829
4830
4831
        this._popper = null;
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
4832

XhmikosR's avatar
Dist    
XhmikosR committed
4833
4834
    _proto.update = function update() {
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
dist    
Mark Otto committed
4835

XhmikosR's avatar
XhmikosR committed
4836
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
4837
4838
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
4839
4840
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
4841

XhmikosR's avatar
Dist    
XhmikosR committed
4842
4843
    _proto._addEventListeners = function _addEventListeners() {
      var _this = this;
Mark Otto's avatar
dist    
Mark Otto committed
4844

XhmikosR's avatar
XhmikosR committed
4845
      EventHandler.on(this._element, EVENT_CLICK, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
4846
4847
        event.preventDefault();
        event.stopPropagation();
Mark Otto's avatar
dist  
Mark Otto committed
4848

XhmikosR's avatar
Dist    
XhmikosR committed
4849
4850
4851
        _this.toggle();
      });
    };
Mark Otto's avatar
dist  
Mark Otto committed
4852

XhmikosR's avatar
Dist    
XhmikosR committed
4853
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
4854
      config = _extends({}, this.constructor.Default, Manipulator.getDataAttributes(this._element), config);
XhmikosR's avatar
XhmikosR committed
4855
      typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
4856
4857
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
4858

XhmikosR's avatar
Dist    
XhmikosR committed
4859
    _proto._getMenuElement = function _getMenuElement() {
XhmikosR's avatar
XhmikosR committed
4860
      return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
XhmikosR's avatar
Dist    
XhmikosR committed
4861
    };
Mark Otto's avatar
dist  
Mark Otto committed
4862

XhmikosR's avatar
Dist    
XhmikosR committed
4863
    _proto._getPlacement = function _getPlacement() {
XhmikosR's avatar
XhmikosR committed
4864
      var parentDropdown = this._element.parentNode;
XhmikosR's avatar
XhmikosR committed
4865
      var placement = PLACEMENT_BOTTOM; // Handle dropup
Mark Otto's avatar
dist  
Mark Otto committed
4866

XhmikosR's avatar
XhmikosR committed
4867
      if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
XhmikosR's avatar
XhmikosR committed
4868
        placement = this._menu.classList.contains(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP;
XhmikosR's avatar
XhmikosR committed
4869
4870
4871
4872
4873
4874
      } else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
        placement = PLACEMENT_RIGHT;
      } else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
        placement = PLACEMENT_LEFT;
      } else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
        placement = PLACEMENT_BOTTOMEND;
XhmikosR's avatar
Dist    
XhmikosR committed
4875
      }
Mark Otto's avatar
dist    
Mark Otto committed
4876

XhmikosR's avatar
Dist    
XhmikosR committed
4877
4878
      return placement;
    };
Mark Otto's avatar
dist    
Mark Otto committed
4879

XhmikosR's avatar
Dist    
XhmikosR committed
4880
    _proto._detectNavbar = function _detectNavbar() {
XhmikosR's avatar
XhmikosR committed
4881
      return Boolean(this._element.closest("." + CLASS_NAME_NAVBAR));
XhmikosR's avatar
Dist    
XhmikosR committed
4882
    };
Mark Otto's avatar
dist    
Mark Otto committed
4883

Mark Otto's avatar
Mark Otto committed
4884
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
Dist    
XhmikosR committed
4885
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
4886

Mark Otto's avatar
Mark Otto committed
4887
      var offset = {};
Mark Otto's avatar
dist    
Mark Otto committed
4888

XhmikosR's avatar
Dist    
XhmikosR committed
4889
      if (typeof this._config.offset === 'function') {
Mark Otto's avatar
Mark Otto committed
4890
        offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
4891
          data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
XhmikosR's avatar
Dist    
XhmikosR committed
4892
4893
4894
          return data;
        };
      } else {
Mark Otto's avatar
Mark Otto committed
4895
        offset.offset = this._config.offset;
XhmikosR's avatar
Dist    
XhmikosR committed
4896
      }
Mark Otto's avatar
dist    
Mark Otto committed
4897

Mark Otto's avatar
Mark Otto committed
4898
4899
4900
4901
      return offset;
    };

    _proto._getPopperConfig = function _getPopperConfig() {
XhmikosR's avatar
Dist    
XhmikosR committed
4902
4903
4904
      var popperConfig = {
        placement: this._getPlacement(),
        modifiers: {
Mark Otto's avatar
Mark Otto committed
4905
          offset: this._getOffset(),
XhmikosR's avatar
Dist    
XhmikosR committed
4906
4907
4908
4909
4910
          flip: {
            enabled: this._config.flip
          },
          preventOverflow: {
            boundariesElement: this._config.boundary
Mark Otto's avatar
dist    
Mark Otto committed
4911
          }
XhmikosR's avatar
XhmikosR committed
4912
        }
XhmikosR's avatar
XhmikosR committed
4913
      }; // Disable Popper if we have a static display
Mark Otto's avatar
dist    
Mark Otto committed
4914

XhmikosR's avatar
Dist    
XhmikosR committed
4915
4916
4917
4918
4919
      if (this._config.display === 'static') {
        popperConfig.modifiers.applyStyle = {
          enabled: false
        };
      }
Mark Otto's avatar
dist  
Mark Otto committed
4920

XhmikosR's avatar
XhmikosR committed
4921
      return _extends({}, popperConfig, this._config.popperConfig);
Mark Otto's avatar
Mark Otto committed
4922
4923
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
4924

XhmikosR's avatar
XhmikosR committed
4925
    Dropdown.dropdownInterface = function dropdownInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
4926
      var data = Data.getData(element, DATA_KEY$4);
Mark Otto's avatar
dist    
Mark Otto committed
4927

XhmikosR's avatar
XhmikosR committed
4928
      var _config = typeof config === 'object' ? config : null;
Mark Otto's avatar
dist  
Mark Otto committed
4929

XhmikosR's avatar
XhmikosR committed
4930
4931
4932
4933
4934
4935
      if (!data) {
        data = new Dropdown(element, _config);
      }

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
Dist.    
XhmikosR committed
4936
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist    
XhmikosR committed
4937
        }
Mark Otto's avatar
dist  
Mark Otto committed
4938

XhmikosR's avatar
XhmikosR committed
4939
4940
4941
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
4942

XhmikosR's avatar
XhmikosR committed
4943
    Dropdown.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
4944
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
4945
        Dropdown.dropdownInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
4946
4947
4948
      });
    };

XhmikosR's avatar
XhmikosR committed
4949
    Dropdown.clearMenus = function clearMenus(event) {
XhmikosR's avatar
XhmikosR committed
4950
      if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4951
4952
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
4953

XhmikosR's avatar
XhmikosR committed
4954
      var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2);
Mark Otto's avatar
dist  
Mark Otto committed
4955

XhmikosR's avatar
Dist    
XhmikosR committed
4956
      for (var i = 0, len = toggles.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
4957
        var parent = Dropdown.getParentFromElement(toggles[i]);
XhmikosR's avatar
XhmikosR committed
4958
        var context = Data.getData(toggles[i], DATA_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
4959
4960
4961
        var relatedTarget = {
          relatedTarget: toggles[i]
        };
Mark Otto's avatar
dist    
Mark Otto committed
4962

XhmikosR's avatar
Dist    
XhmikosR committed
4963
4964
4965
        if (event && event.type === 'click') {
          relatedTarget.clickEvent = event;
        }
Mark Otto's avatar
dist  
Mark Otto committed
4966

XhmikosR's avatar
Dist    
XhmikosR committed
4967
4968
        if (!context) {
          continue;
Mark Otto's avatar
dist  
Mark Otto committed
4969
4970
        }

XhmikosR's avatar
Dist    
XhmikosR committed
4971
        var dropdownMenu = context._menu;
Mark Otto's avatar
dist    
Mark Otto committed
4972

XhmikosR's avatar
XhmikosR committed
4973
        if (!toggles[i].classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4974
          continue;
Mark Otto's avatar
dist  
Mark Otto committed
4975
4976
        }

XhmikosR's avatar
XhmikosR committed
4977
        if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.key === TAB_KEY) && dropdownMenu.contains(event.target)) {
XhmikosR's avatar
Dist    
XhmikosR committed
4978
4979
          continue;
        }
Mark Otto's avatar
dist  
Mark Otto committed
4980

XhmikosR's avatar
XhmikosR committed
4981
        var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
4982

XhmikosR's avatar
XhmikosR committed
4983
        if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
4984
4985
4986
          continue;
        } // If this is a touch-enabled device we remove the extra
        // empty mouseover listeners we added for iOS support
Mark Otto's avatar
dist    
Mark Otto committed
4987
4988


XhmikosR's avatar
Dist    
XhmikosR committed
4989
        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
4990
4991
4992
          var _ref2;

          (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
4993
4994
            return EventHandler.off(elem, 'mouseover', null, noop());
          });
Mark Otto's avatar
dist  
Mark Otto committed
4995
4996
        }

XhmikosR's avatar
Dist    
XhmikosR committed
4997
        toggles[i].setAttribute('aria-expanded', 'false');
XhmikosR's avatar
XhmikosR committed
4998
4999
5000

        if (context._popper) {
          context._popper.destroy();
For faster browsing, not all history is shown. View entire blame