diff options
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/dropdown.js | 30 | ||||
| -rw-r--r-- | js/src/tooltip.js | 16 |
2 files changed, 27 insertions, 19 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 18b051b89..a18f0c28a 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -13,14 +13,6 @@ import Util from './util' const Dropdown = (($) => { /** - * Check for Popper dependency - * Popper - https://popper.js.org - */ - if (typeof Popper === 'undefined') { - throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)') - } - - /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ @@ -55,6 +47,8 @@ const Dropdown = (($) => { DISABLED : 'disabled', SHOW : 'show', DROPUP : 'dropup', + DROPRIGHT : 'dropright', + DROPLEFT : 'dropleft', MENURIGHT : 'dropdown-menu-right', MENULEFT : 'dropdown-menu-left' } @@ -71,7 +65,11 @@ const Dropdown = (($) => { TOP : 'top-start', TOPEND : 'top-end', BOTTOM : 'bottom-start', - BOTTOMEND : 'bottom-end' + BOTTOMEND : 'bottom-end', + RIGHT : 'right-start', + RIGHTEND : 'right-end', + LEFT : 'left-start', + LEFTEND : 'left-end' } const Default = { @@ -145,6 +143,14 @@ const Dropdown = (($) => { return } + /** + * Check for Popper dependency + * Popper - https://popper.js.org + */ + if (typeof Popper === 'undefined') { + throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)') + } + let element = this._element // for dropup with alignment we use the parent as popper container if ($(parent).hasClass(ClassName.DROPUP)) { @@ -227,7 +233,7 @@ const Dropdown = (($) => { _getPlacement() { const $parentDropdown = $(this._element).parent() - let placement = AttachmentMap.BOTTOM + let placement = AttachmentMap.BOTTOM // Handle dropup if ($parentDropdown.hasClass(ClassName.DROPUP)) { @@ -235,6 +241,10 @@ const Dropdown = (($) => { if ($(this._menu).hasClass(ClassName.MENURIGHT)) { placement = AttachmentMap.TOPEND } + } else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) { + placement = AttachmentMap.RIGHT + } else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) { + placement = AttachmentMap.LEFT } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) { placement = AttachmentMap.BOTTOMEND } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a3fc93c91..7cefd0be6 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -13,15 +13,6 @@ import Util from './util' const Tooltip = (($) => { /** - * Check for Popper dependency - * Popper - https://popper.js.org - */ - if (typeof Popper === 'undefined') { - throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)') - } - - - /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ @@ -120,6 +111,13 @@ const Tooltip = (($) => { class Tooltip { constructor(element, config) { + /** + * Check for Popper dependency + * Popper - https://popper.js.org + */ + if (typeof Popper === 'undefined') { + throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)') + } // private this._isEnabled = true |
