forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganization-organize-into-methods.diff
58 lines (57 loc) · 2.28 KB
/
organization-organize-into-methods.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
diff --git a/assets/turbo/turbo-helper.js b/assets/turbo/turbo-helper.js
index 0dc9fd3..7406f98 100644
--- a/assets/turbo/turbo-helper.js
+++ b/assets/turbo/turbo-helper.js
@@ -3,27 +3,34 @@ import { Modal } from 'bootstrap';
const TurboHelper = class {
constructor() {
document.addEventListener('turbo:before-cache', () => {
- 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();
- }
-
- // 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();
- }
- })
- }
+ this.closeModal();
+ this.closeSweetalert();
});
}
+
+ 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();
+ }
+ })
+ }
+ }
}
export default new TurboHelper();