diff options
author | Johann-S <johann.servoire@gmail.com> | 2018-11-14 12:16:56 +0300 |
---|---|---|
committer | Johann-S <johann.servoire@gmail.com> | 2018-11-14 12:54:50 +0300 |
commit | 9201a805101943f9ec088639d520d7d2874bbed1 (patch) | |
tree | b103dea4a9d52bac3bb849c6c14277f4000a1f9c /js/src/dropdown.js | |
parent | fab1dea92773e796a75ac4a2fadb645714ac80ce (diff) |
some cleaning and changes for readability
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r-- | js/src/dropdown.js | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 48b8d62eab..d8fe5fdba1 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -1,7 +1,3 @@ -import $ from 'jquery' -import Popper from 'popper.js' -import Util from './util' - /** * -------------------------------------------------------------------------- * Bootstrap (v4.1.3): dropdown.js @@ -9,6 +5,10 @@ import Util from './util' * -------------------------------------------------------------------------- */ +import $ from 'jquery' +import Popper from 'popper.js' +import Util from './util' + /** * ------------------------------------------------------------------------ * Constants @@ -41,13 +41,13 @@ const Event = { } const ClassName = { - DISABLED : 'disabled', - SHOW : 'show', - DROPUP : 'dropup', - DROPRIGHT : 'dropright', - DROPLEFT : 'dropleft', - MENURIGHT : 'dropdown-menu-right', - MENULEFT : 'dropdown-menu-left', + DISABLED : 'disabled', + SHOW : 'show', + DROPUP : 'dropup', + DROPRIGHT : 'dropright', + DROPLEFT : 'dropleft', + MENURIGHT : 'dropdown-menu-right', + MENULEFT : 'dropdown-menu-left', POSITION_STATIC : 'position-static' } @@ -71,19 +71,19 @@ const AttachmentMap = { } const Default = { - offset : 0, - flip : true, - boundary : 'scrollParent', - reference : 'toggle', - display : 'dynamic' + offset : 0, + flip : true, + boundary : 'scrollParent', + reference : 'toggle', + display : 'dynamic' } const DefaultType = { - offset : '(number|string|function)', - flip : 'boolean', - boundary : '(string|element)', - reference : '(string|element)', - display : 'string' + offset : '(number|string|function)', + flip : 'boolean', + boundary : '(string|element)', + reference : '(string|element)', + display : 'string' } /** @@ -203,8 +203,8 @@ class Dropdown { relatedTarget: this._element } const showEvent = $.Event(Event.SHOW, relatedTarget) - const parent = Dropdown._getParentFromElement(this._element) + $(parent).trigger(showEvent) if (showEvent.isDefaultPrevented()) { @@ -226,8 +226,8 @@ class Dropdown { relatedTarget: this._element } const hideEvent = $.Event(Event.HIDE, relatedTarget) - const parent = Dropdown._getParentFromElement(this._element) + $(parent).trigger(hideEvent) if (hideEvent.isDefaultPrevented()) { @@ -287,6 +287,7 @@ class Dropdown { _getMenuElement() { if (!this._menu) { const parent = Dropdown._getParentFromElement(this._element) + if (parent) { this._menu = parent.querySelector(Selector.MENU) } @@ -382,6 +383,7 @@ class Dropdown { } const toggles = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)) + for (let i = 0, len = toggles.length; i < len; i++) { const parent = Dropdown._getParentFromElement(toggles[i]) const context = $(toggles[i]).data(DATA_KEY) |