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,300 @@
1
+<?php header('Access-Control-Allow-Origin: *'); ?>
2
+<?php
3
+if (TL_MODE == 'FE') {
4
+    $GLOBALS['TL_CSS'][] = 'files/base/layout/css/elements/custom-elements/ce_rsce_contentslider.min.css|static';
5
+}
6
+?>
7
+<?php
8
+if (!isset($this->fixed_image) && $this->element_type == 'is_buttons') {
9
+    $this->{"fixed_image"} = "";
10
+}
11
+?>
12
+
13
+
14
+    <div <?php echo $this->cssID; ?> class="content--element <?php echo $this->class; ?>">
15
+
16
+        <div class="ce--inner <?php if ($this->is_fullwidth): ?>is-fullwidth<?php endif; ?> <?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>is-vertical<?php endif; ?>">
17
+            <?php if ($this->nav_position == 1 || $this->nav_position == 2 && ($this->headline || $this->subline || $this->topline)): ?>
18
+            <div class="ce--headline  container"
19
+                 data-aos="<?php if ($this->animation_type) : ?><?php echo $this->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
20
+                <div class="">
21
+                    <?php if ($this->topline) : ?>
22
+                        <span class="ce--topline"><?php echo $this->topline; ?></span>
23
+                    <?php endif; ?>
24
+                    <?php if ($this->headline) : ?>
25
+                    <<?php echo($this->hl); ?>>
26
+                    <?php echo($this->headline); ?>
27
+                </<?php echo($this->hl); ?>>
28
+                <?php endif; ?>
29
+                <?php if ($this->subline) : ?>
30
+                    <span class="ce--subline"><?php echo $this->subline; ?></span>
31
+                <?php endif; ?>
32
+            </div>
33
+        </div>
34
+        <?php endif; ?>
35
+
36
+
37
+        <div class="ce--contentslider"
38
+             data-aos="<?php if ($this->animation_type) : ?><?php echo $this->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
39
+
40
+            <div class="<?php if (!$this->is_fullwidth): ?>container<?php else: ?>is-fullwidth<?php endif; ?> ce--inner">
41
+
42
+
43
+                <?php if ($this->nav_position == 1): ?>
44
+                    <div class="mt-3 mb-3 container horizontal content-slider--nav d-none d-md-block content-slider--nav_<?= $this->id; ?>">
45
+                        <ul>
46
+                            <?php foreach ($this->elements as $i => $nav) : ?>
47
+                                <li <?php if ($i == 0 && $this->element_type == 'is_slider'): ?>class="active"<?php endif; ?>>
48
+                                    <?php if ($this->element_type == 'is_slider'): ?>
49
+                                        <span data-slide="<?= $i; ?>">
50
+                            <?= $nav->slide_nav_text; ?>
51
+                            </span>
52
+                                    <?php elseif ($this->element_type == 'is_buttons'): ?>
53
+                                        <a href="<?= $nav->link_url; ?>"
54
+                                           <?php if ($nav->link_newtab): ?>target="_blank"<?php endif; ?>>
55
+                                            <?= $nav->slide_nav_text; ?>
56
+                                        </a>
57
+                                    <?php endif; ?>
58
+                                </li>
59
+                            <?php endforeach; ?>
60
+                        </ul>
61
+                    </div>
62
+                <?php endif; ?>
63
+
64
+
65
+                <div class="<?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>row<?php endif; ?> <?php if ($this->nav_position == 4): ?>flex-row-reverse<?php endif; ?>">
66
+                    <?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>
67
+                    <div class="col-12 col-md-6">
68
+                        <div class="nav-column half-container pt-1 pb-1 pt-lg-5 pb-lg-5">
69
+                            <?php if ($this->headline || $this->subline || $this->topline): ?>
70
+                            <div class="ce--headline"
71
+                                 data-aos="<?php if ($this->animation_type) : ?><?php echo $this->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
72
+                                <div class="">
73
+                                    <?php if ($this->topline) : ?>
74
+                                        <span class="ce--topline"><?php echo $this->topline; ?></span>
75
+                                    <?php endif; ?>
76
+                                    <?php if ($this->headline) : ?>
77
+                                    <<?php echo($this->hl); ?>>
78
+                                    <?php echo($this->headline); ?>
79
+                                </<?php echo($this->hl); ?>>
80
+                                <?php endif; ?>
81
+                                <?php if ($this->subline) : ?>
82
+                                    <span class="ce--subline"><?php echo $this->subline; ?></span>
83
+                                <?php endif; ?>
84
+                            </div>
85
+                        </div>
86
+                        <?php endif; ?>
87
+                        <div class="content-slider--nav vertical content-slider--nav_<?= $this->id; ?>">
88
+                            <ul>
89
+                                <?php foreach ($this->elements as $i => $nav) : ?>
90
+                                    <li <?php if ($i == 0 && $this->element_type == 'is_slider'): ?>class="active"<?php endif; ?>>
91
+                                        <?php if ($this->element_type == 'is_slider'): ?>
92
+                                            <span data-slide="<?= $i; ?>"><?= $nav->slide_nav_text; ?></span>
93
+                                        <?php elseif ($this->element_type == 'is_buttons'): ?>
94
+                                            <a href="<?= $nav->link_url; ?>"
95
+                                               <?php if ($nav->link_newtab): ?>target="_blank"<?php endif; ?>>
96
+                                                <?= $nav->slide_nav_text; ?>
97
+                                            </a>
98
+                                        <?php endif; ?>
99
+                                    </li>
100
+                                <?php endforeach; ?>
101
+                            </ul>
102
+                        </div>
103
+                    </div>
104
+                </div>
105
+            <?php endif; ?>
106
+
107
+                <div class="<?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>col-12 col-md-6<?php endif; ?>">
108
+                    <?php if ($this->element_type == 'is_slider'): ?>
109
+                    <div class="position-relative">
110
+                        <div class="content-slider content-slider_<?= $this->id; ?> swiper custom <?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>is-vertical<?php endif; ?>">
111
+                            <!-- Additional required wrapper -->
112
+                            <div class="swiper-wrapper">
113
+                                <!-- Slides -->
114
+                                <?php foreach ($this->elements as $slide) : ?>
115
+                                <?php
116
+                                if (!isset($slide->size) && $this->element_type == 'is_slider') {
117
+                                    $slide->{"size"} = "";
118
+                                }
119
+                                ?>
120
+
121
+                                <div class="swiper-slide">
122
+                                    <div class="<?php if ($this->nav_position == 1 || $this->nav_position == 2): ?> row align-items-center gx-lg-4 <?php if ($slide->row_reverse) : ?>flex-row-reverse <?php endif; ?><?php endif; ?>">
123
+
124
+
125
+                                        <?php if ($slide->image): ?>
126
+                                            <div class="<?php if (($this->nav_position == 3 || $this->nav_position == 4) && ($slide->longtext)): ?>mb-2<?php endif; ?>  <?php if (($this->nav_position == 1 || $this->nav_position == 2) && ($slide->longtext)): ?><?= $slide->column_width; ?><?php endif; ?>">
127
+                                                <img class="<?php if ($this->nav_position == 1 || $this->nav_position == 2): ?>swiper-lazy<?php endif; ?> slide-image"
128
+                                                     <?php if ($this->nav_position == 1 || $this->nav_position == 2): ?>data-<?php endif; ?>src="<?= Image::get(FilesModel::findByUuid($slide->image)->path, $slide->size[0], $slide->size[1], $slide->size[2]); ?>">
129
+
130
+                                            </div>
131
+                                        <?php endif; ?>
132
+
133
+                                        <?php if ($slide->longtext || $slide->text) : ?>
134
+                                        <div class="<?php if ($this->nav_position == 1 || $this->nav_position == 2): ?>col-12 col-md<?php else: ?>half-container<?php endif; ?>">
135
+
136
+                                            <?php if ($slide->text) : ?>
137
+                                            <div class="slide-caption">
138
+                                                <?php if (!$slide->onlystyle) : ?>
139
+                                                <<?php echo $slide->headline_type; ?>>
140
+                                                <?php echo $slide->text; ?>
141
+                                            </<?php echo $slide->headline_type; ?>>
142
+                                        <?php else : ?>
143
+                                            <span class="<?php echo $slide->headline_type; ?>">
144
+                                                                        <?php echo $slide->text; ?>
145
+                                                                    </span>
146
+                                        <?php endif; ?>
147
+                                        </div>
148
+                                    <?php endif; ?>
149
+
150
+                                        <?php if ($slide->longtext) : ?>
151
+                                            <div class="slide-description  <?php if (!$slide->image): ?>container<?php elseif ($this->nav_position == 3 || $this->nav_position == 4): ?>half-container<?php endif; ?>"><?php echo $slide->longtext; ?></div>
152
+                                        <?php endif; ?>
153
+                                    </div>
154
+                                    <?php endif; ?>
155
+                                </div>
156
+
157
+                            </div>
158
+                            <?php endforeach ?>
159
+                        </div>
160
+                    </div>
161
+
162
+                    <?php if (count($this->elements) > 1) : ?>
163
+                        <?php if ($this->show_pagination): ?>
164
+                            <div class="content-slider_<?= $this->id; ?> swiper-pagination"></div>
165
+                        <?php endif; ?>
166
+                        <?php if ($this->show_arrows): ?>
167
+                            <div class="content-slider_<?= $this->id; ?> swiper-button-prev"></div>
168
+                            <div class="content-slider_<?= $this->id; ?> swiper-button-next"></div>
169
+                        <?php endif; ?>
170
+                    <?php endif; ?>
171
+                </div>
172
+            <?php endif; ?>
173
+
174
+                <?php if ($this->element_type == 'is_buttons' && $this->fixed_image): ?>
175
+                    <div class="text-center fixed-image w-100 h-100 <?php if (!$this->is_fullwidth && ($this->nav_position == 3 || $this->nav_position == 4)): ?>half-container<?php endif; ?>">
176
+                        <div class="fixed-image--holder lazy w-100 h-100" data-bg="<?= Image::get(FilesModel::findByUuid($this->fixed_image)->path, $this->size_fixed[0], $this->size_fixed[1], $this->size_fixed[2]); ?>" style="background-position: center center; background-repeat: no-repeat;background-size: cover;">
177
+                        </div>
178
+                    </div>
179
+                <?php endif; ?>
180
+
181
+                <?php if ($this->nav_position == 2): ?>
182
+                    <div class="mt-3 container  horizontal content-slider--nav d-none d-md-block content-slider--nav_<?= $this->id; ?>">
183
+                        <ul>
184
+                            <?php foreach ($this->elements as $i => $nav) : ?>
185
+                                <li <?php if ($i == 0 && $this->element_type == 'is_slider'): ?>class="active"<?php endif; ?>>
186
+                                    <?php if ($this->element_type == 'is_slider'): ?>
187
+                                        <span data-slide="<?= $i; ?>">
188
+                                                <?= $nav->slide_nav_text; ?>
189
+                                                </span>
190
+                                    <?php elseif ($this->element_type == 'is_buttons'): ?>
191
+                                        <a href="<?= $nav->link_url; ?>"
192
+                                           <?php if ($nav->link_newtab): ?>target="_blank"<?php endif; ?>>
193
+                                            <?= $nav->slide_nav_text; ?>
194
+                                        </a>
195
+                                    <?php endif; ?>
196
+                                </li>
197
+                            <?php endforeach; ?>
198
+                        </ul>
199
+                    </div>
200
+                <?php endif; ?>
201
+            </div>
202
+        </div>
203
+
204
+
205
+    </div>
206
+    </div>
207
+    </div>
208
+    </div>
209
+
210
+
211
+<?php if ($this->element_type == 'is_slider' && TL_MODE == 'FE'): ?>
212
+    <script>
213
+        window.addEventListener('load', function () {
214
+            if ($('.swiper.content-slider_<?= $this->id;?>').length) {
215
+                const swiper_<?php echo $this->id; ?> = new Swiper('.swiper.content-slider_<?php echo $this->id; ?>', {
216
+
217
+
218
+                    <?php if ($this->nav_position == 3 || $this->nav_position == 4): ?>
219
+                    direction: 'horizontal',
220
+                    preloadImages: true,
221
+                    //freemode: true,
222
+                    autoHeight: true,
223
+
224
+
225
+
226
+                    <?php elseif ($this->nav_position == 1 || $this->nav_position == 2):?>
227
+
228
+                    direction: 'horizontal',
229
+                    loop: <?php if ($this->loop) : ?>true<?php else:?>false<?php endif;?>,
230
+                    lazy: {
231
+                        loadPrevNext: true,
232
+                    },
233
+
234
+
235
+                    <?php endif;?>
236
+
237
+                    <?php if ($this->mousehweel) : ?>
238
+                    mousewheel: true,
239
+                    <?php endif;?>
240
+
241
+                    speed: <?php if ($this->transition_time) : ?><?= $this->transition_time; ?><?php else:?>500<?php endif;?>,
242
+
243
+
244
+                    <?php if ($this->autoplay) : ?>
245
+                    autoplay: {
246
+                        delay: <?php if ($this->autoplay_time) : ?><?= $this->autoplay_time; ?><?php else:?>3000<?php endif;?>,
247
+                    },
248
+                    <?php endif; ?>
249
+
250
+                    effect: <?php if ($this->slide_effect) : ?>'<?= $this->slide_effect; ?>'
251
+                    <?php else:?>'slide'<?php endif;?>,
252
+                    <?php if ($this->slide_effect == "coverflow") : ?>
253
+                    coverflowEffect: {
254
+                        rotate: 50, // Slide rotate in degrees
255
+                        stretch: 0, // Stretch space between slides (in px)
256
+                        depth: 100, // Depth offset in px (slides translate in Z axis)
257
+                        modifier: 1, // Effect multipler
258
+                        slideShadows: true, // Enables slides shadows
259
+                    },
260
+                    <?php endif;?>
261
+
262
+                    <?php if ($this->slide_effect == "fade") : ?>
263
+                    fadeEffect: {
264
+                        crossFade: true
265
+                    },
266
+                    <?php endif;?>
267
+
268
+                    <?php if (count($this->elements) > 1) : ?>
269
+                    navigation: {
270
+                        nextEl: '.content-slider_<?= $this->id;?>.swiper-button-next',
271
+                        prevEl: '.content-slider_<?= $this->id;?>.swiper-button-prev',
272
+                    },
273
+
274
+                    pagination: {
275
+                        el: '.content-slider_<?php echo $this->id; ?>.swiper-pagination',
276
+                        clickable: true,
277
+                    },
278
+                    <?php endif; ?>
279
+
280
+                });
281
+
282
+
283
+                $('.content-slider--nav_<?= $this->id; ?> span').click(swiper_<?php echo $this->id; ?>, function () {
284
+                    swiper_<?php echo $this->id; ?>.slideTo($(this).data("slide") <?php if ($this->nav_position == 1 || $this->nav_position == 2): ?>+ 1<?php endif;?>);
285
+
286
+                    $('.content-slider--nav_<?= $this->id; ?> li.active').removeClass("active");
287
+                    $(this).parent("li").addClass("active");
288
+
289
+                })
290
+
291
+
292
+                swiper_<?php echo $this->id; ?>.on('slideChange', function () {
293
+                    $('.content-slider--nav_<?= $this->id; ?> li.active').removeClass("active");
294
+                    $('.content-slider--nav_<?= $this->id; ?> span[data-slide="' + (swiper_<?php echo $this->id; ?>.realIndex) + '"]').parent("li").addClass("active");
295
+                });
296
+
297
+            }
298
+        }, {passive: true})
299
+    </script>
300
+<?php endif; ?>
0 301
\ No newline at end of file