diff options
Diffstat (limited to 'js/src/button.js')
-rw-r--r-- | js/src/button.js | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/js/src/button.js b/js/src/button.js index 56688e2462..445e78938b 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -8,8 +8,6 @@ import $ from 'jquery' */ const Button = (($) => { - - /** * ------------------------------------------------------------------------ * Constants @@ -39,11 +37,10 @@ const Button = (($) => { const Event = { CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`, - FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} ` - + `blur${EVENT_KEY}${DATA_API_KEY}` + FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} ` + + `blur${EVENT_KEY}${DATA_API_KEY}` } - /** * ------------------------------------------------------------------------ * Class Definition @@ -51,25 +48,22 @@ const Button = (($) => { */ class Button { - constructor(element) { this._element = element } - - // getters + // Getters static get VERSION() { return VERSION } - - // public + // Public toggle() { let triggerChangeEvent = true let addAriaPressed = true - const rootElement = $(this._element).closest( + const rootElement = $(this._element).closest( Selector.DATA_TOGGLE )[0] @@ -81,7 +75,6 @@ const Button = (($) => { if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) { triggerChangeEvent = false - } else { const activeElement = $(rootElement).find(Selector.ACTIVE)[0] @@ -105,7 +98,6 @@ const Button = (($) => { input.focus() addAriaPressed = false } - } if (addAriaPressed) { @@ -123,8 +115,7 @@ const Button = (($) => { this._element = null } - - // static + // Static static _jQueryInterface(config) { return this.each(function () { @@ -140,10 +131,8 @@ const Button = (($) => { } }) } - } - /** * ------------------------------------------------------------------------ * Data Api implementation @@ -167,22 +156,20 @@ const Button = (($) => { $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)) }) - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ - $.fn[NAME] = Button._jQueryInterface + $.fn[NAME] = Button._jQueryInterface $.fn[NAME].Constructor = Button - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return Button._jQueryInterface } return Button - })($) export default Button |