PageSourceSearch

https://www.metrolisboa.pt/wp-content/plugins/wp-latest-posts/js/wplp_front.js?ver=5.0.11

js metrolisboa.pt collected 2026-10-01 08:57:39 UTC 15,485 bytes, 356 lines download raw bytes

1jQuery(document).ready(function ($) {
2    $('[id^="wplp_widget_"].default').each(function () {
3        var wplp_swiper = $(this);
4        widget_id = $(this).data('post');
5        widget_params = window['WPLP_' + widget_id];
6
7        if (widget_params !== undefined) {
8            $('.wplp-swiper .swiper-button-next').show();
9            $('.wplp-swiper .swiper-button-prev').show();
10            $('.wplp-swiper .swiper-pagination'). show();
11            var mySwiperParams = {
12                spaceBetween: 15,
13                watchOverflow: true,
14                noSwipingClass: 'swiper-no-swiping',
15                // Responsive breakpoints
16                breakpoints: {
17                    // when window width is >= 320px
18                    320: {
19                        slidesPerView: 1,
20                        slidesPerGroup: 1,
21                        spaceBetweenSlides: parseInt(widget_params.space_between)
22                    }
23                }
24            };
25
26            // 0 = None
27            // 1 = Arrows
28            // 2 = Arrows with bullets
29            // 3 = Bullets
30            if (typeof widget_params.pagination != 'undefined') {
31                switch (widget_params.pagination) {
32                    case '0':
33                        mySwiperParams.navigation = {
34                            enabled: false
35                        };
36                        break;
37                    case '1':
38                        mySwiperParams.navigation = {
39                            nextEl: '.swiper-button-next',
40                            prevEl: '.swiper-button-prev',
41                        };
42                        break;
43                    case '2':
44                        mySwiperParams.navigation = {
45                            nextEl: '.swiper-button-next',
46                            prevEl: '.swiper-button-prev',
47
48                        };
49                        mySwiperParams.pagination = {
50                            el: '.swiper-pagination',
51                            clickable: true,
52                            type: 'bullets',
53                        };
54                        break;
55                    case '3':
56                        mySwiperParams.navigation = {
57                            enabled: false
58                        };
59                        mySwiperParams.pagination = {
60                            el: '.swiper-pagination',
61                            clickable: true,
62                            type: 'bullets',
63                        };
64                        break;
65                }
66            }
67
68            if (typeof widget_params.space_between != 'undefined' && !isNaN(widget_params.space_between)) {
69                mySwiperParams.spaceBetween = parseInt(widget_params.space_between);
70            }
71
72            if (typeof widget_params.layzyload_img != 'undefined') {
73                switch (widget_params.layzyload_img) {
74                    case '0':
75                        mySwiperParams.lazy = false;
76                        break;
77                    case '1':
78                        mySwiperParams.lazy = true;
79                        mySwiperParams.preloadImages = false;
80                        break;
81                } 
82            }
83
84            // Enable loop by default
85            mySwiperParams.loop = true;
86            if (typeof widget_params.addon_enable != 'undefined' && widget_params.addon_enable == '1') {
87                if (typeof widget_params.slidespeed != 'undefined' && !isNaN(widget_params.slidespeed)) {
88                    mySwiperParams.speed = parseInt(widget_params.slidespeed);
89                }
90
91                if (typeof widget_params.animationloop != 'undefined') {
92                    switch (widget_params.animationloop) {
93                        case '0':
94                            mySwiperParams.loop = false;
95                            break;
96                        case '1':
97                            mySwiperParams.loop = true;
98                            break;
99                    }
100                }
101
102                if (typeof widget_params.touch != 'undefined') {
103                    switch (widget_params.touch) {
104                        case '0':
105                            wplp_swiper.find('.swiper-wrapper').removeClass('swiper-no-swiping');
106                            break;
107                        case '1':
108                            wplp_swiper.find('.swiper-wrapper').addClass('swiper-no-swiping');
109                            break;
110                    }
111                }
112            } else {
113                widget_params.slideshowspeed = 7000;
114                mySwiperParams.speed = 600;
115            }
116
117            if (typeof widget_params.autoanimate != 'undefined' && widget_params.autoanimate == '1'
118                && typeof widget_params.slideshowspeed != 'undefined' && !isNaN(widget_params.slideshowspeed)) {
119                mySwiperParams.autoplay = {
120                    delay: parseInt(widget_params.slideshowspeed)
121                };
122            }
123
124            // animation
125            // 0 = fade
126            // 1 = slide
127            if (typeof widget_params.autoanimatetrans != 'undefined') {
128                switch (widget_params.autoanimatetrans) {
129                    case '0':
130                        mySwiperParams.effect = 'fade';
131                        mySwiperParams.fadeEffect = {
132                            crossFade: true
133                        };
134                        break;
135                    case '1':
136                        mySwiperParams.effect = "slide";
137                        break;
138                }
139            }
140            
141            if (typeof widget_params.slidedirection != 'undefined') {
142                let nbcol = 1;
143                let nbrow = 1;
144                if (typeof widget_params.nbcol != 'undefined') {
145                    nbcol = parseInt(widget_params.nbcol);
146                }
147                if (typeof widget_params.nbrow != 'undefined') {
148                    nbrow = parseInt(widget_params.nbrow);
149                }
150
151                switch (widget_params.slidedirection) {
152                    case '0':
153                        mySwiperParams.direction = 'horizontal';
154                        if (nbcol > 0 && nbrow > 0) {
155                            mySwiperParams.slidesPerView = nbcol;
156                            mySwiperParams.slidesPerGroup = nbcol;
157
158                            // fade effect only work well with one slide per view, slidesPerView = 1;
159                            if (mySwiperParams.slidesPerView > 1 ) {
160                                mySwiperParams.effect = 'slide';
161                            }
162
163                            if (mySwiperParams.slidesPerView > 1 ) {
164                                if (mySwiperParams.lazy) {
165                                    mySwiperParams.watchSlidesProgress = true;
166                                }
167
168                                mySwiperParams.breakpoints['768'] = {
169                                    slidesPerView: 2,
170                                    slidesPerGroup: 2,
171                                    spaceBetweenSlides: parseInt(widget_params.space_between)
172                                };
173
174                                if (mySwiperParams.slidesPerView >= 2) {                                            
175                                    mySwiperParams.breakpoints['992'] = {
176                                        slidesPerView: mySwiperParams.slidesPerView,
177                                        slidesPerGroup: mySwiperParams.slidesPerView,
178                                        spaceBetweenSlides: parseInt(widget_params.space_between)
179                                    };
180                                }   
181                            }
182
183                            if (nbrow > 1) {
184                                mySwiperParams.loop = false; // Loop don't work with multiple row
185                                if (mySwiperParams.effect !== 'fade') {
186                                    mySwiperParams.grid = {
187                                        fill: 'row',
188                                        rows: nbrow
189                                    }
190
191                                    mySwiperParams.breakpoints['320'].grid = {
192                                        fill: 'column',
193                                        rows: nbrow
194                                    };
195                                    if (typeof mySwiperParams.breakpoints['768'] != 'undefined') {
196                                        mySwiperParams.breakpoints['768'].grid = {
197                                            fill: 'row',
198                                            rows: nbrow
199                                        };
200                                    }
201
202                                    if (typeof mySwiperParams.breakpoints['992'] != 'undefined') {
203                                        mySwiperParams.breakpoints['992'].grid = {
204                                            fill: 'row',
205                                            rows: nbrow
206                                        };
207                                    }                
208                                } else {
209                                    mySwiperParams.loop = true;
210                                }
211                            }
212                        }
213                        break;
214                    case '1': // vertical: only work with one slide per view
215                        mySwiperParams.direction = 'vertical';
216                        break;
217                }
218            }
219
220            var mySwiper = new Swiper('#wplp_widget_' + widget_params.id, mySwiperParams);
221
222            mySwiper.on('slideChange', function () {
223                setTimeout(function() {
224                    if (mySwiperParams.grid === 'undefined') {
225                        mySwiper.visibleSlides.find('.swiper-lazy-preloader').remove();
226                    } else {
227                        $('#wplp_widget_' + widget_params.id).find('.swiper-lazy-preloader').remove();
228                    }
229                }, 500);
230            });
231
232            if (typeof widget_params.addon_enable != 'undefined' && widget_params.addon_enable == '1' && typeof mySwiperParams.autoplay != 'undefined') {
233                var check_pauseaction = 0;
234                if (typeof widget_params.pausehover != 'undefined' && widget_params.pausehover == '1') {
235                    $('.wplp-swiper').mouseenter(function() {
236                        mySwiper.autoplay.stop();
237                    });
238
239                    $('.wplp-swiper').mouseleave(function() {
240                        if (!check_pauseaction) {
241                            mySwiper.autoplay.start();
242                        }
243                    });
244                }
245
246                if (typeof widget_params.pauseaction != 'undefined') {
247                    switch (widget_params.pauseaction) {
248                        case '0':
249                            $('.swiper-button-next').click(function() {
250                                mySwiper.autoplay.start();
251                            });
252                            $('.swiper-button-prev').click(function() {
253                                mySwiper.autoplay.start();
254                            });
255                            break;
256                        case '1':
257                            $('.swiper-button-next').click(function() {
258                                check_pauseaction = 1;
259                                mySwiper.autoplay.stop();
260                            });
261                            $('.swiper-button-prev').click(function() {
262                                check_pauseaction = 1;
263                                mySwiper.autoplay.stop();
264                            });
265                            break;
266                    }
267                }
268            }
269
270            if (wplp_swiper.hasClass('swiper-vertical')) {
271                var height = wplp_swiper.find('.swiper-slide .thumbnail:first').height();
272                height = parseInt(height) - 35;
273                wplp_swiper.height(height);
274            }
275            if (wplp_swiper.hasClass('swiper-horizontal')) {
276                if ($(window).width() <= 767) {
277                    $('#wplp_widget_' + widget_params.id+' .wplp_listposts.swiper-wrapper').addClass('swiper-slide-mb');
278                } else {
279                    $('#wplp_widget_' + widget_params.id+' .wplp_listposts.swiper-wrapper').removeClass('swiper-slide-mb');
280                }
281            }
282        }
283    });
284    
285    $(window).resize(function(){
286        $('[id^="wplp_widget_"].default').each(function () {
287            if ($(this).hasClass('swiper-vertical')) {
288                var height = $(this).find('.swiper-slide .thumbnail:first').height();
289                height = parseInt(height) - 35;
290                $(this).height(height);
291            }
292            if ($(this).hasClass('swiper-horizontal')) {
293                if ($(window).width() <= 767) {
294                    $('#wplp_widget_' + widget_params.id+' .wplp_listposts.swiper-wrapper').addClass('swiper-slide-mb');
295                } else {
296                    $('#wplp_widget_' + widget_params.id+' .wplp_listposts.swiper-wrapper').removeClass('swiper-slide-mb');
297                }
298            }
299        })
300    });
301});
302
303(function ( $ ) {
304    $.fn.wplp_swiper = function(options, settings) {
305        var swiper = new Swiper(`#wplp_widget_${settings.id}.wplp_widget_default`, options);
306        swiper.on('slideChange', function () {
307            setTimeout(function() {
308                if (options.grid === 'undefined') {
309                    swiper.visibleSlides.find('.swiper-lazy-preloader').remove();
310                } else {
311                    $('#wplp_widget_' + settings.id).find('.swiper-lazy-preloader').remove();
312                }
313            }, 500);
314        });
315        console.log(options);
316        if (typeof settings.addon_enable != 'undefined' && settings.addon_enable == '1' && typeof options.autoplay != 'undefined') {
317            var check_pauseaction = 0;
318            if (typeof settings.pausehover != 'undefined' && settings.pausehover == '1') {
319                $('.wplp-swiper').mouseenter(function() {
320                    swiper.autoplay.stop();
321                });
322
323                $('.wplp-swiper').mouseleave(function() {
324                    if (!check_pauseaction) {
325                        swiper.autoplay.start();
326                    }
327                });
328            }
329
330            if (typeof settings.pauseaction != 'undefined') {
331                switch (settings.pauseaction) {
332                case '0':
333                    $('.swiper-button-next').click(function() {
334                        swiper.autoplay.start();
335                    });
336                    $('.swiper-button-prev').click(function() {
337                        swiper.autoplay.start();
338                    });
339                    break;
340                case '1':
341                    $('.swiper-button-next').click(function() {
342                        check_pauseaction = 1;
343                        swiper.autoplay.stop();
344                    });
345                    $('.swiper-button-prev').click(function() {
346                        check_pauseaction = 1;
347                        swiper.autoplay.stop();
348                    });
349                    break;
350                }
351            }
352        }
353
354        return true;
355    };
356}( jQuery ));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.