bootstrap.bundle.js 208 KB
Newer Older
Mark Otto's avatar
dist    
Mark Otto committed
3001
3002
    return data;
  }
Mark Otto's avatar
dist  
Mark Otto committed
3003
3004

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3005
3006
3007
3008
3009
   * @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
Mark Otto's avatar
dist  
Mark Otto committed
3010
   */
Mark Otto's avatar
dist    
Mark Otto committed
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
  function keepTogether(data) {
    var _data$offsets = data.offsets,
        popper = _data$offsets.popper,
        reference = _data$offsets.reference;

    var placement = data.placement.split('-')[0];
    var floor = Math.floor;
    var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
    var side = isVertical ? 'right' : 'bottom';
    var opSide = isVertical ? 'left' : 'top';
    var measurement = isVertical ? 'width' : 'height';

    if (popper[side] < floor(reference[opSide])) {
      data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
    }
    if (popper[opSide] > floor(reference[side])) {
      data.offsets.popper[opSide] = floor(reference[side]);
    }

    return data;
  }
Mark Otto's avatar
dist  
Mark Otto committed
3032
3033

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
   * Converts a string containing value + unit into a px value number
   * @function
   * @memberof {modifiers~offset}
   * @private
   * @argument {String} str - Value + unit string
   * @argument {String} measurement - `height` or `width`
   * @argument {Object} popperOffsets
   * @argument {Object} referenceOffsets
   * @returns {Number|String}
   * Value in pixels, or original string if no values were extracted
Mark Otto's avatar
dist  
Mark Otto committed
3044
   */
Mark Otto's avatar
dist    
Mark Otto committed
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
  function toValue(str, measurement, popperOffsets, referenceOffsets) {
    // separate value from unit
    var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
    var value = +split[1];
    var unit = split[2];

    // If it's not a number it's an operator, I guess
    if (!value) {
      return str;
    }

    if (unit.indexOf('%') === 0) {
      var element = void 0;
      switch (unit) {
        case '%p':
          element = popperOffsets;
          break;
        case '%':
        case '%r':
        default:
          element = referenceOffsets;
      }

      var rect = getClientRect(element);
      return rect[measurement] / 100 * value;
    } else if (unit === 'vh' || unit === 'vw') {
      // if is a vh or vw, we calculate the size based on the viewport
      var size = void 0;
      if (unit === 'vh') {
        size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
      } else {
        size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
      }
      return size / 100 * value;
    } else {
      // if is an explicit pixel unit, we get rid of the unit and keep the value
      // if is an implicit unit, it's px, and we return just the value
      return value;
    }
  }
Mark Otto's avatar
dist  
Mark Otto committed
3085
3086

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3087
3088
3089
3090
3091
3092
3093
3094
3095
   * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
   * @function
   * @memberof {modifiers~offset}
   * @private
   * @argument {String} offset
   * @argument {Object} popperOffsets
   * @argument {Object} referenceOffsets
   * @argument {String} basePlacement
   * @returns {Array} a two cells array with x and y offsets in numbers
Mark Otto's avatar
dist  
Mark Otto committed
3096
   */
Mark Otto's avatar
dist    
Mark Otto committed
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
  function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
    var offsets = [0, 0];

    // Use height if placement is left or right and index is 0 otherwise use width
    // in this way the first offset will use an axis and the second one
    // will use the other one
    var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;

    // Split the offset string to obtain a list of values and operands
    // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
    var fragments = offset.split(/(\+|\-)/).map(function (frag) {
      return frag.trim();
    });

    // Detect if the offset string contains a pair of values or a single one
    // they could be separated by comma or space
    var divider = fragments.indexOf(find(fragments, function (frag) {
      return frag.search(/,|\s/) !== -1;
    }));

    if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
      console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
    }

    // If divider is found, we divide the list of values and operands to divide
    // them by ofset X and Y.
    var splitRegex = /\s*,\s*|\s+/;
    var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];

    // Convert the values with units to absolute pixels to allow our computations
    ops = ops.map(function (op, index) {
      // Most of the units rely on the orientation of the popper
      var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
      var mergeWithPrevious = false;
      return op
      // This aggregates any `+` or `-` sign that aren't considered operators
      // e.g.: 10 + +5 => [10, +, +5]
      .reduce(function (a, b) {
        if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
          a[a.length - 1] = b;
          mergeWithPrevious = true;
          return a;
        } else if (mergeWithPrevious) {
          a[a.length - 1] += b;
          mergeWithPrevious = false;
          return a;
        } else {
          return a.concat(b);
        }
      }, [])
      // Here we convert the string values into number values (in px)
      .map(function (str) {
        return toValue(str, measurement, popperOffsets, referenceOffsets);
      });
    });

    // Loop trough the offsets arrays and execute the operations
    ops.forEach(function (op, index) {
      op.forEach(function (frag, index2) {
        if (isNumeric(frag)) {
          offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
        }
      });
    });
    return offsets;
  }
Mark Otto's avatar
dist  
Mark Otto committed
3163
3164

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3165
3166
3167
3168
3169
3170
3171
   * @function
   * @memberof Modifiers
   * @argument {Object} data - The data object generated by update method
   * @argument {Object} options - Modifiers configuration and options
   * @argument {Number|String} options.offset=0
   * The offset value as described in the modifier description
   * @returns {Object} The data object, properly modified
Mark Otto's avatar
dist  
Mark Otto committed
3172
   */
Mark Otto's avatar
dist    
Mark Otto committed
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
  function offset(data, _ref) {
    var offset = _ref.offset;
    var placement = data.placement,
        _data$offsets = data.offsets,
        popper = _data$offsets.popper,
        reference = _data$offsets.reference;

    var basePlacement = placement.split('-')[0];

    var offsets = void 0;
    if (isNumeric(+offset)) {
      offsets = [+offset, 0];
    } else {
      offsets = parseOffset(offset, popper, reference, basePlacement);
    }

    if (basePlacement === 'left') {
      popper.top += offsets[0];
      popper.left -= offsets[1];
    } else if (basePlacement === 'right') {
      popper.top += offsets[0];
      popper.left += offsets[1];
    } else if (basePlacement === 'top') {
      popper.left += offsets[0];
      popper.top -= offsets[1];
    } else if (basePlacement === 'bottom') {
      popper.left += offsets[0];
      popper.top += offsets[1];
    }

    data.popper = popper;
    return data;
  }
Mark Otto's avatar
dist  
Mark Otto committed
3206
3207

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
   * @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 preventOverflow(data, options) {
    var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);

    // If offsetParent is the reference element, we really want to
    // go one step up and use the next offsetParent as reference to
    // avoid to make this modifier completely useless and look like broken
    if (data.instance.reference === boundariesElement) {
      boundariesElement = getOffsetParent(boundariesElement);
    }

Mark Otto's avatar
dist    
Mark Otto committed
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
    // NOTE: DOM access here
    // resets the popper's position so that the document size can be calculated excluding
    // the size of the popper element itself
    var transformProp = getSupportedPropertyName('transform');
    var popperStyles = data.instance.popper.style; // assignment to help minification
    var top = popperStyles.top,
        left = popperStyles.left,
        transform = popperStyles[transformProp];

    popperStyles.top = '';
    popperStyles.left = '';
    popperStyles[transformProp] = '';

Mark Otto's avatar
dist    
Mark Otto committed
3237
    var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
Mark Otto's avatar
dist    
Mark Otto committed
3238
3239
3240
3241
3242
3243
3244

    // NOTE: DOM access here
    // restores the original style properties after the offsets have been computed
    popperStyles.top = top;
    popperStyles.left = left;
    popperStyles[transformProp] = transform;

Mark Otto's avatar
dist    
Mark Otto committed
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
    options.boundaries = boundaries;

    var order = options.priority;
    var popper = data.offsets.popper;

    var check = {
      primary: function primary(placement) {
        var value = popper[placement];
        if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
          value = Math.max(popper[placement], boundaries[placement]);
        }
        return defineProperty({}, placement, value);
      },
      secondary: function secondary(placement) {
        var mainSide = placement === 'right' ? 'left' : 'top';
        var value = popper[mainSide];
        if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
          value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
        }
        return defineProperty({}, mainSide, value);
      }
    };

    order.forEach(function (placement) {
      var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
      popper = _extends({}, popper, check[side](placement));
    });

    data.offsets.popper = popper;

    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 shift(data) {
    var placement = data.placement;
    var basePlacement = placement.split('-')[0];
    var shiftvariation = placement.split('-')[1];

    // if shift shiftvariation is specified, run the modifier
    if (shiftvariation) {
      var _data$offsets = data.offsets,
          reference = _data$offsets.reference,
          popper = _data$offsets.popper;

      var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
      var side = isVertical ? 'left' : 'top';
      var measurement = isVertical ? 'width' : 'height';

      var shiftOffsets = {
        start: defineProperty({}, side, reference[side]),
        end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
      };

      data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
    }

    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 hide(data) {
    if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
      return data;
    }

    var refRect = data.offsets.reference;
    var bound = find(data.instance.modifiers, function (modifier) {
      return modifier.name === 'preventOverflow';
    }).boundaries;

    if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
      // Avoid unnecessary DOM access if visibility hasn't changed
      if (data.hide === true) {
        return data;
      }

      data.hide = true;
      data.attributes['x-out-of-boundaries'] = '';
    } else {
      // Avoid unnecessary DOM access if visibility hasn't changed
      if (data.hide === false) {
        return data;
      }

      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
3380
   *
Mark Otto's avatar
dist    
Mark Otto committed
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
   * @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
3391
   *
Mark Otto's avatar
dist    
Mark Otto committed
3392
3393
3394
   * 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
3395
   */
Mark Otto's avatar
dist    
Mark Otto committed
3396
  var modifiers = {
Mark Otto's avatar
dist  
Mark Otto committed
3397
    /**
Mark Otto's avatar
dist    
Mark Otto committed
3398
3399
3400
3401
3402
3403
     * 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
3404
     */
Mark Otto's avatar
dist    
Mark Otto committed
3405
3406
3407
3408
3409
3410
3411
3412
3413
    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
3414
    /**
Mark Otto's avatar
dist    
Mark Otto committed
3415
3416
3417
     * The `offset` modifier can shift your popper on both its axis.
     *
     * It accepts the following units:
Mark Otto's avatar
dist    
Mark Otto committed
3418
     * - `px` or unit-less, interpreted as pixels
Mark Otto's avatar
dist    
Mark Otto committed
3419
3420
3421
3422
3423
3424
3425
     * - `%` 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
3426
     * `width`. In case of `left` or `right`, it will be the `height`.
Mark Otto's avatar
dist    
Mark Otto committed
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
     *
     * 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
3447
     * > 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
3448
3449
3450
     *
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
3451
     */
Mark Otto's avatar
dist    
Mark Otto committed
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
    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
3465
    /**
Mark Otto's avatar
dist    
Mark Otto committed
3466
3467
     * Modifier used to prevent the popper from being positioned outside the boundary.
     *
Mark Otto's avatar
dist    
Mark Otto committed
3468
     * A scenario exists where the reference itself is not within the boundaries.<br />
Mark Otto's avatar
dist    
Mark Otto committed
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
     * 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
3481
     */
Mark Otto's avatar
dist    
Mark Otto committed
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
    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
3498
       * and the popper. This makes sure the popper always has a little padding
Mark Otto's avatar
dist    
Mark Otto committed
3499
3500
3501
3502
3503
       * between the edges of its container
       */
      padding: 5,
      /**
       * @prop {String|HTMLElement} boundariesElement='scrollParent'
Mark Otto's avatar
dist    
Mark Otto committed
3504
       * Boundaries used by the modifier. Can be `scrollParent`, `window`,
Mark Otto's avatar
dist    
Mark Otto committed
3505
3506
3507
3508
       * `viewport` or any DOM element.
       */
      boundariesElement: 'scrollParent'
    },
Mark Otto's avatar
dist  
Mark Otto committed
3509
3510

    /**
Mark Otto's avatar
dist    
Mark Otto committed
3511
3512
3513
3514
     * 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
3515
3516
3517
     * between the popper and its reference element.
     * @memberof modifiers
     * @inner
Mark Otto's avatar
dist  
Mark Otto committed
3518
     */
Mark Otto's avatar
dist    
Mark Otto committed
3519
3520
3521
3522
3523
3524
3525
3526
    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
3527

Mark Otto's avatar
dist    
Mark Otto committed
3528
3529
3530
3531
    /**
     * 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
3532
     * pixels of conjunction are needed.
Mark Otto's avatar
dist    
Mark Otto committed
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
     *
     * 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
3548

Mark Otto's avatar
dist    
Mark Otto committed
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
    /**
     * 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
3571
       * placements (with optional variations)
Mark Otto's avatar
dist    
Mark Otto committed
3572
3573
3574
3575
3576
3577
3578
3579
3580
       */
      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
3581
3582
3583
       * 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
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
       */
      boundariesElement: 'viewport'
    },

    /**
     * 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
3647
3648
       * 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
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
       */
      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
3675
     * Just disable this modifier and define your own to achieve the desired effect.
Mark Otto's avatar
dist    
Mark Otto committed
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
     *
     * @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
3692
3693
       * 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
3694
3695
3696
3697
       */
      gpuAcceleration: undefined
    }
  };
Mark Otto's avatar
dist  
Mark Otto committed
3698
3699

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3700
3701
   * 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
3702
3703
3704
3705
3706
   * @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
3707
   * @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
3708
   * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
Mark Otto's avatar
dist    
Mark Otto committed
3709
3710
   * @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
3711
   * @property {Object} data.boundaries Offsets of the popper boundaries
Mark Otto's avatar
dist    
Mark Otto committed
3712
   * @property {Object} data.offsets The measurements of popper, reference and arrow elements
Mark Otto's avatar
dist    
Mark Otto committed
3713
3714
3715
   * @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
3716
3717
3718
   */

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3719
   * Default options provided to Popper.js constructor.<br />
Mark Otto's avatar
dist    
Mark Otto committed
3720
3721
3722
   * 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
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
   * ```
   * new Popper(ref, pop, {
   *   modifiers: {
   *     preventOverflow: { enabled: false }
   *   }
   * })
   * ```
   * @type {Object}
   * @static
   * @memberof Popper
Mark Otto's avatar
dist  
Mark Otto committed
3733
   */
Mark Otto's avatar
dist    
Mark Otto committed
3734
3735
  var Defaults = {
    /**
Mark Otto's avatar
dist    
Mark Otto committed
3736
     * Popper's placement.
Mark Otto's avatar
dist    
Mark Otto committed
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
     * @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
3748
     * Whether events (resize, scroll) are initially enabled.
Mark Otto's avatar
dist    
Mark Otto committed
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
     * @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
3762
     * By default, it is set to no-op.<br />
Mark Otto's avatar
dist    
Mark Otto committed
3763
3764
3765
3766
3767
3768
     * Access Popper.js instance with `data.instance`.
     * @prop {onCreate}
     */
    onCreate: function onCreate() {},

    /**
Mark Otto's avatar
dist    
Mark Otto committed
3769
     * Callback called when the popper is updated. This callback is not called
Mark Otto's avatar
dist    
Mark Otto committed
3770
3771
     * on the initialization/creation of the popper, but only on subsequent
     * updates.<br />
Mark Otto's avatar
dist    
Mark Otto committed
3772
     * By default, it is set to no-op.<br />
Mark Otto's avatar
dist    
Mark Otto committed
3773
3774
3775
3776
3777
3778
3779
     * 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
3780
     * They provide most of the functionalities of Popper.js.
Mark Otto's avatar
dist    
Mark Otto committed
3781
3782
3783
3784
     * @prop {modifiers}
     */
    modifiers: modifiers
  };
Mark Otto's avatar
dist  
Mark Otto committed
3785
3786

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3787
3788
   * @callback onCreate
   * @param {dataObject} data
Mark Otto's avatar
dist  
Mark Otto committed
3789
   */
Mark Otto's avatar
dist    
Mark Otto committed
3790

Mark Otto's avatar
dist  
Mark Otto committed
3791
  /**
Mark Otto's avatar
dist    
Mark Otto committed
3792
3793
   * @callback onUpdate
   * @param {dataObject} data
Mark Otto's avatar
dist  
Mark Otto committed
3794
3795
   */

Mark Otto's avatar
dist    
Mark Otto committed
3796
3797
3798
3799
  // Utils
  // Methods
  var Popper = function () {
    /**
Mark Otto's avatar
dist    
Mark Otto committed
3800
     * Creates a new Popper.js instance.
Mark Otto's avatar
dist    
Mark Otto committed
3801
3802
     * @class Popper
     * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper
Mark Otto's avatar
dist    
Mark Otto committed
3803
     * @param {HTMLElement} popper - The HTML element used as the popper
Mark Otto's avatar
dist    
Mark Otto committed
3804
3805
3806
3807
3808
3809
3810
3811
     * @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
3812

Mark Otto's avatar
dist    
Mark Otto committed
3813
3814
3815
      this.scheduleUpdate = function () {
        return requestAnimationFrame(_this.update);
      };
Mark Otto's avatar
dist  
Mark Otto committed
3816

Mark Otto's avatar
dist    
Mark Otto committed
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
      // 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
      this.options = _extends({}, Popper.Defaults, options);

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

Mark Otto's avatar
dist    
Mark Otto committed
3830
3831
3832
      // 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
3833

Mark Otto's avatar
dist    
Mark Otto committed
3834
3835
3836
3837
3838
      // Deep merge modifiers options
      this.options.modifiers = {};
      Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
        _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
      });
Mark Otto's avatar
dist  
Mark Otto committed
3839

Mark Otto's avatar
dist    
Mark Otto committed
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
      // Refactoring modifiers' list (Object => Array)
      this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
        return _extends({
          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
3850

Mark Otto's avatar
dist    
Mark Otto committed
3851
3852
3853
3854
3855
3856
3857
3858
3859
      // 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
3860

Mark Otto's avatar
dist    
Mark Otto committed
3861
3862
      // fire the first update to position the popper in the right place
      this.update();
Mark Otto's avatar
dist  
Mark Otto committed
3863

Mark Otto's avatar
dist    
Mark Otto committed
3864
3865
3866
3867
      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
3868
3869
      }

Mark Otto's avatar
dist    
Mark Otto committed
3870
      this.state.eventsEnabled = eventsEnabled;
Mark Otto's avatar
dist  
Mark Otto committed
3871
3872
    }

Mark Otto's avatar
dist    
Mark Otto committed
3873
3874
    // 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
3875
3876


Mark Otto's avatar
dist    
Mark Otto committed
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
    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
3897

Mark Otto's avatar
dist    
Mark Otto committed
3898
      /**
Mark Otto's avatar
dist    
Mark Otto committed
3899
       * Schedules an update. It will run on the next UI update available.
Mark Otto's avatar
dist    
Mark Otto committed
3900
3901
3902
       * @method scheduleUpdate
       * @memberof Popper
       */
Mark Otto's avatar
dist  
Mark Otto committed
3903
3904


Mark Otto's avatar
dist    
Mark Otto committed
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
      /**
       * 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
3921

Mark Otto's avatar
dist    
Mark Otto committed
3922
3923
3924
    }]);
    return Popper;
  }();
Mark Otto's avatar
dist  
Mark Otto committed
3925
3926

  /**
Mark Otto's avatar
dist    
Mark Otto committed
3927
3928
3929
3930
3931
3932
3933
3934
3935
   * 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
3936
   * NB: This feature isn't supported in Internet Explorer 10.
Mark Otto's avatar
dist    
Mark Otto committed
3937
3938
3939
3940
3941
3942
3943
   * @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
3944
   */
Mark Otto's avatar
dist    
Mark Otto committed
3945
3946
3947
3948
3949
3950
3951
3952


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

  /**
   * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
3953
   * Bootstrap (v4.1.3): dropdown.js
Mark Otto's avatar
dist    
Mark Otto committed
3954
3955
3956
3957
3958
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */

  var Dropdown = function ($$$1) {
Mark Otto's avatar
dist    
Mark Otto committed
3959
3960
    /**
     * ------------------------------------------------------------------------
Mark Otto's avatar
dist    
Mark Otto committed
3961
     * Constants
Mark Otto's avatar
dist    
Mark Otto committed
3962
3963
     * ------------------------------------------------------------------------
     */
Mark Otto's avatar
dist    
Mark Otto committed
3964
    var NAME = 'dropdown';
Mark Otto's avatar
Mark Otto committed
3965
    var VERSION = '4.1.3';
Mark Otto's avatar
dist    
Mark Otto committed
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
    var DATA_KEY = 'bs.dropdown';
    var EVENT_KEY = "." + DATA_KEY;
    var DATA_API_KEY = '.data-api';
    var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
    var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key

    var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key

    var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key

    var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key

    var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key

    var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)

    var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
    var Event = {
      HIDE: "hide" + EVENT_KEY,
      HIDDEN: "hidden" + EVENT_KEY,
      SHOW: "show" + EVENT_KEY,
      SHOWN: "shown" + EVENT_KEY,
      CLICK: "click" + EVENT_KEY,
      CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
      KEYDOWN_DATA_API: "keydown" + EVENT_KEY + DATA_API_KEY,
      KEYUP_DATA_API: "keyup" + EVENT_KEY + DATA_API_KEY
    };
    var ClassName = {
      DISABLED: 'disabled',
      SHOW: 'show',
      DROPUP: 'dropup',
      DROPRIGHT: 'dropright',
      DROPLEFT: 'dropleft',
      MENURIGHT: 'dropdown-menu-right',
      MENULEFT: 'dropdown-menu-left',
For faster browsing, not all history is shown. View entire blame