PageSourceSearch

https://caribana.ch/user/themes/customer/js/template.js?g-3fdb6a95

js caribana.ch collected 2026-10-02 19:40:10 UTC 15,790 bytes, 425 lines download raw bytes

1// Fonction notice
2var isMobile = false;
3var lastScrollY;
4var lastWindowWidth;
5var lastPreviousScrollY;
6
7/* SET VARS */
8const updateVars = () => {
9    let noticeHeight = parseInt($('#page-notice').length ? $('#page-notice').height() : 0);
10    let navigationHeight = parseInt($('#navigation').length ? $('#navigation').height() : 0);
11    let navigationY = $('#navigation').length ? 0 : 0
12
13    if( $('#navigation').length ){
14        let transformMatrix = $('#navigation').css('transform').slice(7, $('#navigation').css('transform').length - 1).split(', ')
15        navigationY = parseInt(transformMatrix[5]);
16        navigationY = navigationY ? navigationY : 0;
17    }
18
19    navigationY += navigationHeight;
20    //navigationY += noticeHeight;
21
22    const doc = document.documentElement
23    doc.style.setProperty('--app-height', `${window.innerHeight}px`)
24    doc.style.setProperty('--nav-height', navigationHeight + 'px')
25    doc.style.setProperty('--nav-mobile-height', $('.navigation-mobile-wrapper-body').height() + 'px')
26    doc.style.setProperty('--notice-height', noticeHeight + 'px')
27    doc.style.setProperty('--nav-sticky', (navigationY - 1) + 'px')
28
29
30}
31
32function keyframe(timestamp) {
33    updatePagekeyframe(false)
34    window.requestAnimationFrame(keyframe);
35}
36
37window.requestAnimationFrame(keyframe);
38
39function updatePagekeyframe(force){
40    var scrollElm = $(window);
41
42    updateVars();
43
44    if( force || lastWindowWidth !== scrollElm.width() || lastScrollY !== scrollElm.scrollTop() ){
45        lastScrollY = scrollElm.scrollTop();
46        lastWindowWidth = scrollElm.width();
47
48        stickyHeader();
49        updateLayout();
50    }
51}
52
53function isElementCenterInViewport(el) {
54    var rect = el.getBoundingClientRect();
55    var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
56    var elementHeight = rect.bottom - rect.top;
57
58    // Calcul de la position verticale du centre de l'élément
59    var elementCenterVertical = (rect.top + rect.bottom) / 2;
60
61    return (elementCenterVertical >= 0 && elementCenterVertical <= viewportHeight && elementHeight <= viewportHeight);
62}
63
64function updateLayout(){
65
66    var animatedElements = document.querySelectorAll('[data-scroll-animation]');
67
68    animatedElements.forEach(function(element) {
69        let elementClass = element.getAttribute('data-scroll-animation')
70        if (isElementCenterInViewport(element)) {
71            element.classList.add(elementClass);
72        } else {
73            if( $('body').hasClass("scroll-up") )
74            {
75                //element.classList.remove(elementClass);
76            }
77        }
78    });
79
80    $('.parallax').each(function(){
81
82        var obj = $(this);
83        var top = obj.parent().offset().top;
84        var h = obj.parent().height();
85        var dataSpeed = obj.attr('data-speed') ? obj.attr('data-speed') : 0.5;
86        var center = obj.attr('data-center') ? 50 : 0;
87        var clip = obj.parent().hasClass("parallax-clip");
88        var windowH = $(window).height();
89        var diff = 0;
90
91        /*
92        // CENTER
93        if( top + h/2 <= windowH/2 ){
94            diff = (windowH/2 - (top + h/2)) * dataSpeed ;
95        }
96
97        var y = (((lastScrollY + windowH/2) - (top + h/2)) * dataSpeed) - (diff) ;
98        y = ((50 + (y * -0.075)) * -1) + "%";
99
100        TweenLite.to(obj, 0, {ease: Expo.easeInOut, top:'50%', left: '50%', x:'-50%', y:y, scale: clip ? 1.05 : 1, force3D:true});
101        */
102
103        if( top + h/2 <= windowH/2 ){
104            diff = (windowH/2 - (top + h/2)) * dataSpeed ;
105        }
106
107        var y = (((lastScrollY + windowH/2) - (top + h/2)) * dataSpeed) - (diff) ;
108        y = ((center + (y * -0.075)) * -1) + "%";
109
110        /*
111        if( obj.parent().find('.debug').length <= 0 ){
112            obj.parent().append('<div class="debug"></div>');
113            obj.parent().find('.debug').css({textAlign: 'right', background:'red', position:'absolute', top: 0, left: 0, width:'100%', zIndex:100, overflow: 'hidden'});
114            obj.parent().find('.debug').css({top: (h/2), transform: 'translateY(-50%)'});
115        }
116        obj.parent().find('.debug').html(y + " " + (diff));
117        */
118
119        if( center ){
120            TweenLite.to(obj, 0, {ease: Expo.easeInOut, top:'50%', left: '50%', x:'-50%', y:y, scale: clip ? 1.05 : 1, force3D:true});
121        }else{
122            TweenLite.to(obj, 0, {ease: Expo.easeInOut, y:y, scale: clip ? 1.1 : 1, force3D:true});
123        }
124        //TweenLite.to(obj, 0, {ease: Expo.easeInOut, top:'50%', left: '50%', x:'-50%', y:y, scale: clip ? 1.05 : 1, force3D:true});
125
126
127    });
128
129}
130
131function stickyHeader() {
132
133    // Fix navigation on scroll down at x px
134    var scrollLimitFixed = 100;
135    // Hide navigation on scroll down at x px
136    var scrollLimitDownHide = 800;//$(window).height() / 2;
137    var hideOnScroll = $('.page-navigation[data-scroll-hide]').length ? true : false;
138    var scrollLimitUp = 0;
139    var scrollDirectionUp = false;
140    var scrollDirectionDown = false;
141
142    if( !hideOnScroll ){
143        scrollLimitDownHide = 99999999999999999999;
144    }
145
146    var hasNavigation = $("#navigation").length > 0 ? true : false;
147    if( hasNavigation == false ){ return false; }
148
149    //--------------------------------------
150    // Calculate max navigation to force minified version
151    var margin = 0; //($(window).width() - $(".navigation .wrapper").innerWidth())/2;
152    var navigationWidth = $("#navigation").data('max-width') ? $("#navigation").data('max-width') : $(".navigation .navigation-wrapper").innerWidth() + margin;
153
154    if( navigationWidth > $(window).width()){
155        $("body").addClass("navigation-minified");
156        $("#navigation").data('max-width', navigationWidth)
157    }else{
158        $("body").removeClass("navigation-minified");
159        $("#navigation-open").prop('checked', false);
160    }
161    //--------------------------------------
162
163    var navbar = $("#navigation");
164    var navbarTop = $('.navigation-wrapper-top').length ? $('.navigation-wrapper-top').height() : 0;
165
166    if (lastPreviousScrollY > lastScrollY) {
167        // Scroll UP
168        $("body").removeClass("scroll-down").addClass("scroll-up");
169        lastScrollUp = lastScrollY;
170        scrollDirectionUp = true;
171    }
172    if (lastPreviousScrollY < lastScrollY) {
173        // Scroll DOWN
174        $("body").removeClass("scroll-up").addClass("scroll-down");
175        lastScrollDown = lastScrollY;
176        scrollDirectionDown = true;
177    }
178
179    if(lastScrollY >= scrollLimitFixed && scrollDirectionDown){
180        navbar.addClass("navigation-fixed");
181        $('html').addClass('navigation-fixed');
182
183        if( !navbar.hasClass("navigation-fixed-hide") )
184        {
185            TweenLite.to(navbar, 0.2, {ease: Expo.linear, y:(navbarTop*-1), force3D:true});
186        }
187
188    }
189
190    if(lastScrollY <= scrollLimitFixed && scrollDirectionUp){
191        navbar.removeClass("navigation-fixed");
192        $('html').removeClass('navigation-fixed');
193    }
194
195    if(lastScrollY >= scrollLimitDownHide && scrollDirectionDown){
196        navbar.addClass("navigation-fixed-hide");
197        TweenLite.to(navbar, 0.2, {ease: Expo.linear, y:"-100%", force3D:true});
198    }
199
200    if(scrollDirectionUp){
201        navbar.removeClass("navigation-fixed-hide");
202        let y = 0;
203        if(lastScrollY >= scrollLimitFixed)
204        {
205            y = navbarTop;
206        }
207        TweenLite.to(navbar, 0.2, {ease: Expo.linear, y:(y*-1), force3D:true});
208    }
209
210    updateLayout()
211
212    lastPreviousScrollY = lastScrollY;
213}
214
215function showHeaderNotice() {
216    var cookieName = "notice";
217    var now = new Date();
218
219    $('.page-notice button').unbind().click(function(e){
220        e.stopPropagation();
221        e.preventDefault();
222        // assign notice to current time + 1
223        localStorage.setItem(cookieName, now.getTime() + 60 * 1000 ); // 60 minutes
224        $(this).parent().slideUp();
225        setTimeout(function() {
226            $(this).parent().hide();
227        }, 2000);
228        return false;
229    });
230
231    // check if notice === null
232    if( localStorage.getItem(cookieName) == null ) {
233        $('.page-notice').show();
234    }else{
235        //if current time is bigger than notice, relaunch the function
236        if( now.getTime() > localStorage.getItem(cookieName) ){
237            localStorage.removeItem(cookieName);
238            showHeaderNotice();
239        }
240    }
241}
242
243
244var swipersContainer = [];
245
246function initializeSwipers() {
247
248    $("[id*='swiper_']").each(function() {
249
250        let swip = $(this).hasClass('swiper') ? $(this) : $(this).find(".swiper");
251
252        var id = $(this).attr('id'),
253            pagination = swip.data('pagination') || null,
254            navigation = swip.data('navigation') || null,
255            limit = swip.data('limit') || "auto",
256            centeredSlides = swip.data('centered-slides') || false,
257            space_between = swip.data('space-between') || 0,
258            limit_navigation = swip.data('limit-navigation') || false,
259            scrollbar = swip.data('scrollbar') || null,
260            default_options = swip.data('default-options') || null;
261
262        if( window[default_options] )
263        {
264            var swiperOptions = window[default_options]();
265        }else{
266            var swiperOptions = {
267                slidesPerView: limit,
268                centeredSlides: centeredSlides,
269                spaceBetween: space_between,
270                breakpoints: {
271                    0: {
272                        slidesPerView: 1
273                    },
274                    740: {
275                        slidesPerView: 2
276                    },
277                    1000: {
278                        slidesPerView: limit,
279                    }
280                }
281            };
282
283            swiperOptions.breakpoints[1000].slidesPerView = limit;
284
285            if(limit_navigation) {
286                swiperOptions.breakpoints[1000].allowSlideNext = false;
287                swiperOptions.breakpoints[1000].allowSlidePrev = false;
288            }
289        }
290
291        if (pagination) {
292            swiperOptions.pagination = {
293                el: '#' + id + ' .swiper-pagination',
294                clickable: true
295            }
296        }
297
298        if (navigation) {
299            swiperOptions.navigation = {
300                nextEl: '#' + id + ' .swiper-navigation-next',
301                prevEl: '#' + id + ' .swiper-navigation-prev',
302            }
303        }
304
305        if (scrollbar) {
306            swiperOptions.scrollbar = {
307                el:  '#' + id + ' .swiper-scrollbar',
308            }
309        }
310        if( $(this).hasClass('swiper') ){
311            swipersContainer[id] = new Swiper('#' + id, swiperOptions);
312        }else{
313            swipersContainer[id] = new Swiper('#' + id + " .swiper", swiperOptions);
314        }
315
316    });
317}
318
319
320
321//window.addEventListener('resize', updateVars)
322
323
324$(document).ready(function() {
325    showHeaderNotice();
326    updateVars();
327
328    setTimeout(function(){
329        updatePagekeyframe(true);
330        updatePagekeyframe(true);
331    }, 100);
332
333    $("a[href='#']").click(function(e) {
334        e.preventDefault();
335    });
336
337    // data-clickable true
338    $('[clickable],[data-clickable]').click(function(){
339        var link = $(this).find('a:not([data-clickable-notfollow])').attr('href');
340        if(link){ location.href = link; }
341        return false;
342    });
343
344    $(this).find('a[data-clickable-notfollow]').click(function(e){
345        e.preventDefault();
346        location.href = $(this).attr('href');
347        return false;
348    });
349
350    $('a[href^="#"]').click(function(){
351        console.log("test")
352        if( $(this).attr("href") == "" || $(this).attr("href") == '#'){ return false; }
353        if( $($(this).attr("href")).length ){
354            $('html,body').animate({
355                scrollTop: $($(this).attr("href")).offset().top
356            }, 500);
357        }
358        return false;
359    });
360
361
362    // DETECT MOBILE
363    if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
364        || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
364substr(0,4))) {
365        isMobile = true;
366    }
367    if( isMobile ){
368        $('html').addClass('mobile');
369    }else{
370        $('html').addClass('desktop');
371    }
372
373    initializeSwipers();
374
375
376    function createRipple(event) {
377        const button = event.currentTarget;
378
379        const circle = document.createElement("span");
380        const diameter = Math.max(button.clientWidth, button.clientHeight);
381        const radius = diameter / 2;
382
383        circle.style.width = circle.style.height = `${diameter}px`;
384        circle.style.left = `${event.clientX - button.offsetLeft - radius}px`;
385        circle.style.top = `${event.clientY - button.offsetTop - radius}px`;
386        circle.classList.add("ripple");
387
388        const ripple = button.getElementsByClassName("ripple")[0];
389
390        if (ripple) {
391            ripple.remove();
392        }
393
394        button.appendChild(circle);
395    }
396
397    const buttons = document.querySelectorAll(".navigation-mobile a, button[class*='button'], a[class*='button']");
398    for (const button of buttons) {
399        button.addEventListener("click", createRipple);
400    }
401
402    $('.navigation-mobile').find('a').on('click', function(){
403        var elm = $(this);
404        var hasChild = elm.find("~ .container").length;
405        if(hasChild){
406            elm.find("~ .container").addClass('active');
407            elm.parent().parent().parent().addClass('hide');
408            return false;
409        }else{
410            $("#navigation-open").prop('checked', false);
411        }
412    });
413
414    $('.navigation-mobile').find('.back a').on('click', function(){
415        var elm = $(this);
416        elm.parent().parent().parent().parent().parent().scrollTop(0)
417        elm.parent().parent().parent().parent().parent().parent().removeClass('hide')
418        elm.parent().parent().parent().removeClass('hide')
419        elm.parent().parent().parent().removeClass('active')
420        elm.parent().parent().find('.container.active').removeClass('active');
421        return false;
422    });
423
424});
425

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.