aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/dropdown.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-06-13 10:00:50 +0000
committerMario <mario@mariovavti.com>2020-06-13 10:00:50 +0000
commitdc3b09c8f38872ef8b792a4b551671a6105754cc (patch)
tree554f130cc2d5a00088cad6c9a75ae0a8f2d558f8 /vendor/twbs/bootstrap/js/dist/dropdown.js
parentc8c4513af98a9dd2a6d9331ba4b3ab3af0e95a5f (diff)
downloadvolse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.tar.gz
volse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.tar.bz2
volse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.zip
composer update bootstrap
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/dropdown.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/dropdown.js168
1 files changed, 75 insertions, 93 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/dropdown.js b/vendor/twbs/bootstrap/js/dist/dropdown.js
index 3557cecba..290b64b49 100644
--- a/vendor/twbs/bootstrap/js/dist/dropdown.js
+++ b/vendor/twbs/bootstrap/js/dist/dropdown.js
@@ -1,6 +1,6 @@
/*!
- * Bootstrap dropdown.js v4.4.1 (https://getbootstrap.com/)
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Bootstrap dropdown.js v4.5.0 (https://getbootstrap.com/)
+ * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
(function (global, factory) {
@@ -9,9 +9,9 @@
(global = global || self, global.Dropdown = factory(global.jQuery, global.Popper, global.Util));
}(this, (function ($, Popper, Util) { 'use strict';
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
- Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
+ $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
+ Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
+ Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util;
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@@ -85,7 +85,7 @@
*/
var NAME = 'dropdown';
- var VERSION = '4.4.1';
+ var VERSION = '4.5.0';
var DATA_KEY = 'bs.dropdown';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -103,43 +103,32 @@
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',
- POSITION_STATIC: 'position-static'
- };
- var Selector = {
- DATA_TOGGLE: '[data-toggle="dropdown"]',
- FORM_CHILD: '.dropdown form',
- MENU: '.dropdown-menu',
- NAVBAR_NAV: '.navbar-nav',
- VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
- };
- var AttachmentMap = {
- TOP: 'top-start',
- TOPEND: 'top-end',
- BOTTOM: 'bottom-start',
- BOTTOMEND: 'bottom-end',
- RIGHT: 'right-start',
- RIGHTEND: 'right-end',
- LEFT: 'left-start',
- LEFTEND: 'left-end'
- };
+ var EVENT_HIDE = "hide" + EVENT_KEY;
+ var EVENT_HIDDEN = "hidden" + EVENT_KEY;
+ var EVENT_SHOW = "show" + EVENT_KEY;
+ var EVENT_SHOWN = "shown" + EVENT_KEY;
+ var EVENT_CLICK = "click" + EVENT_KEY;
+ var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
+ var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY + DATA_API_KEY;
+ var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY + DATA_API_KEY;
+ var CLASS_NAME_DISABLED = 'disabled';
+ var CLASS_NAME_SHOW = '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_POSITION_STATIC = 'position-static';
+ var SELECTOR_DATA_TOGGLE = '[data-toggle="dropdown"]';
+ 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';
var Default = {
offset: 0,
flip: true,
@@ -162,9 +151,7 @@
* ------------------------------------------------------------------------
*/
- var Dropdown =
- /*#__PURE__*/
- function () {
+ var Dropdown = /*#__PURE__*/function () {
function Dropdown(element, config) {
this._element = element;
this._popper = null;
@@ -180,11 +167,11 @@
// Public
_proto.toggle = function toggle() {
- if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
+ if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED)) {
return;
}
- var isActive = $(this._menu).hasClass(ClassName.SHOW);
+ var isActive = $(this._menu).hasClass(CLASS_NAME_SHOW);
Dropdown._clearMenus();
@@ -200,14 +187,14 @@
usePopper = false;
}
- if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) {
+ if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || $(this._menu).hasClass(CLASS_NAME_SHOW)) {
return;
}
var relatedTarget = {
relatedTarget: this._element
};
- var showEvent = $.Event(Event.SHOW, relatedTarget);
+ var showEvent = $.Event(EVENT_SHOW, relatedTarget);
var parent = Dropdown._getParentFromElement(this._element);
@@ -243,7 +230,7 @@
if (this._config.boundary !== 'scrollParent') {
- $(parent).addClass(ClassName.POSITION_STATIC);
+ $(parent).addClass(CLASS_NAME_POSITION_STATIC);
}
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
@@ -253,7 +240,7 @@
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
- if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) {
+ if ('ontouchstart' in document.documentElement && $(parent).closest(SELECTOR_NAVBAR_NAV).length === 0) {
$(document.body).children().on('mouseover', null, $.noop);
}
@@ -261,19 +248,19 @@
this._element.setAttribute('aria-expanded', true);
- $(this._menu).toggleClass(ClassName.SHOW);
- $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
+ $(this._menu).toggleClass(CLASS_NAME_SHOW);
+ $(parent).toggleClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_SHOWN, relatedTarget));
};
_proto.hide = function hide() {
- if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || !$(this._menu).hasClass(ClassName.SHOW)) {
+ if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || !$(this._menu).hasClass(CLASS_NAME_SHOW)) {
return;
}
var relatedTarget = {
relatedTarget: this._element
};
- var hideEvent = $.Event(Event.HIDE, relatedTarget);
+ var hideEvent = $.Event(EVENT_HIDE, relatedTarget);
var parent = Dropdown._getParentFromElement(this._element);
@@ -287,8 +274,8 @@
this._popper.destroy();
}
- $(this._menu).toggleClass(ClassName.SHOW);
- $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
+ $(this._menu).toggleClass(CLASS_NAME_SHOW);
+ $(parent).toggleClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget));
};
_proto.dispose = function dispose() {
@@ -316,7 +303,7 @@
_proto._addEventListeners = function _addEventListeners() {
var _this = this;
- $(this._element).on(Event.CLICK, function (event) {
+ $(this._element).on(EVENT_CLICK, function (event) {
event.preventDefault();
event.stopPropagation();
@@ -325,7 +312,7 @@
};
_proto._getConfig = function _getConfig(config) {
- config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
+ config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), $(this._element).data()), config);
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
};
@@ -335,7 +322,7 @@
var parent = Dropdown._getParentFromElement(this._element);
if (parent) {
- this._menu = parent.querySelector(Selector.MENU);
+ this._menu = parent.querySelector(SELECTOR_MENU);
}
}
@@ -344,20 +331,16 @@
_proto._getPlacement = function _getPlacement() {
var $parentDropdown = $(this._element.parentNode);
- var placement = AttachmentMap.BOTTOM; // Handle dropup
-
- if ($parentDropdown.hasClass(ClassName.DROPUP)) {
- placement = AttachmentMap.TOP;
-
- if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
- placement = AttachmentMap.TOPEND;
- }
- } else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) {
- placement = AttachmentMap.RIGHT;
- } else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) {
- placement = AttachmentMap.LEFT;
- } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
- placement = AttachmentMap.BOTTOMEND;
+ var placement = PLACEMENT_BOTTOM; // Handle dropup
+
+ if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) {
+ placement = $(this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP;
+ } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) {
+ placement = PLACEMENT_RIGHT;
+ } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) {
+ placement = PLACEMENT_LEFT;
+ } else if ($(this._menu).hasClass(CLASS_NAME_MENURIGHT)) {
+ placement = PLACEMENT_BOTTOMEND;
}
return placement;
@@ -374,7 +357,7 @@
if (typeof this._config.offset === 'function') {
offset.fn = function (data) {
- data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
+ data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this2._config.offset(data.offsets, _this2._element) || {});
return data;
};
} else {
@@ -404,7 +387,7 @@
};
}
- return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
+ return _objectSpread2(_objectSpread2({}, popperConfig), this._config.popperConfig);
} // Static
;
@@ -434,7 +417,7 @@
return;
}
- var toggles = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE));
+ var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE));
for (var i = 0, len = toggles.length; i < len; i++) {
var parent = Dropdown._getParentFromElement(toggles[i]);
@@ -454,7 +437,7 @@
var dropdownMenu = context._menu;
- if (!$(parent).hasClass(ClassName.SHOW)) {
+ if (!$(parent).hasClass(CLASS_NAME_SHOW)) {
continue;
}
@@ -462,7 +445,7 @@
continue;
}
- var hideEvent = $.Event(Event.HIDE, relatedTarget);
+ var hideEvent = $.Event(EVENT_HIDE, relatedTarget);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
@@ -481,8 +464,8 @@
context._popper.destroy();
}
- $(dropdownMenu).removeClass(ClassName.SHOW);
- $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
+ $(dropdownMenu).removeClass(CLASS_NAME_SHOW);
+ $(parent).removeClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget));
}
};
@@ -506,36 +489,35 @@
// - If key is other than escape
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
- if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
+ if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
return;
}
- event.preventDefault();
- event.stopPropagation();
-
- if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
+ if (this.disabled || $(this).hasClass(CLASS_NAME_DISABLED)) {
return;
}
var parent = Dropdown._getParentFromElement(this);
- var isActive = $(parent).hasClass(ClassName.SHOW);
+ var isActive = $(parent).hasClass(CLASS_NAME_SHOW);
if (!isActive && event.which === ESCAPE_KEYCODE) {
return;
}
+ event.preventDefault();
+ event.stopPropagation();
+
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
- var toggle = parent.querySelector(Selector.DATA_TOGGLE);
- $(toggle).trigger('focus');
+ $(parent.querySelector(SELECTOR_DATA_TOGGLE)).trigger('focus');
}
$(this).trigger('click');
return;
}
- var items = [].slice.call(parent.querySelectorAll(Selector.VISIBLE_ITEMS)).filter(function (item) {
+ var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) {
return $(item).is(':visible');
});
@@ -588,12 +570,12 @@
*/
- $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + " " + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
+ $(document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown._jQueryInterface.call($(this), 'toggle');
- }).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
+ }).on(EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, function (e) {
e.stopPropagation();
});
/**