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",
|
"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.",
|
"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>",
|
"author": "Tony Air <tony@twma.pro>",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
|
@ -19,7 +19,7 @@ const submitForm = (e) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
data.append('ajax', '1')
|
data.append('ajax', '1')
|
||||||
form.classList.add('loading')
|
form.parentElement.classList.add('loading')
|
||||||
|
|
||||||
fetch(form.action, {
|
fetch(form.action, {
|
||||||
method: form.method,
|
method: form.method,
|
||||||
@ -49,19 +49,12 @@ const submitForm = (e) => {
|
|||||||
const replaceForm = (form, html) => {
|
const replaceForm = (form, html) => {
|
||||||
const parent = form.parentElement;
|
const parent = form.parentElement;
|
||||||
|
|
||||||
if (parent.classList.contains(CONTAINER_CLASS)) {
|
parent.innerHTML = html
|
||||||
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}`))
|
window.dispatchEvent(new Event(`${Events.AJAX}`))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const formInit = (form) => {
|
const formInit = (form) => {
|
||||||
@ -70,6 +63,16 @@ const formInit = (form) => {
|
|||||||
return false
|
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.dataset[`${NAME}Active`] = true
|
||||||
|
|
||||||
form.addEventListener('submit', submitForm)
|
form.addEventListener('submit', submitForm)
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
animation: fade 3s linear infinite;
|
animation: fade 3s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-container.loading,
|
||||||
main.loading {
|
main.loading {
|
||||||
animation: shrink 0.5s linear 1;
|
animation: shrink 0.5s linear 1;
|
||||||
max-height: 0;
|
max-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-container.loaded,
|
||||||
main.loaded {
|
main.loaded {
|
||||||
animation: expand 0.5s linear 1;
|
animation: expand 0.5s linear 1;
|
||||||
max-height: fit-content;
|
max-height: fit-content;
|
||||||
|
Loading…
Reference in New Issue
Block a user