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

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Otto <markdotto@gmail.com>2017-06-18 10:14:35 +0300
committerMark Otto <markdotto@gmail.com>2017-06-18 10:14:35 +0300
commit72a009320049720701ef225962566ebd7c3c053c (patch)
treed94f63a8fc4a0dc594cd38faad78e19f94321ce2 /js/dist/dropdown.js
parent035b7349f96891d1f70526c44bafa10a8302246e (diff)
build
Diffstat (limited to 'js/dist/dropdown.js')
-rw-r--r--js/dist/dropdown.js47
1 files changed, 35 insertions, 12 deletions
diff --git a/js/dist/dropdown.js b/js/dist/dropdown.js
index 404d123b02..2736356482 100644
--- a/js/dist/dropdown.js
+++ b/js/dist/dropdown.js
@@ -101,6 +101,7 @@ var Dropdown = function ($) {
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
+ this._inNavbar = this._detectNavbar();
this._addEventListeners();
}
@@ -141,17 +142,7 @@ var Dropdown = function ($) {
element = parent;
}
}
- this._popper = new Popper(element, this._menu, {
- placement: this._getPlacement(),
- modifiers: {
- offset: {
- offset: this._config.offset
- },
- flip: {
- enabled: this._config.flip
- }
- }
- });
+ this._popper = new Popper(element, this._menu, this._getPopperConfig());
// if this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
@@ -180,6 +171,7 @@ var Dropdown = function ($) {
};
Dropdown.prototype.update = function update() {
+ this._inNavbar = this._detectNavbar();
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
@@ -231,10 +223,41 @@ var Dropdown = function ($) {
} else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
placement = AttachmentMap.BOTTOMEND;
}
-
return placement;
};
+ Dropdown.prototype._detectNavbar = function _detectNavbar() {
+ return $(this._element).closest('.navbar').length > 0;
+ };
+
+ Dropdown.prototype._getPopperConfig = function _getPopperConfig() {
+ var _this2 = this;
+
+ var popperConfig = {
+ placement: this._getPlacement(),
+ modifiers: {
+ offset: {
+ offset: this._config.offset
+ },
+ flip: {
+ enabled: this._config.flip
+ }
+ }
+ };
+
+ if (this._inNavbar) {
+ popperConfig.modifiers.AfterApplyStyle = {
+ enabled: true,
+ order: 901, // ApplyStyle order + 1
+ fn: function fn() {
+ // reset Popper styles
+ $(_this2._menu).attr('style', '');
+ }
+ };
+ }
+ return popperConfig;
+ };
+
// static
Dropdown._jQueryInterface = function _jQueryInterface(config) {