diff options
author | Mark Otto <markdotto@gmail.com> | 2018-02-12 01:53:29 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2018-02-12 01:53:29 +0300 |
commit | e373fbea9220732283761f3720b4be6280d5135d (patch) | |
tree | 2aac6819b440f92d055cdf9c1961831c92bf01a5 /js/dist/dropdown.js | |
parent | f81f419b22949d2bf0f4d346891be44724109135 (diff) |
dist
Diffstat (limited to 'js/dist/dropdown.js')
-rw-r--r-- | js/dist/dropdown.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/js/dist/dropdown.js b/js/dist/dropdown.js index 263d35bf63..ed1d52d7d1 100644 --- a/js/dist/dropdown.js +++ b/js/dist/dropdown.js @@ -75,12 +75,14 @@ var Dropdown = function ($) { var Default = { offset: 0, flip: true, - boundary: 'scrollParent' + boundary: 'scrollParent', + reference: 'toggle' }; var DefaultType = { offset: '(number|string|function)', flip: 'boolean', - boundary: '(string|element)' + boundary: '(string|element)', + reference: '(string|element)' /** * ------------------------------------------------------------------------ * Class Definition @@ -141,11 +143,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 ($(parent).hasClass(ClassName.DROPUP)) { - if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) { - element = parent; + 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 (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 +162,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 |