PageSourceSearch

https://welcome-suisse.ch/wp-content/themes/magic-mag/js/main.js

js welcome-suisse.ch collected 2026-10-09 05:14:09 UTC 21,753 bytes, 617 lines download raw bytes

1jQuery(document).ready(function() {
2
3    var $doc          = jQuery(document),
4        $window       = jQuery(window),
5        $html         = jQuery('html'),
6        $wrapper      = jQuery('body'),
7        $pos_id       = jQuery('.post-content-bd');
8
9    var $bdGoTopOffset      = 220;
10    var $bdGoTopDuration    = 500;
11    var $bdGoTopClass       = jQuery('#go-top');
12
13    jQuery(window).on("scroll",function(){
14        if (jQuery(this).scrollTop() > $bdGoTopOffset){
15            $bdGoTopClass.css({ opacity: "1", bottom: "50px" });
16        }
17        else {
18            $bdGoTopClass.css({ opacity: "0", bottom: "-100px" });
19        }
20    });
21
22    $bdGoTopClass.on("click",function(event){
23        event.preventDefault();
24        jQuery( "html,body" ).animate( {scrollTop: 0}, $bdGoTopDuration );
25        return false;
26    });
27
28    /**
29     Main JS
30     ----------------------------------------------------------------------------- */
31    initTabGroup();
32
33
34    jQuery('input, textarea').placeholder();
35    jQuery(".post-content-bd, .post-video-wrap, .bd-video-widget").fitVids();
36    jQuery( "a.menu-trigger, .bd-slider .flex-control-nav li a, .popup-with-zoom-anim, #check-also-close" ).on("click",function(event){
37        event.preventDefault(event);
38    });
39
40    /**
41     Login Popup
42     ----------------------------------------------------------------------------- */
43    jQuery('.login-pp a').magnificPopup({
44        type: 'inline',
45        fixedContentPos: true,
46        fixedBgPos: true,
47        overflowY: 'auto',
48        closeBtnInside: true,
49        preloader: false,
50        midClick: true,
51        removalDelay: 300,
52        mainClass: 'my-mfp-zoom-in'
53    });
54
55    /**
56     Search in top menu
57     ----------------------------------------------------------------------------- */
58    jQuery(".search-btn").on("click",function(event){
59        if(
60            jQuery(this).hasClass("active")){
61            jQuery(this).removeClass("active");
62            jQuery(".search-btn").removeClass("active");
63            jQuery(".search-dropdown").stop().slideUp('fast');
64            return false
65        }
66        else{
67            jQuery(this).addClass("active");
68            jQuery(".search-btn").addClass("active");
69            jQuery(".search-dropdown").stop().slideDown('fast');
70            return false
71        }}
72    );
73
74    /**
75     Mobile Nav Menu Drop Down
76     ----------------------------------------------------------------------------- */
77    jQuery("a.menu-trigger").on("click",function(){if(
78            jQuery(this).hasClass("active")){
79            jQuery(this).removeClass("active");
80            jQuery("a.menu-trigger").removeClass("active");
81            jQuery(".primary-menu-drop").stop().slideUp('fast');
82            return false
83        }else{
84            jQuery(this).addClass("active");
85            jQuery("a.menu-trigger").addClass("active");
86            jQuery(".primary-menu-drop").stop().slideDown('fast');
87            return false
88        }}
89    );
90
91    /**
92     Mobile Top Menu Drop Down
93     ----------------------------------------------------------------------------- */
94    jQuery(".top-mob-btn").on("click",function(){if(
95            jQuery(this).hasClass("active")){
96            jQuery(this).removeClass("active");
97            jQuery(".top-mob-btn").removeClass("active");
98            jQuery(".top-menu-drop").stop().slideUp('fast');
99            return false
100        }else{
101            jQuery(this).addClass("active");
102            jQuery(".top-mob-btn").addClass("active");
103            jQuery(".top-menu-drop").stop().slideDown('fast');
104            return false
105        }}
106    );
107
108    /**
109     Breaking News
110     ----------------------------------------------------------------------------- */
111    jQuery( '.breaking-news ul, #breakingNews ul' ).each(function() {
112        jQuery('.breaking-news ul li, #breakingNews ul li').addClass('wow animated flipInX');
113
114        if ( ! jQuery(this).find( 'li.active' ).length ) {
115            jQuery(this).find( 'li:first' ).addClass('active');
116        }
117
118        var ticker = jQuery( this );
119        window.setInterval( function() {
120
121            var active = ticker.find('li.active');
122            active.fadeOut(function() {
123
124                var next = active.next();
125                if (!next.length) {
126                    next = ticker.find('li:first');
127                }
128
129                next.addClass('active').fadeIn();
130                active.removeClass('active');
131            });
132
133        }, 6000);
134    });
135
136    /**
137     Shortcodes toggle
138     ----------------------------------------------------------------------------- */
139    jQuery('div.toggle h4').on("click",function(event){
140        var text = jQuery(this).siblings('div.panel');
141        if (text.is(':hidden')) {
142            text.slideDown( 'fast' );
143            jQuery(this).siblings('span').html('-');
144        } else {
145            text.slideUp( 'fast' );
146            jQuery(this).siblings('span').html('+');
147        }
148    });
149
150
151    /**
152     Sticky navigation
153     ----------------------------------------------------------------------------- */
154    var stickySidebarTop = 0;
155    if ( !bdayh_isMobile.any() ) {
156        if ($window.width() > 1000) {
157            if (jQuery('body').hasClass('sticky-nav-on')) {
158
159                var $bd_nav = jQuery('#navigation');
160                var $bd_wpadminbar = jQuery('#wpadminbar');
161
162                if ($bd_wpadminbar.length) {
163                    stickySidebarTop = 82;
164                }
165                else {
166                    stickySidebarTop = 50;
167                }
168
169                jQuery('#header').imagesLoaded(function () {
170                    var bd_above_Height = jQuery('#header').outerHeight();
171
172                    $window.scroll(function () {
173                        if ($window.scrollTop() > bd_above_Height) {
174                            if ($bd_wpadminbar.length) {
175                                $bd_nav.addClass('sticky-nav').css('top', '32px');
176                            }
177                            else {
178                                $bd_nav.addClass('sticky-nav').css('top', '0');
179                            }
180                        }
181                        else {
182                            $bd_nav.removeClass('sticky-nav').css('top', 0);
183                        }
184                    });
185                });
186            }
187        }
188    }
189
190    /**
191     Sticky Sidebar
192     ----------------------------------------------------------------------------- */
193
194    if ( jQuery(window).width() > 800 && bd.sticky_sidebar ) {
195        jQuery( '.sidebar' ).theiaStickySidebar( {
196            "additionalMarginTop"   : 32,
197            'minWidth'              : 990
198        } );
199    }
200    // END Sticky Sidebar. -----
201
202
203
204    /**
205     Mobile Menu
206     ----------------------------------------------------------------------------- */
207    jQuery(".bd-ClickAOpen").on("click",function(event){
208        var $bd_page        = jQuery('#page');
209        var $bd_body        = jQuery('body');
210        var $bd_MMClass     = jQuery('.bd-MobileSiderbar');
211        var $bd_MMClickOpen = jQuery('.bd-ClickAOpen');
212
213        if( jQuery(this).hasClass( "bd-ClickAOpen" )) {
214
215            $bd_page.css( {overflow:"hidden"} );
216            $bd_body.addClass( 'js-nav' );
217            $bd_MMClass.addClass( 'bd-MobileSiderbarShow' );
218            jQuery(this).removeClass('bd-ClickAOpen').addClass('bd-ClickAClose');
219
220            return false;
221        }
222        else if( jQuery(this).hasClass( "bd-ClickAClose" ) ) {
223
224            $bd_page.css({overflow:"auto"});
225            $bd_body.removeClass( 'js-nav' );
226            $bd_MMClass.removeClass( 'bd-MobileSiderbarShow' );
227            jQuery(this).removeClass('bd-ClickAClose').addClass('bd-ClickAOpen');
228
229            return false;
230        }
231    });
232
233    // Add Mobile Menu item icon
234    jQuery( ".bd-MobileSiderbar #mobile-menu .menu-item-has-children" ).append( '<i class="mobile-arrows fa fa-chevron-down"></i>' );
235    jQuery(document).on("click", "#mobile-menu .menu-item-has-children i.mobile-arrows", function()
236    {
237        if( jQuery(this).hasClass( "fa-chevron-down" ) ) {
238            jQuery(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
239        }
240        else {
241            jQuery(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
242        }
243        jQuery(this).parent().find('ul:first').toggle();
244    });
245
246    /**
247     Check Also
248     ----------------------------------------------------------------------------- */
249    jQuery(function(){
250        var $bdCheckAlso = jQuery("#bdCheckAlso");
251        var $bdCheckAlsoRight  = jQuery(".bdCheckAlso-right");
252
253        if( !bdayh_isMobile.any() && bd.is_singular && $bdCheckAlso.length > 0 )
254        {
255            var articleOffset = $pos_id.offset().top + ( $pos_id.outerHeight()/2 );
256            var bdCheckAlsoClosed = false;
257
258            if( $window.width() <= 1120 ) {
259                $bdCheckAlso.hide()
260            }
261            else {
262                $bdCheckAlso.show()
263            }
264
265            $window.resize(function(e){
266                if( $window.width() <= 1120 ){
267                    $bdCheckAlso.hide()
268                }
269                else {
270                    $bdCheckAlso.show()
271                }
272            });
273
274            $window.scroll(function() {
275                if( ! bdCheckAlsoClosed ) {
276                    if ($window.scrollTop() > articleOffset) {
277                        if ($bdCheckAlsoRight.length) {
278                            //$bdCheckAlso.css({'opacity': '1', 'right': '0'}, 300);
279                            $bdCheckAlso.addClass("bdCheckAlsoShow");
280                        }
281                        else {
282                            //$bdCheckAlso.css({'opacity': '1', 'left': '0'}, 300);
283                            $bdCheckAlso.addClass("bdCheckAlsoShow");
284                        }
285                    }
286                    else if ($window.scrollTop() <= articleOffset) {
287                        if ($bdCheckAlsoRight.length) {
288                            //$bdCheckAlso.css({'opacity': '0', 'right': '-350px'}, 300);
289                            $bdCheckAlso.removeClass("bdCheckAlsoShow");
290                        }
291                        else {
292                            //$bdCheckAlso.css({'opacity': '0', 'left': '-350px'}, 300);
293                            $bdCheckAlso.removeClass("bdCheckAlsoShow");
294                        }
295                    }
296                }
297            });
298
299            jQuery("#check-also-close").on("click",function(event){
300                $bdCheckAlso.removeClass("bdCheckAlsoShow");
301                bdCheckAlsoClosed = true ;
302                return false;
303            });
304        }
305    });
306
307    /**
308     Reading Post
309     ----------------------------------------------------------------------------- */
310    if( !bdayh_isMobile.any() && bd.is_singular && bd.post_reading_position_indicator ) {
311
312        var getMax = function () {
313            return jQuery(document).height() - jQuery(window).height();
314        };
315
316        var getValue = function () {
317            return jQuery(window).scrollTop();
318        };
319
320        if ( 'max' in document.createElement('progress') ) {
321            var progressBar = jQuery( '#reading-position-indicator' ),
322                max = getMax(),
323                value, width;
324
325            var getWidth = function () {
326                value = getValue();
327                width = (value / max) * 100;
328                width = width + '%';
329                return width;
330            };
331
332            var setWidth = function () {
333                progressBar.css({width: getWidth()});
334            };
335
336            jQuery(document).on('scroll', setWidth);
337            jQuery(window).on('resize', function () {
338                max = getMax();
339                setWidth();
340            });
341        }
342    }
343
344    /**
345     YouTube z-index fix
346     ----------------------------------------------------------------------------- */
347    jQuery('iframe[src*="youtube.com"]').each(function() {
348        var url = jQuery(this).attr('src');
349        if (jQuery(this).attr('src').indexOf('?') > 0) {
350            jQuery(this).attr({
351                'src'   : url + '&wmode=transparent',
352                'wmode' : 'Opaque'
353            });
354        } else {
355            jQuery(this).attr({
356                'src'   : url + '?wmode=transparent',
357                'wmode' : 'Opaque'
358            });
359        }
360    });
361
362    /**
363     About me widget image popup
364     ----------------------------------------------------------------------------- */
365    jQuery('.about-me-img').each(function()
366    {
367        jQuery(this).magnificPopup(
368            {
369                delegate: 'a',
370                type: 'image',
371                tLoading: 'Loading image #%curr%...',
372                mainClass: 'mfp-img-mobile',
373                gallery:
374                {
375                    enabled: true,
376                    navigateByImgClick: true,
377                    preload: [0,1] // Will preload 0 - before current, and 1 after the current image
378                },
379                image:
380                {
381                    tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
382                    titleSrc: function(item) {
383                        return item.el.attr('title') + '';
384                    }
385                },
386                zoom: {
387                    enabled: true,
388                    duration: 300, // don't foget to change the duration also in CSS
389                    opener: function(element) {
390                        return element.find('img');
391                    }
392                }
393            });
394    });
395
396    /**
397     Image Popup
398     ----------------------------------------------------------------------------- */
399    jQuery( 'body.on-lightbox figure.wp-caption, body.on-lightbox figure.gallery-item' ).each(function()
400    {
401        var caption_text = jQuery(this).children('figcaption').html();
402        jQuery(this).children('a').data('caption', caption_text);
403    });
404
405    jQuery( 'body.on-lightbox .post' ).each(function()
406    {
407        jQuery(this).magnificPopup(
408            {
409                delegate: '.post-featured-image-bd a, .gallery-item a, figure.wp-caption a, .pop-img-bd',
410                type: 'image',
411                tLoading: 'Loading ...',
412                mainClass: 'mfp-img-mobile',
413                gallery:
414                {
415                    enabled: true
416                },
417                image:
418                {
419                    tError: "<a href=\'%url%\'>The image #%curr%</a> could not be loaded.",
420                    titleSrc: function(item) {
421                        var current_caption_bd = jQuery(item.el).data('caption');
422                        if (typeof current_caption_bd != "undefined") {
423                            return current_caption_bd;
424                        } else {
425                            return '';
426                        }
427                    }
428                },
429                zoom:
430                {
431                    enabled: true,
432                    duration: 300, // don't foget to change the duration also in CSS
433                    opener: function(element) {
434                        return element.find('img');
435                    }
436                }
437            });
438    });
439});
440
441/**
442 Image Scroll
443 ----------------------------------------------------------------------------- */
444if( !bdayh_isMobile.any() && bd.imgScroll ) {
445    jQuery(function () {
446        var $window = jQuery(window),
447            win_height_padded = $window.height() * .9;
448
449        $window.on('scroll', bd_RevealOnScroll);
450
451        function bd_RevealOnScroll() {
452            var scrolled = $window.scrollTop(),
453                win_height_padded = $window.height() * .9;
454
455            jQuery(".fm-story .fm-thumbnail, .post-img, .ws-thumbnail, .flexslider .slides > li, .rp-thumbnail").each(function () {
456                var $this = jQuery(this),
457                    offsetTop = $this.offset().top;
458
459                if (scrolled + win_height_padded > offsetTop) {
460                    jQuery(this).addClass('img-over');
461                }
462            });
463        }
464        bd_RevealOnScroll();
465    });
466} else {
467    jQuery(".fm-story .fm-thumbnail, .post-img, .ws-thumbnail, .flexslider .slides > li, .rp-thumbnail").addClass('bd-show');
468    jQuery(".bd-hid a, .bd-hid img, .bd-hid, .fm-story .fm-thumbnail img, .post-img img, .ws-thumbnail img, .flexslider .slides > li a, .rp-thumbnail img").css({'filter':'alpha(opacity=100)', 'zoom':'1', 'opacity':'1'});
469}
470
471/**
472 Tabs Shortcodes
473 ----------------------------------------------------------------------------- */
474function initTabGroup(e) {
475    if(typeof e === 'undefined'){
476        e = document;
477    }
478    if (jQuery('.tabgroup', jQuery(e)).length) {
479        jQuery('.tabgroup', jQuery(e)).tabs().show();
480    }
481}
482
483
484/**
485 User Rating
486 ----------------------------------------------------------------------------- */
487;(function(e) {
488    function t() {
489        if (e(".bd-user-review-rating").length) {
490            this.el = this.build_el();
491            if (!this.is_rated()) {
492                this.bind_events()
493            } else {
494                this.display_user_rating()
495            }
496        }
497    }
498    t.prototype.is_rated = function() {
499        if (this.readCookie("bd_rating_" + bd_script.post_id) === "rated") {
500            return true
501        } else {
502            return false
503        }
504    };
505    t.prototype.display_user_rating = function() {
506        var e = this.readCookie("bd_rating_score_" + bd_script.post_id),
507            t = this.readCookie("bd_rating_position_" + bd_script.post_id);
508        this.el.rating.score.html(e);
509        this.el.stars.top.css("width", t + "%");
510        this.el.rating.label.your_rating.show();
511        this.el.rating.label.user_rating.hide()
512    };
513    t.prototype.build_el = function() {
514        var t = {
515            rating: {
516                score: e("SPAN.score", ".bd-user-review-description"),
517                count: e("SPAN.count", ".bd-user-review-description"),
518                label: {
519                    your_rating: e("SPAN.your_rating", ".bd-user-review-description"),
520                    user_rating: e("SPAN.user_rating", ".bd-user-review-description")
521                }
522            },
523            stars: {
524                under: e(".bd-criteria-star-under", ".bd-user-review-rating"),
525                top: e(".bd-criteria-star-top", ".bd-user-review-rating")
526            }
527        };
528        t.stars.old_position = parseInt(t.stars.top[0].style.width, 10);
529        t.rating.old_score = t.rating.score.html();
530        return t
531    };
532    t.prototype.bind_events = function() {
533        var t = this;
534        t.el.stars.under.on("mouseover", function() {
535            e(this).css("cursor", "pointer");
536            t.el.rating.label.your_rating.show();
537            t.el.rating.label.user_rating.hide()
538        });
539        t.el.stars.under.on("mouseout", function() {
540            t.el.stars.top.css("width", t.el.stars.old_position + "%");
541            t.el.rating.label.user_rating.show();
542            t.el.rating.label.your_rating.hide();
543            t.el.rating.score.html(t.el.rating.old_score)
544        });
545        t.el.stars.under.on("mousemove", function(n) {
546            if (!n.offsetX) {
547                n.offsetX = n.clientX - e(n.target).offset().left
548            }
549            var r = n.offsetX + 4;
550            if (r > 100) {
551                r = 100
552            }
553            t.el.stars.top.css("width", r + "%");
554            var i = Math.floor(r / 10 * 5) / 10;
555            if (i > 5) {
556                i = 5
557            }
558            t.el.rating.score.html(i)
559        });
560        t.el.stars.under.on("click", function(n) {
561            if (!n.offsetX) {
562                n.offsetX = n.clientX - e(n.target).offset().left
563            }
564            var r = parseInt(t.el.rating.count.html(), 10) + 0,
565                i = Math.floor((n.offsetX + 4) / 10 * 5) / 10,
566                s = n.offsetX + 4;
567            if (i > 5) {
568                i = 5
569            }
570            if (s > 100) {
571                s = 100
572            }
573            t.el.stars.under.off();
574            t.el.stars.under.css("cursor", "default");
575            t.el.stars.top.fadeOut(function() {
576                t.el.stars.top.css("background-position-y", "top");
577                t.el.stars.top.fadeIn()
578            });
579            t.el.rating.count.html(r);
580            var o = {
581                action: "bd_rating",
582                rating_position: s,
583                rating_score: i,
584                post_id: bd_script.post_id
585            };
586            e.post(bd_script.ajaxurl, o, function() {
587                t.createCookie("bd_rating_" + bd_script.post_id, "rated", 900);
588                t.createCookie("bd_rating_score_" + bd_script.post_id, i, 900);
589                t.createCookie("bd_rating_position_" + bd_script.post_id, s, 900)
590            })
591        })
592    };
593    t.prototype.createCookie = function(e, t, n) {
594        if (n) {
595            var r = new Date;
596            r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3);
597            var i = "; expires=" + r.toGMTString()
598        } else var i = "";
599        document.cookie = e + "=" + t + i + "; path=/"
600    };
601    t.prototype.readCookie = function(e) {
602        var t = e + "=";
603        var n = document.cookie.split(";");
604        for (var r = 0; r < n.length; r++) {
605            var i = n[r];
606            while (i.charAt(0) == " ") i = i.substring(1, i.length);
607            if (i.indexOf(t) == 0) return i.substring(t.length, i.length)
608        }
609        return null
610    };
611    t.prototype.eraseCookie = function(e) {
612        createCookie(e, "", -1)
613    };
614    e(document).ready(function() {
615        new t
616    })
617})(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.