Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap/dropdown.js')
-rw-r--r--assets/javascripts/bootstrap/dropdown.js50
1 files changed, 34 insertions, 16 deletions
diff --git a/assets/javascripts/bootstrap/dropdown.js b/assets/javascripts/bootstrap/dropdown.js
index a4f73fe..9a81783 100644
--- a/assets/javascripts/bootstrap/dropdown.js
+++ b/assets/javascripts/bootstrap/dropdown.js
@@ -1,4 +1,6 @@
-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); }
+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; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
+
+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 _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); } }
@@ -6,7 +8,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0): dropdown.js
+ * Bootstrap (v4.1.0): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -17,7 +19,7 @@ var Dropdown = function ($) {
* ------------------------------------------------------------------------
*/
var NAME = 'dropdown';
- var VERSION = '4.0.0';
+ var VERSION = '4.1.0';
var DATA_KEY = 'bs.dropdown';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -60,7 +62,7 @@ var Dropdown = function ($) {
FORM_CHILD: '.dropdown form',
MENU: '.dropdown-menu',
NAVBAR_NAV: '.navbar-nav',
- VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled)'
+ VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
};
var AttachmentMap = {
TOP: 'top-start',
@@ -75,12 +77,16 @@ var Dropdown = function ($) {
var Default = {
offset: 0,
flip: true,
- boundary: 'scrollParent'
+ boundary: 'scrollParent',
+ reference: 'toggle',
+ display: 'dynamic'
};
var DefaultType = {
offset: '(number|string|function)',
flip: 'boolean',
- boundary: '(string|element)'
+ boundary: '(string|element)',
+ reference: '(string|element)',
+ display: 'string'
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -141,11 +147,15 @@ var Dropdown = function ($) {
throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)');
}
- var element = this._element; // For dropup with alignment we use the parent as popper container
+ var referenceElement = this._element;
+
+ if (this._config.reference === 'parent') {
+ referenceElement = parent;
+ } else if (Util.isElement(this._config.reference)) {
+ referenceElement = this._config.reference; // Check if it's jQuery element
- if ($(parent).hasClass(ClassName.DROPUP)) {
- if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
- element = parent;
+ if (typeof this._config.reference.jquery !== 'undefined') {
+ referenceElement = this._config.reference[0];
}
} // If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
@@ -156,7 +166,7 @@ var Dropdown = function ($) {
$(parent).addClass(ClassName.POSITION_STATIC);
}
- this._popper = new Popper(element, this._menu, this._getPopperConfig());
+ 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
@@ -164,7 +174,7 @@ var Dropdown = function ($) {
if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) {
- $('body').children().on('mouseover', null, $.noop);
+ $(document.body).children().on('mouseover', null, $.noop);
}
this._element.focus();
@@ -209,7 +219,7 @@ var Dropdown = function ($) {
};
_proto._getConfig = function _getConfig(config) {
- config = _extends({}, this.constructor.Default, $(this._element).data(), config);
+ config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config);
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
};
@@ -256,7 +266,7 @@ var Dropdown = function ($) {
if (typeof this._config.offset === 'function') {
offsetConf.fn = function (data) {
- data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets) || {});
+ data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets) || {});
return data;
};
} else {
@@ -273,8 +283,16 @@ var Dropdown = function ($) {
preventOverflow: {
boundariesElement: this._config.boundary
}
- }
+ } // Disable Popper.js if we have a static display
+
};
+
+ if (this._config.display === 'static') {
+ popperConfig.modifiers.applyStyle = {
+ enabled: false
+ };
+ }
+
return popperConfig;
}; // Static
@@ -339,7 +357,7 @@ var Dropdown = function ($) {
if ('ontouchstart' in document.documentElement) {
- $('body').children().off('mouseover', null, $.noop);
+ $(document.body).children().off('mouseover', null, $.noop);
}
toggles[i].setAttribute('aria-expanded', 'false');