Browse code

Fix assets links

Benjamin Roth authored on04/11/2022 22:40:47
Showing1 changed files
... ...
@@ -1,11 +1,11 @@
1 1
 <?php
2 2
 
3
-$GLOBALS['TL_CSS'][] = '/system/modules/eSM_swiper/assets/lib/swiper/' . $GLOBALS['TL_ASSETS']['SWIPERJS'] . '/swiper-bundle.min.css';
4
-$GLOBALS['TL_CSS'][] = '/system/modules/eSM_swiper/assets/css/swiper-custom.css';
3
+$GLOBALS['TL_CSS'][] = 'bundles/esalesmediacontaoswiper/js/lib/swiper/' . $GLOBALS['TL_ASSETS']['SWIPERJS'] . '/swiper-bundle.min.css';
4
+$GLOBALS['TL_CSS'][] = 'bundles/esalesmediacontaoswiper/css/swiper-custom.css';
5 5
 
6 6
 ?>
7 7
 
8
-<script src="/system/modules/eSM_swiper/assets/lib/swiper/<?= $GLOBALS['TL_ASSETS']['SWIPERJS'] ?>/swiper-bundle.min.js"></script>
8
+<script src="bundles/esalesmediacontaoswiper/js/lib/swiper/<?= $GLOBALS['TL_ASSETS']['SWIPERJS'] ?>/swiper-bundle.min.js"></script>
9 9
 
10 10
 <script>
11 11
   (function () {
Browse code

Refactor and rewrite as contao bundle

Benjamin Roth authored on04/11/2022 22:32:32
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,87 @@
1
+<?php
2
+
3
+$GLOBALS['TL_CSS'][] = '/system/modules/eSM_swiper/assets/lib/swiper/' . $GLOBALS['TL_ASSETS']['SWIPERJS'] . '/swiper-bundle.min.css';
4
+$GLOBALS['TL_CSS'][] = '/system/modules/eSM_swiper/assets/css/swiper-custom.css';
5
+
6
+?>
7
+
8
+<script src="/system/modules/eSM_swiper/assets/lib/swiper/<?= $GLOBALS['TL_ASSETS']['SWIPERJS'] ?>/swiper-bundle.min.js"></script>
9
+
10
+<script>
11
+  (function () {
12
+    var cte = document.querySelectorAll(".ce_swiperSliderStart,.swiper-holder");
13
+
14
+    for (var i=0; i<cte.length; i++)
15
+    {
16
+      var e = cte[i].querySelectorAll('.swiper-container')[0];
17
+      var w = e.querySelectorAll('.swiper-wrapper')[0];
18
+      var c = {
19
+        initialSlide: 0,
20
+        speed: 300,
21
+        autoHeight: false,
22
+        effect: 'slide',
23
+        slidesPerView: 1,
24
+        slidesPerGroup: 1,
25
+        preloadImages: true,
26
+        loop: false,
27
+        autoplay: false
28
+      };
29
+
30
+      if (w.hasAttribute('data-config'))
31
+      {
32
+        var s = w.getAttribute('data-config').split(',');
33
+
34
+        c.speed = parseInt(s[1]);
35
+        c.initialSlide = parseInt(s[2]);
36
+
37
+        if (parseInt(s[0]) > 0)
38
+          c.autoplay = {delay: parseInt(s[0]), disableOnInteraction: (parseInt(s[7]) == 1 ? true : false)}
39
+
40
+        if (parseInt(s[3]) != 1)
41
+          c.preloadImages = false;
42
+
43
+        if (parseInt(s[4]) == 1)
44
+          c.loop = true;
45
+
46
+        if (parseInt(s[5]) != '')
47
+          c.navigation = {
48
+            nextEl: cte[i].querySelectorAll('.swiper-button-next')[0],
49
+            prevEl: cte[i].querySelectorAll('.swiper-button-prev')[0],
50
+          };
51
+
52
+        if (parseInt(s[6]) == 1)
53
+          c.pagination = {
54
+            el: '.swiper-pagination',
55
+            clickable: true
56
+          };
57
+
58
+        if (parseInt(s[8]) == 1)
59
+          c.effect = 'fade';
60
+
61
+        if (parseInt(s[9]) > 1)
62
+          c.slidesPerView = parseInt(s[9]);
63
+
64
+        if (parseInt(s[10]) > 1)
65
+          c.slidesPerGroup = parseInt(s[10]);
66
+
67
+        if (parseInt(s[11]) == 1)
68
+          c.autoHeight = true;
69
+
70
+        if (s[12] !== undefined && s[12] !== '')
71
+          c.slideClass = s[12];
72
+
73
+      }
74
+      if (w.hasAttribute('data-breakpoints'))
75
+      {
76
+        try {
77
+          var breakpoints = JSON.parse(w.getAttribute('data-breakpoints'));
78
+          c.breakpoints = breakpoints;
79
+        } catch (e)
80
+        {
81
+          console.log('Swiper.js: breakpoint data attribute is not valid JSON');
82
+        }
83
+      }
84
+      new Swiper(e,c);
85
+    }
86
+  })();
87
+</script>
0 88
\ No newline at end of file