aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/dropdown.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
committerMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
commitbafbf0416462c6f18c3fb6c8c06a063c8d6fdae6 (patch)
tree8929845be585b09d0f420621281c5531e1efad3e /vendor/twbs/bootstrap/js/dist/dropdown.js
parent6f93d9848c43019d43ea76c27d42d657ba031cd7 (diff)
parentfdefa101d84dc2a9424eaedbdb003a4c30ec5d01 (diff)
downloadvolse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.gz
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.bz2
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.zip
Merge branch '5.0RC'5.0
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/dropdown.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/dropdown.js305
1 files changed, 124 insertions, 181 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/dropdown.js b/vendor/twbs/bootstrap/js/dist/dropdown.js
index 32aff75c1..f4c39b535 100644
--- a/vendor/twbs/bootstrap/js/dist/dropdown.js
+++ b/vendor/twbs/bootstrap/js/dist/dropdown.js
@@ -1,68 +1,23 @@
/*!
- * Bootstrap dropdown.js v4.3.1 (https://getbootstrap.com/)
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * Bootstrap dropdown.js v4.5.2 (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/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) :
typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) :
- (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;
-
- function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
- }
-
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
- }
-
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
- }
-
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- var ownKeys = Object.keys(source);
-
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
- }
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.jQuery, global.Popper, global.Util));
+}(this, (function ($, Popper, Util) { 'use strict';
- ownKeys.forEach(function (key) {
- _defineProperty(target, key, source[key]);
- });
- }
+ $ = $ && 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 _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
- return target;
- }
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/**
* ------------------------------------------------------------------------
* Constants
@@ -70,7 +25,7 @@
*/
var NAME = 'dropdown';
- var VERSION = '4.3.1';
+ var VERSION = '4.5.2';
var DATA_KEY = 'bs.dropdown';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -88,67 +43,55 @@
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,
boundary: 'scrollParent',
reference: 'toggle',
- display: 'dynamic'
+ display: 'dynamic',
+ popperConfig: null
};
var DefaultType = {
offset: '(number|string|function)',
flip: 'boolean',
boundary: '(string|element)',
reference: '(string|element)',
- display: 'string'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
-
+ display: 'string',
+ popperConfig: '(null|object)'
};
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
- var Dropdown =
- /*#__PURE__*/
- function () {
+ var Dropdown = /*#__PURE__*/function () {
function Dropdown(element, config) {
this._element = element;
this._popper = null;
@@ -164,13 +107,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 parent = Dropdown._getParentFromElement(this._element);
-
- var isActive = $(this._menu).hasClass(ClassName.SHOW);
+ var isActive = $(this._menu).hasClass(CLASS_NAME_SHOW);
Dropdown._clearMenus();
@@ -178,10 +119,25 @@
return;
}
+ this.show(true);
+ };
+
+ _proto.show = function show(usePopper) {
+ if (usePopper === void 0) {
+ usePopper = false;
+ }
+
+ 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);
+
$(parent).trigger(showEvent);
if (showEvent.isDefaultPrevented()) {
@@ -189,7 +145,7 @@
} // Disable totally Popper.js for Dropdown in Navbar
- if (!this._inNavbar) {
+ if (!this._inNavbar && usePopper) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
@@ -214,7 +170,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());
@@ -224,7 +180,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);
}
@@ -232,41 +188,19 @@
this._element.setAttribute('aria-expanded', true);
- $(this._menu).toggleClass(ClassName.SHOW);
- $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
- };
-
- _proto.show = function show() {
- if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED) || $(this._menu).hasClass(ClassName.SHOW)) {
- return;
- }
-
- var relatedTarget = {
- relatedTarget: this._element
- };
- var showEvent = $.Event(Event.SHOW, relatedTarget);
-
- var parent = Dropdown._getParentFromElement(this._element);
-
- $(parent).trigger(showEvent);
-
- if (showEvent.isDefaultPrevented()) {
- return;
- }
-
- $(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);
@@ -276,8 +210,12 @@
return;
}
- $(this._menu).toggleClass(ClassName.SHOW);
- $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
+ if (this._popper) {
+ this._popper.destroy();
+ }
+
+ $(this._menu).toggleClass(CLASS_NAME_SHOW);
+ $(parent).toggleClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget));
};
_proto.dispose = function dispose() {
@@ -305,7 +243,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();
@@ -314,7 +252,7 @@
};
_proto._getConfig = function _getConfig(config) {
- config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config);
+ config = _extends({}, this.constructor.Default, $(this._element).data(), config);
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
};
@@ -324,7 +262,7 @@
var parent = Dropdown._getParentFromElement(this._element);
if (parent) {
- this._menu = parent.querySelector(Selector.MENU);
+ this._menu = parent.querySelector(SELECTOR_MENU);
}
}
@@ -333,20 +271,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;
@@ -363,7 +297,7 @@
if (typeof this._config.offset === 'function') {
offset.fn = function (data) {
- data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
+ data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
return data;
};
} else {
@@ -384,9 +318,8 @@
preventOverflow: {
boundariesElement: this._config.boundary
}
- } // Disable Popper.js if we have a static display
-
- };
+ }
+ }; // Disable Popper.js if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers.applyStyle = {
@@ -394,7 +327,7 @@
};
}
- return popperConfig;
+ return _extends({}, popperConfig, this._config.popperConfig);
} // Static
;
@@ -424,7 +357,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]);
@@ -444,7 +377,7 @@
var dropdownMenu = context._menu;
- if (!$(parent).hasClass(ClassName.SHOW)) {
+ if (!$(parent).hasClass(CLASS_NAME_SHOW)) {
continue;
}
@@ -452,7 +385,7 @@
continue;
}
- var hideEvent = $.Event(Event.HIDE, relatedTarget);
+ var hideEvent = $.Event(EVENT_HIDE, relatedTarget);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
@@ -466,8 +399,13 @@
}
toggles[i].setAttribute('aria-expanded', 'false');
- $(dropdownMenu).removeClass(ClassName.SHOW);
- $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
+
+ if (context._popper) {
+ context._popper.destroy();
+ }
+
+ $(dropdownMenu).removeClass(CLASS_NAME_SHOW);
+ $(parent).removeClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget));
}
};
@@ -491,32 +429,37 @@
// - 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));
+ var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) {
+ return $(item).is(':visible');
+ });
if (items.length === 0) {
return;
@@ -567,12 +510,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();
});
/**
@@ -591,5 +534,5 @@
return Dropdown;
-}));
+})));
//# sourceMappingURL=dropdown.js.map