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-05-27 06:20:10 +0300
committerMark Otto <markdotto@gmail.com>2017-05-27 06:20:10 +0300
commit4282d892f37e6b44f31c5f6bc0fa693f147c6e59 (patch)
treec9e2641b2ff2acc7d8e7ea0845284da8ad9db9ec /js/dist/dropdown.js
parentc8c51186f58886b114fbcc4e0b01dd2df3d74d36 (diff)
build
Diffstat (limited to 'js/dist/dropdown.js')
-rw-r--r--js/dist/dropdown.js40
1 files changed, 34 insertions, 6 deletions
diff --git a/js/dist/dropdown.js b/js/dist/dropdown.js
index 3a4996992d..a2593e1623 100644
--- a/js/dist/dropdown.js
+++ b/js/dist/dropdown.js
@@ -54,7 +54,10 @@ var Dropdown = function ($) {
var ClassName = {
DISABLED: 'disabled',
- SHOW: 'show'
+ SHOW: 'show',
+ DROPUP: 'dropup',
+ MENURIGHT: 'dropdown-menu-right',
+ MENULEFT: 'dropdown-menu-left'
};
var Selector = {
@@ -67,7 +70,9 @@ var Dropdown = function ($) {
var AttachmentMap = {
TOP: 'top-start',
- BOTTOM: 'bottom-start'
+ TOPEND: 'top-end',
+ BOTTOM: 'bottom-start',
+ BOTTOMEND: 'bottom-end'
};
var Default = {
@@ -129,10 +134,15 @@ var Dropdown = function ($) {
return;
}
- // Handle dropup
- var dropdownPlacement = $(this._element).parent().hasClass('dropup') ? AttachmentMap.TOP : this._config.placement;
- this._popper = new Popper(this._element, this._menu, {
- placement: dropdownPlacement,
+ 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)) {
+ element = parent;
+ }
+ }
+ this._popper = new Popper(element, this._menu, {
+ placement: this._getPlacement(),
modifiers: {
offset: {
offset: this._config.offset
@@ -208,6 +218,24 @@ var Dropdown = function ($) {
return this._menu;
};
+ Dropdown.prototype._getPlacement = function _getPlacement() {
+ var $parentDropdown = $(this._element).parent();
+ var placement = this._config.placement;
+
+ // Handle dropup
+ if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) {
+ placement = AttachmentMap.TOP;
+ if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
+ placement = AttachmentMap.TOPEND;
+ }
+ } else {
+ if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
+ placement = AttachmentMap.BOTTOMEND;
+ }
+ }
+ return placement;
+ };
+
// static
Dropdown._jQueryInterface = function _jQueryInterface(config) {