1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-12 08:34:08 +02:00
This commit is contained in:
Mark Otto
2018-01-11 22:42:40 -08:00
parent 80d0943b95
commit 6d8d8639f3
42 changed files with 356 additions and 385 deletions

26
js/dist/dropdown.js vendored
View File

@@ -100,12 +100,12 @@ var Dropdown = function ($) {
this._inNavbar = this._detectNavbar();
this._addEventListeners();
} // getters
} // Getters
var _proto = Dropdown.prototype;
// public
// Public
_proto.toggle = function toggle() {
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
return;
@@ -138,10 +138,10 @@ var Dropdown = function ($) {
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)');
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 element = this._element; // For dropup with alignment we use the parent as popper container
if ($(parent).hasClass(ClassName.DROPUP)) {
if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
@@ -157,13 +157,13 @@ var Dropdown = function ($) {
}
this._popper = new Popper(element, this._menu, this._getPopperConfig());
} // if this is a touch-enabled device we add extra
} // 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
if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) {
if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) {
$('body').children().on('mouseover', null, $.noop);
}
@@ -194,7 +194,7 @@ var Dropdown = function ($) {
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
}; // private
}; // Private
_proto._addEventListeners = function _addEventListeners() {
@@ -276,7 +276,7 @@ var Dropdown = function ($) {
}
};
return popperConfig;
}; // static
}; // Static
Dropdown._jQueryInterface = function _jQueryInterface(config) {
@@ -292,7 +292,7 @@ var Dropdown = function ($) {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error("No method named \"" + config + "\"");
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
@@ -334,7 +334,7 @@ var Dropdown = function ($) {
if (hideEvent.isDefaultPrevented()) {
continue;
} // if this is a touch-enabled device we remove the extra
} // If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
@@ -395,19 +395,19 @@ var Dropdown = function ($) {
var items = $(parent).find(Selector.VISIBLE_ITEMS).get();
if (!items.length) {
if (items.length === 0) {
return;
}
var index = items.indexOf(event.target);
if (event.which === ARROW_UP_KEYCODE && index > 0) {
// up
// Up
index--;
}
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
// down
// Down
index++;
}