forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransitions-organize-to-method.diff
86 lines (84 loc) · 2.8 KB
/
transitions-organize-to-method.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff --git a/assets/turbo/turbo-helper.js b/assets/turbo/turbo-helper.js
index db34bd3..4bed7b9 100644
--- a/assets/turbo/turbo-helper.js
+++ b/assets/turbo/turbo-helper.js
@@ -11,6 +11,42 @@ const TurboHelper = class {
this.initializeWeatherWidget();
});
+ this.initializeTransitions();
+ }
+
+ closeModal() {
+ if (document.body.classList.contains('modal-open')) {
+ const modalEl = document.querySelector('.modal');
+ const modal = Modal.getInstance(modalEl);
+ modalEl.classList.remove('fade');
+ modal._backdrop._config.isAnimated = false;
+ modal.hide();
+ modal.dispose();
+ }
+ }
+
+ closeSweetalert() {
+ // internal way to see if sweetalert2 has been imported yet
+ if (__webpack_modules__[require.resolveWeak('sweetalert2')]) {
+ // because we know it's been imported, this will run synchronously
+ import(/* webpackMode: 'weak' */'sweetalert2').then((Swal) => {
+ if (Swal.default.isVisible()) {
+ Swal.default.getPopup().style.animationDuration = '0ms'
+ Swal.default.close();
+ }
+ })
+ }
+ }
+
+ initializeWeatherWidget() {
+ __weatherwidget_init();
+ }
+
+ isPreviewRendered() {
+ return document.documentElement.hasAttribute('data-turbo-preview');
+ }
+
+ initializeTransitions() {
document.addEventListener('turbo:visit', () => {
// fade out the old body
document.body.classList.add('turbo-loading');
@@ -53,38 +89,6 @@ const TurboHelper = class {
}
});
}
-
- closeModal() {
- if (document.body.classList.contains('modal-open')) {
- const modalEl = document.querySelector('.modal');
- const modal = Modal.getInstance(modalEl);
- modalEl.classList.remove('fade');
- modal._backdrop._config.isAnimated = false;
- modal.hide();
- modal.dispose();
- }
- }
-
- closeSweetalert() {
- // internal way to see if sweetalert2 has been imported yet
- if (__webpack_modules__[require.resolveWeak('sweetalert2')]) {
- // because we know it's been imported, this will run synchronously
- import(/* webpackMode: 'weak' */'sweetalert2').then((Swal) => {
- if (Swal.default.isVisible()) {
- Swal.default.getPopup().style.animationDuration = '0ms'
- Swal.default.close();
- }
- })
- }
- }
-
- initializeWeatherWidget() {
- __weatherwidget_init();
- }
-
- isPreviewRendered() {
- return document.documentElement.hasAttribute('data-turbo-preview');
- }
}
export default new TurboHelper();