Browse code

Initial commit

Benjamin Roth authored on16/03/2023 20:22:35
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+$GLOBALS['TL_CSS']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.css|static';
4
+
5
+if ($this->options['polyfill'] ?? false) {
6
+    $GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.polyfill'] = 'bundles/contaommenu/mmenu/mmenu.polyfills.js|static';
7
+}
8
+
9
+$GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu'] = 'bundles/contaommenu/mmenu/mmenu.js|static';
10
+
11
+if ($this->options['drag']['menu']['open'] ?? false) {
12
+    $GLOBALS['TL_JAVASCRIPT']['contao_dk_mmenu.hammerjs'] = 'bundles/contaommenu/hammerjs/hammer.min.js|static';
13
+}
14
+
15
+?>
16
+<script>
17
+    document.addEventListener(
18
+        "DOMContentLoaded", function () {
19
+            const menu = document.querySelector('#<?= $this->elementId ?>');
20
+            if (null !== menu && 0 === menu.querySelectorAll('li.active').length) {
21
+                const trails = menu.querySelectorAll('li.trail');
22
+                if (0 < trails.length) {
23
+                    trails.item(trails.length - 1).classList.add('active');
24
+                }
25
+            }
26
+
27
+
28
+            if ($('.mmenu_close_button').length) {
29
+
30
+                var mmenu = new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
31
+
32
+                var elements = document.getElementsByClassName("mmenu_close_button");
33
+
34
+                for (var i = 0; i < elements.length; i++) {
35
+                    elements[i].addEventListener("click", function () {
36
+                        mmenu.API.close();
37
+                    });
38
+                }
39
+            } else {
40
+                new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
41
+            }
42
+
43
+        }
44
+    );
45
+</script>
46
+