mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-27 13:59:06 +02:00
Comply to the new rules.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user