frayerjj-frontend 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/init.js +4 -1
- package/src/scss/_wizard.scss +20 -0
- package/src/scss/styles.scss +1 -0
- package/src/wizard.js +60 -0
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -8,6 +8,7 @@ import { hasMany } from './hasMany';
|
|
|
8
8
|
import { loading } from './loading';
|
|
9
9
|
import { msg } from './msg';
|
|
10
10
|
import { modal } from './modal';
|
|
11
|
+
import { wizard } from './wizard';
|
|
11
12
|
import { phoneInput } from './phoneInput';
|
|
12
13
|
import { session } from './session';
|
|
13
14
|
import { validate } from './validate';
|
|
@@ -21,6 +22,7 @@ export const init = (args) => {
|
|
|
21
22
|
window.session = session;
|
|
22
23
|
window.validate = validate;
|
|
23
24
|
window.loading = loading;
|
|
25
|
+
window.wizard = wizard;
|
|
24
26
|
window.ClassicEditor = ClassicEditor;
|
|
25
27
|
loading.init(args?.loadingAnimationStyle ?? 'default');
|
|
26
28
|
|
|
@@ -34,6 +36,7 @@ export const init = (args) => {
|
|
|
34
36
|
modal.ajax.init();
|
|
35
37
|
phoneInput.init();
|
|
36
38
|
validate.init();
|
|
39
|
+
wizard.init();
|
|
37
40
|
|
|
38
41
|
//Dynamic height for container-fixed
|
|
39
42
|
let container = document.querySelectorAll('.container-fixed');
|
|
@@ -58,7 +61,7 @@ export const init = (args) => {
|
|
|
58
61
|
document.querySelectorAll('.dt-localize').forEach(el => {
|
|
59
62
|
msg.verbose('Localizing Date/Time');
|
|
60
63
|
const date = new Date(el.dataset.utc);
|
|
61
|
-
el.innerText = date.toLocaleString();
|
|
64
|
+
el.innerText = date.toLocaleString(undefined, options);
|
|
62
65
|
});
|
|
63
66
|
|
|
64
67
|
// Updates the id in the form action inside a modal. Used for delete confirm and edit modals.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.wizard {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wizard-step {
|
|
7
|
+
display: none;
|
|
8
|
+
width: 100%;
|
|
9
|
+
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.wizard-step.active {
|
|
13
|
+
display: block;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.slide-in-right { transform: translateX(100%); opacity: 0; }
|
|
17
|
+
.slide-in-left { transform: translateX(-100%); opacity: 0; }
|
|
18
|
+
.slide-out-right { transform: translateX(100%); opacity: 0; }
|
|
19
|
+
.slide-out-left { transform: translateX(-100%); opacity: 0; }
|
|
20
|
+
.slide-center { transform: translateX(0); opacity: 1; }
|
package/src/scss/styles.scss
CHANGED
package/src/wizard.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { msg } from './msg.js';
|
|
2
|
+
import { validate } from './validate.js';
|
|
3
|
+
|
|
4
|
+
export const wizard = {
|
|
5
|
+
init: () => {
|
|
6
|
+
msg.verbose('Initializing Wizard');
|
|
7
|
+
document.querySelectorAll('.wizard').forEach(wizard => {
|
|
8
|
+
const animated = wizard.getAttribute('wizard-animated') !== 'false';
|
|
9
|
+
const animationSpeed = parseInt(wizard.getAttribute('wizard-animation-speed')) || 300;
|
|
10
|
+
const steps = wizard.querySelectorAll('.wizard-step');
|
|
11
|
+
let currentStep = 0;
|
|
12
|
+
|
|
13
|
+
steps[currentStep].classList.add('active');
|
|
14
|
+
steps[currentStep].style.opacity = 1;
|
|
15
|
+
|
|
16
|
+
wizard.querySelectorAll('.wizard-next').forEach(button => {
|
|
17
|
+
button.addEventListener('click', () => {
|
|
18
|
+
if (!validate.check(steps[currentStep])) {
|
|
19
|
+
msg.warn('Form failed validation. Please fix the errors before proceeding.');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
wizard.transition(steps[currentStep], steps[currentStep + 1], 'next', animated, animationSpeed);
|
|
23
|
+
currentStep++;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
wizard.querySelectorAll('.wizard-back').forEach(button => {
|
|
27
|
+
button.addEventListener('click', () => {
|
|
28
|
+
wizard.transition(steps[currentStep], steps[currentStep - 1], 'back', animated, animationSpeed);
|
|
29
|
+
currentStep--;
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
transition: (from, to, direction, animated, speed) => {
|
|
35
|
+
if (!animated) {
|
|
36
|
+
from.classList.remove('active');
|
|
37
|
+
to.classList.add('active');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const outClass = direction === 'next' ? 'slide-out-left' : 'slide-out-right';
|
|
42
|
+
const inClass = direction === 'next' ? 'slide-in-right' : 'slide-in-left';
|
|
43
|
+
|
|
44
|
+
to.style.transition = 'none';
|
|
45
|
+
to.classList.add('active', inClass);
|
|
46
|
+
to.offsetHeight; // Trigger reflow
|
|
47
|
+
from.style.transition = `transform ${speed}ms, opacity ${speed}ms`;
|
|
48
|
+
to.style.transition = `transform ${speed}ms, opacity ${speed}ms`;
|
|
49
|
+
from.classList.add(outClass);
|
|
50
|
+
to.classList.remove(inClass);
|
|
51
|
+
to.classList.add('slide-center');
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
from.classList.remove('active', outClass);
|
|
55
|
+
to.classList.remove(inClass, 'slide-center');
|
|
56
|
+
from.style.transition = '';
|
|
57
|
+
to.style.transition = '';
|
|
58
|
+
}, speed);
|
|
59
|
+
}
|
|
60
|
+
};
|