2023-10-28 23:07:18 +03:00
|
|
|
export default class extends HTMLElement {
|
|
|
|
|
connectedCallback () {
|
2025-09-24 12:07:54 +03:00
|
|
|
const form = this.querySelector('form') || (this.querySelector('input, button, select') || this.lastElementChild).form
|
|
|
|
|
|
2025-07-05 10:27:35 +03:00
|
|
|
if (this.dataset.interval) {
|
|
|
|
|
this.interval = setInterval(() => {
|
2025-09-24 12:07:54 +03:00
|
|
|
form.requestSubmit()
|
2025-07-05 10:27:35 +03:00
|
|
|
}, parseInt(this.dataset.interval))
|
2025-09-18 10:05:04 +03:00
|
|
|
} else if (this.dataset.on) {
|
2025-09-24 12:07:54 +03:00
|
|
|
this.lastElementChild.addEventListener(this.dataset.on, (event) => {
|
|
|
|
|
if (this.dataset.disable === 'true') {
|
|
|
|
|
form.querySelector('[type="submit"]')?.setAttribute('disabled', true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataset.submitIfValue === 'true') {
|
|
|
|
|
if (event.target.value) {
|
|
|
|
|
form.requestSubmit()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
form.requestSubmit()
|
|
|
|
|
}
|
2025-09-18 10:05:04 +03:00
|
|
|
})
|
2025-07-05 10:27:35 +03:00
|
|
|
} else {
|
2025-09-24 12:07:54 +03:00
|
|
|
form.requestSubmit()
|
2025-07-05 10:27:35 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disconnectedCallback () {
|
|
|
|
|
if (this.interval) {
|
|
|
|
|
clearInterval(this.interval)
|
|
|
|
|
}
|
2023-10-28 23:07:18 +03:00
|
|
|
}
|
|
|
|
|
}
|