mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-21 04:41:36 +02:00
some cleaning and changes for readability
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user