mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPR: Form loading improvements
This commit is contained in:
parent
7077687bc2
commit
70bcbcab2b
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate-react",
|
||||
"version": "5.1.7",
|
||||
"version": "5.1.8",
|
||||
"description": "This UI Kit allows you to build Bootstrap 5 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.",
|
||||
"author": "Tony Air <tony@twma.pro>",
|
||||
"license": "BSD-2-Clause",
|
||||
|
@ -19,7 +19,7 @@ const submitForm = (e) => {
|
||||
})
|
||||
|
||||
data.append('ajax', '1')
|
||||
form.classList.add('loading')
|
||||
form.parentElement.classList.add('loading')
|
||||
|
||||
fetch(form.action, {
|
||||
method: form.method,
|
||||
@ -49,27 +49,30 @@ const submitForm = (e) => {
|
||||
const replaceForm = (form, html) => {
|
||||
const parent = form.parentElement;
|
||||
|
||||
if (parent.classList.contains(CONTAINER_CLASS)) {
|
||||
parent.innerHTML = html
|
||||
parent.classList.remove('loading')
|
||||
parent.classList.add('loaded')
|
||||
|
||||
window.dispatchEvent(new Event(`${Events.AJAX}`))
|
||||
return
|
||||
}
|
||||
|
||||
const elHtml = document.createElement('div')
|
||||
elHtml.classList.add(CONTAINER_CLASS)
|
||||
elHtml.innerHTML = html
|
||||
form.replaceWith(elHtml)
|
||||
|
||||
window.dispatchEvent(new Event(`${Events.AJAX}`))
|
||||
}
|
||||
|
||||
const formInit = (form) => {
|
||||
if (form.dataset[`${NAME}Active`]) {
|
||||
console.log(`${NAME}: #${form.id} already activated`)
|
||||
return false
|
||||
}
|
||||
|
||||
// wrap form
|
||||
const parent = form.parentElement;
|
||||
|
||||
if (!parent.classList.contains(CONTAINER_CLASS)) {
|
||||
const elHtml = document.createElement('div')
|
||||
elHtml.classList.add(CONTAINER_CLASS)
|
||||
elHtml.append(form)
|
||||
}
|
||||
//
|
||||
|
||||
form.dataset[`${NAME}Active`] = true
|
||||
|
||||
form.addEventListener('submit', submitForm)
|
||||
|
@ -11,12 +11,14 @@
|
||||
animation: fade 3s linear infinite;
|
||||
}
|
||||
|
||||
.form-container.loading,
|
||||
main.loading {
|
||||
animation: shrink 0.5s linear 1;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.form-container.loaded,
|
||||
main.loaded {
|
||||
animation: expand 0.5s linear 1;
|
||||
max-height: fit-content;
|
||||
|
Loading…
Reference in New Issue
Block a user