Skip to content

Commit

Permalink
fix: added attribute to disable active label
Browse files Browse the repository at this point in the history
fix: added code to enable active label at page load
  • Loading branch information
PiemP committed Sep 14, 2023
1 parent be2772c commit a145eef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
5 changes: 4 additions & 1 deletion src/js/plugins/input-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class InputLabel {
this._labelOut()
this._labelOver()
}
this._bindEvents()

if (label && label.getAttribute('it-bs-static') === null) {
this._bindEvents()
}
}

_bindEvents() {
Expand Down
19 changes: 7 additions & 12 deletions src/js/plugins/input-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const EVENT_CHANGE = `change${EVENT_KEY}`

//const EVENT_FOCUS_DATA_API = `focus${EVENT_KEY}${DATA_API_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
const EVENT_MOUSEDOWN_DATA_API = `mousedown${EVENT_KEY}${DATA_API_KEY}`
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`

const CLASS_NAME_ADAPTIVE = 'input-number-adaptive'
const CLASS_NAME_PERCENTAGE = 'input-number-percentage'
Expand Down Expand Up @@ -168,17 +166,14 @@ const createInput = (element) => {
return null
}

EventHandler.on(document, EVENT_MOUSEDOWN_DATA_API, SELECTOR_INPUT + ', label', function () {
const target = InputLabel.getInputFromLabel(this) || this
createInput(target)
})
EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_INPUT + ', label', function () {
const target = InputLabel.getInputFromLabel(this) || this
const element = createInput(target)
if (element && element._label) {
element._label._labelOut()
}
document.addEventListener('DOMContentLoaded', function () {
var frmel = document.querySelectorAll(SELECTOR_INPUT + ', label')
frmel.forEach(function (item) {
const target = InputLabel.getInputFromLabel(item) || item
createInput(target)
})
})

EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_BTN, function () {
const wrapper = this.closest(SELECTOR_WRAPPER)
if (wrapper) {
Expand Down
19 changes: 6 additions & 13 deletions src/js/plugins/input-search-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ import InputLabel from './input-label'
const NAME = 'inputsearchautocomplete'
const DATA_KEY = 'bs.inputsearchautocomplete'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'

const Default = {
autocomplete: [],
}

const EVENT_KEYUP = `keyup${EVENT_KEY}`
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`
const EVENT_MOUSEDOWN_DATA_API = `mousedown${EVENT_KEY}${DATA_API_KEY}`

const CLASS_NAME_SHOW = 'autocomplete-list-show'
const CLASS_NAME_AUTOCOMPLETE = 'autocomplete'
Expand Down Expand Up @@ -137,16 +134,12 @@ const createInput = (element) => {
return null
}

EventHandler.on(document, EVENT_MOUSEDOWN_DATA_API, SELECTOR_SEARCH + ', label', function () {
const target = InputLabel.getInputFromLabel(this) || this
createInput(target)
})
EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_SEARCH + ', label', function () {
const target = InputLabel.getInputFromLabel(this) || this
const element = createInput(target)
if (element && element._label) {
element._label._labelOut()
}
document.addEventListener('DOMContentLoaded', function () {
var frmel = document.querySelectorAll(SELECTOR_SEARCH + ', label')
frmel.forEach(function (item) {
const target = InputLabel.getInputFromLabel(item) || item
createInput(target)
})
})

export default InputSearch
19 changes: 9 additions & 10 deletions src/js/plugins/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import InputLabel from './input-label'
const NAME = 'input'
const DATA_KEY = 'bs.input'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'

const EVENT_MOUSEDOWN_DATA_API = `mousedown${EVENT_KEY}${DATA_API_KEY}`
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`

const EVENT_CHANGE = `change${EVENT_KEY}`

Expand Down Expand Up @@ -67,11 +63,13 @@ class Input extends BaseComponent {
*/
const excludes = [
'select',
//'input[data-bs-input][type="number"]',
'textarea',
'input[data-bs-input][type="password"]',
'input.input-password[data-bs-input]',
'input[data-bs-autocomplete][type="search"]',
'input[type="time"]',
'input[type="radio"]',
'input[type="checkbox"]',
]

/*const inputs = SelectorEngine.find('input, textarea').filter((input) => {
Expand All @@ -96,11 +94,12 @@ const createInput = (element) => {
return null
}

var frmel = document.querySelectorAll('input, textarea, label')
frmel.forEach(function (item, index, arr) {
const target = InputLabel.getInputFromLabel(item) || item
createInput(target)
document.addEventListener('DOMContentLoaded', function () {
var frmel = document.querySelectorAll('input, textarea, label')
frmel.forEach(function (item) {
const target = InputLabel.getInputFromLabel(item) || item
createInput(target)
})
})


export default Input

0 comments on commit a145eef

Please sign in to comment.