diff options
author | Mark Otto <markdotto@gmail.com> | 2017-06-18 10:14:35 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2017-06-18 10:14:35 +0300 |
commit | 72a009320049720701ef225962566ebd7c3c053c (patch) | |
tree | d94f63a8fc4a0dc594cd38faad78e19f94321ce2 /js/dist/dropdown.js | |
parent | 035b7349f96891d1f70526c44bafa10a8302246e (diff) |
build
Diffstat (limited to 'js/dist/dropdown.js')
-rw-r--r-- | js/dist/dropdown.js | 47 |
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) { |