PageSourceSearch

https://animalgenetics.com/wp-content/themes/sway/core/assets/js/scripts.js?ver=2.8

js animalgenetics.com collected 2026-10-02 12:33:46 UTC 27,171 bytes, 727 lines download raw bytes

1jQuery.event.special.touchstart = {
2        setup: function( _, ns, handle ){
3            this.addEventListener("touchstart", handle, { passive: true });
4        }
5};
6
7// ------------------------------------------------------------------------
8// Check if element is in ViewPort
9// ------------------------------------------------------------------------
10(function($) {
11    "use strict";
12
13    $.belowthefold = function(element, settings) {
14        var fold = $(window).height() + $(window).scrollTop();
15        return fold <= $(element).offset().top - settings.threshold;
16    };
17    $.abovethetop = function(element, settings) {
18        var top = $(window).scrollTop();
19        return top >= $(element).offset().top + $(element).height() - settings.threshold;
20    };
21    $.rightofscreen = function(element, settings) {
22        var fold = $(window).width() + $(window).scrollLeft();
23        return fold <= $(element).offset().left - settings.threshold;
24    };
25    $.leftofscreen = function(element, settings) {
26        var left = $(window).scrollLeft();
27        return left >= $(element).offset().left + $(element).width() - settings.threshold;
28    };
29    $.inviewport = function(element, settings) {
30        return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
31    };
32    $.extend($.expr[':'], {
33        "below-the-fold": function(a, i, m) {
34            return $.belowthefold(a, {
35                threshold: 0
36            });
37        },
38        "above-the-top": function(a, i, m) {
39            return $.abovethetop(a, {
40                threshold: 0
41            });
42        },
43        "left-of-screen": function(a, i, m) {
44            return $.leftofscreen(a, {
45                threshold: 0
46            });
47        },
48        "right-of-screen": function(a, i, m) {
49            return $.rightofscreen(a, {
50                threshold: 0
51            });
52        },
53        "in-viewport": function(a, i, m) {
54            return $.inviewport(a, {
55                threshold: 0
56            });
57        }
58    });
59      $(window).on('load', function() {
60        "use strict";
61    	// ------------------------------------------------------------------------
62    	// Preload Effect
63	    // ------------------------------------------------------------------------
64      $('body').removeClass('fade-in');
65        // ------------------------------------------------------------------------
66        // Center Logo
67        // ------------------------------------------------------------------------
68        // if ($('.navbar.logo-center').length > 0) {
69        // 	var MenuHeight = $('.navbar.logo-center').height();
70        //     $(".entry-header").css("padding-top", MenuHeight+100);
71        // }
72		if ($('.navbar.logo-center').length > 0) {
73         	if ($(window).width() > 1270) {
74        	var MenuHeight = $('.navbar.logo-center').height();
75        		if (!$(".entry-header").hasClass("has-top-padding")) {
76           			 $(".entry-header").css("padding-top", MenuHeight+100);
77       			}
78       		}
79       	}
80    });
81
82
83    window.addEventListener("beforeunload", function () {
84          $("body a[href]").click(function(){
85            var $anchor = $(this);
86
87            // Don't fade for links that open in new window
88            if ( $anchor.attr('target') && $anchor.attr('target').indexOf('_blank') >=0 ) {
89                return;
90            }
91            // Don't fade for email
92            if ( $anchor.attr('href').indexOf('mailto:') >=0 ) {
93                return;
94            }
95
96            // Don't fade for telephone links
97            if ( $anchor.attr('href').indexOf('tel:') >=0 ) {
98                return;
99            }
100
101            // Don't fade for links to anchor tags
102            if ( $anchor.attr('href').indexOf('#') >=0 ) {
103                return;
104            }
105
106            // Fade out
107            document.body.classList.add("fade-out");
108        });
109    });
110
111    $(document).ready(function() {
112        "use strict";
113        $(".wpb_wrapper:empty").parent().addClass('hide-on-mobile');
114
115        $('.parallax-overlay').each(function() {
116            var size = $(this).attr('data-vc-kd-parallax');
117            var height = $(this).closest('.kd_vc_parallax').innerHeight();
118            $(this).css('height', size * height + 'px');
119        });
120
121        if ($('.entry-header .breadcrumbs, .breadcrumbs.breadcrumbs-shortcode').length > 0) {
122        var str = $(".breadcrumbs").html();
123        $(".breadcrumbs").html(str.replace(/&gt;/g, '<span class="fa fa-chevron-right"></span>'));
124        }
125
126        // ------------------------------------------------------------------------
127        // 3rd level menu off screen
128        // ------------------------------------------------------------------------
129        
130        
131      
132
133        // ------------------------------------------------------------------------
134        // 3rd level menu off screen
135        // ------------------------------------------------------------------------
136
137
138		$(".navbar-nav .dropdown:not(.mega-menu) .dropdown-menu .dropdown").on("mouseover", function () {
139            var dropdown = $(this).find('.dropdown-menu');
140            var off = dropdown.offset();
141            var l = off.left;
142            var w = dropdown.width();
143            var docW = $(window).width();
144            var isEntirelyVisible = (l + w < docW);
145            if (!isEntirelyVisible) {
146                dropdown.addClass('align-menu-right');
147            }
148        });
149        $(window).on('resize', function(){
150            $(".dropdown-menu").removeClass('align-menu-right');
151        });
152
153
154        // ------------------------------------------------------------------------
155        // Mobile Navbar Toggle
156        // ------------------------------------------------------------------------
157
158        $(document).click(function(e) {
159            if (!$(e.target).is('.mobile-dropdown')) {
160                $('.collapse').collapse('hide');
161            }
162        });
163
164
165
166        // ------------------------------------------------------------------------
167        // Mega menu effects
168        // ------------------------------------------------------------------------
169          if ($('.transparent-navigation').length > 0) {
170            $( ".navbar-nav .mega-menu" ).hover(
171              function () {
172                $('body').removeClass( "transparent-navigation" );
173              },
174              function () {
175                $('body').addClass( "transparent-navigation" );
176              }
177            );
178          }
179
180         $( ".navbar-nav .mega-menu" ).hover(
181              function () {
182                $('.navbar-nav').addClass( "no-transition" );
183              },
184              function () {
185                $('.navbar-nav').removeClass( "no-transition" );
186              }
187         );
188
189        if ($('#tribe-events-pg-template').length > 0) {
190            $('#tribe-events-pg-template').addClass('container');
191        }
192
193        // ------------------------------------------------------------------------
194        // Side panel
195        // ------------------------------------------------------------------------
196        var $html_wrapper = $('html'),
197            scrollDisabled = false,
198            scrollTop;
199
200        function scrollDisable() {
201            if (scrollDisabled) {
202                return;
203            }
204
205            scrollTop = $(window).scrollTop();
206
207            $html_wrapper.addClass('scrollLock')
208                .css({
209                top: -1 * scrollTop
210            });
211
212            scrollDisabled = true;
213        }
214
215        function scrollEnable() {
216            if (!scrollDisabled) {
217                return;
218            }
219
220            $html_wrapper.removeClass('scrollLock');
221            $(window).scrollTop(scrollTop);
222
223            scrollDisabled = false;
224        }
225
226        if ($(".panel-trigger-btn").length) {
227          $(".panel-trigger-btn").click(function(e) {
228              e.preventDefault();
229              scrollDisable();
230              $(".kd-side-panel, .panel-screen-overlay").addClass("active");
231              $(".navbar.navbar-default.fixed-menu").addClass("panel-enabled");
232          });
233          $(".kd-side-panel .panel-close").click(function() {
234              scrollEnable();
235              $(".kd-side-panel, .panel-screen-overlay").removeClass("active");
236              $(".navbar.navbar-default.fixed-menu").removeClass("panel-enabled");
237          });
238
239          $('.panel-screen-overlay').on("click", function(){
240               $(".kd-side-panel .panel-close").trigger("click");
241          });
242        }
243
244        if ($(".modal-trigger-btn").length) {
245          $(".modal-trigger-btn").click(function(e) {
246              $(this).attr("href", "#")
247        });
248        }
249        // ------------------------------------------------------------------------
250        // Opening Hours on Mobile
251        // ------------------------------------------------------------------------
252
253        $(".topbar-contact .topbar-opening-hours").click(function() {
254        $(this).toggleClass('active');
255        });
256
257
258        // ------------------------------------------------------------------------
259        // Live Preview Customizer
260        // ------------------------------------------------------------------------
261
262        $("#customizer .switcher, .demo-switcher ").click(function() {
263        $("#customizer").toggleClass('active');
264        });
265
266        // ------------------------------------------------------------------------
267        // Topbar search
268        // ------------------------------------------------------------------------
269
270        $(".topbar-search .toggle-search").click(function() {
271            $(".topbar-search .topbar-search-container").toggleClass('active');
272            $(this).toggleClass('sway-times');
273            setTimeout( function(){
274                $('.topbar-search-container .search-field').focus();
275            }  , 250 );
276        });
277
278        function draw() {
279            requestAnimationFrame(draw);
280            scrollEvent();
281        }
282        draw();
283
284        // ------------------------------------------------------------------------
285        // Fixed Footer
286        // ------------------------------------------------------------------------
287        if ($("#footer.fixed").length) {
288            var footerHeight = $("#footer.fixed").height();
289            $("#wrapper").css("margin-bottom", footerHeight);
290        }
291
292        // ------------------------------------------------------------------------
293        // Custom Search Field
294        // ------------------------------------------------------------------------
295        $("#s").each(function(index, elem) {
296            var eId = $(elem).attr("id");
297            var label = null;
298            if (eId && (label = $(elem).parents("form").find("label[for=" + eId + "]")).length == 1) {
299                $(elem).attr("placeholder", 'Search');
300                $(label).remove();
301            }
302        });
303        $(".wp-block-search .wp-block-search__button").text('');
304        $(".search-submit, .blog_widget #bbp_search_submit").val('');
305        $(".woocommerce-product-search input[type='submit']").val('');
306        // ------------------------------------------------------------------------
307        // Contact Form Buttons
308        // ------------------------------------------------------------------------
309        $(document).on("click", ".section .wpcf7-not-valid-tip,.section .wpcf7-mail-sent-ok, .blog-header-form .wpcf7-not-valid-tip, .blog-header-form .wpcf7-mail-sent-ok, .subscribe-form header .wpcf7-response-output, .modal-content-inner .wpcf7-not-valid-tip, .kd-side-panel .wpcf7-not-valid-tip", function() {
310            $(this).fadeOut();
311        });
312        // ------------------------------------------------------------------------
313        // Reset reCaptcha for modal window
314        // ------------------------------------------------------------------------
315        if ($('.wpcf7-recaptcha').length > 0) {
316    			$(document).on("click", ".modal-menu-item", function() {
317    				grecaptcha.reset();
318    			});
319    		}
320        // ------------------------------------------------------------------------
321        // Blog video cover
322        // ------------------------------------------------------------------------
323        $('.background-video-image').each(function() {
324            var imgSrc = $(this).children('img').attr('src');
325            $(this).css('background', 'url("' + imgSrc + '")').css('background-position', 'initial');
326        });
327
328
329        $('.video-cover').each(function(){
330                var videoCover = $(this);
331                if(videoCover.find('iframe').length){
332                    videoCover.find('iframe').attr('data-src', videoCover.find('iframe').attr('src'));
333                    videoCover.find('iframe').attr('src','');
334                }
335            });
336
337            $('.video-cover .play-video').on("click", function(){
338                var playIcon = $(this);
339                var videoCover = playIcon.closest('.video-cover');
340                if(videoCover.find('video').length){
341                    var video = videoCover.find('video').get(0);
342                    videoCover.addClass('show-video');
343                    video.play();
344                    return false;
345                } else if(videoCover.find('iframe').length){
346                    var iframe = videoCover.find('iframe');
347                var videoSrc = iframe.attr('data-src');
348                var videoSrcAuto = videoSrc.replace('?feature=oembed', '?autoplay=1');
349                    iframe.attr('src', videoSrcAuto);
350                    videoCover.addClass('show-video');
351                    return false;
352                }
353            });
354
355        // ------------------------------------------------------------------------
356        // Main Menu One Page Links
357        // ------------------------------------------------------------------------
358
359        $( "<span class='mobile-dropdown'></span>" ).appendTo( $( ".navbar-nav .menu-item-has-children" ) );
360
361        $(".navbar-nav .menu-item-has-children .mobile-dropdown").click(function() {
362        $(this).closest(".menu-item-has-children").toggleClass('mobile-visible');
363        });
364
365        // ------------------------------------------------------------------------
366        // Bbpress Breadcrumbs
367        // ------------------------------------------------------------------------
368
369        if ($('.bbp-breadcrumb').length > 0) {
370            $( '.bbp-breadcrumb' ).appendTo( $(".bbpress-breadcrumbs"));
371        }
372
373        // ------------------------------------------------------------------------
374        // Main Smooth Scroll and Scroll Spy
375        // ------------------------------------------------------------------------
376
377        $(function() {
378            $('.navbar-nav .one-page-link a, .scroll-section a, .modal-menu-item.scroll-section, .demo-button').bind('click', function(event) {
379                if ($("body").hasClass("home")) {
380                var $anchor = $(this);
381                $('html, body').stop().animate({
382                    scrollTop: $($anchor.attr('href')).offset().top - 90
383                }, 1500, 'easeInOutQuart');
384                event.preventDefault();
385                }
386            });
387        $('.btn-smooth-scroll').bind('click', function(event) {
388                var $anchor = $(this);
389                $('html, body').stop().animate({
390                    scrollTop: $($anchor.attr('href')).offset().top - 90
391                }, 1500, 'easeInOutQuart');
392                event.preventDefault();
393            });
394        });
395        $('body').scrollspy({
396            offset: 100,
397            target: '.navbar-fixed-top'
398        });
399
400        // ------------------------------------------------------------------------
401        // WPGlobus compatibility - NavWalker conflict
402        // ------------------------------------------------------------------------
403
404        if ($('.wpglobus-selector-link').length > 0) {
405            $('.wpglobus-selector-link .dropdown-menu').addClass('sub-menu');
406        }
407
408        // ------------------------------------------------------------------------
409        // Back to top button
410        // ------------------------------------------------------------------------
411        $(window).bind("scroll", function() {
412            if ($(window).scrollTop() > 150) {
413                $('.back-to-top').addClass('active');
414            }
415            if ($(window).scrollTop() < 150) {
416                $('.back-to-top').removeClass('active');
417        }
418
419        // ------------------------------------------------------------------------
420        // Reading Progress Bar
421        // ------------------------------------------------------------------------
422        if ($(".rebar-wrapper").length) {
423                let imageHeight = 0;
424                let contentHeight = $("body.single-post #posts-content .blog-content").height();
425                let titleHeight = $("body.single-post #posts-content .blog-single-header-wrapper").height();
426                if ($('.single-post-content .entry-image').length) { imageHeight = $("body.single-post #posts-content .single-post-content .entry-image").height(); }
427                let finalHeight = contentHeight + titleHeight + imageHeight + 500;
428                let winHeight = $(window).height();
429                let viewport = finalHeight - winHeight;
430                let scrollPos = $(window).scrollTop();
431                let scrollPercent = (scrollPos / viewport) * 100;
432                $(".rebar-element").css("width", scrollPercent + "%");
433            }
434
435        // ------------------------------------------------------------------------
436        // Back to top progress scroll
437        // ------------------------------------------------------------------------
438        
439        if ($(".back-to-top.scroll-position-style").length) {
440                let contentHeight = $("body").height();
441                let winHeight = $(window).height();
442                let viewport = contentHeight - winHeight;
443                let scrollPos = $(window).scrollTop();
444                let scrollPercent =  262 - (scrollPos / viewport) * 150;
445                $(".back-to-top.scroll-position-style circle").css("stroke-dashoffset", scrollPercent + "px");
446        }
447
448        });
449
450        // ------------------------------------------------------------------------
451        // Back to top
452        // ------------------------------------------------------------------------
453        
454        $('.back-to-top').click(function(event) {
455            event.preventDefault();
456            $('html, body').animate({
457                scrollTop: 0
458            }, 500);
459            return false;
460        });
461
462    });
463
464    // ------------------------------------------------------------------------
465    // Portfolio & Blog related posts slider
466    // ------------------------------------------------------------------------
467
468    if ($(".related-content.owlslider-related-posts").length) {
469        $(".related-content.owlslider-related-posts").owlCarousel({
470            stageClass: "owl-wrapper",
471            stageOuterClass: "owl-wrapper-outer",
472            loadedClass: "owl-carousel",
473            responsive:{
474                0:{
475                    items: 1,
476                    nav: true,
477                    navSpeed: 500,
478                    dots: false,
479                },
480                767:{
481                    items: 3,
482                    nav: true,
483                    navSpeed: 500,
484                    dots: false,
485                },
486                960:{
487                    nav: true,
488                    items: 3,
489                    navSpeed: 500,
490                    dots: false,
491                }
492            },
493            items: 3,
494            nav: true,
495            navSpeed: 500,
496            dots: false,
497            rewind: true,
498            loop: true,
499        });
500    }
501
502    // ------------------------------------------------------------------------
503    // PhotoSwipe init
504    // ------------------------------------------------------------------------
505    var PhotoSwipe = window.PhotoSwipe,
506        PhotoSwipeUI_Default = window.PhotoSwipeUI_Default;
507
508    $('body').on('click', 'a[data-size]', function(e) {
509        if (!PhotoSwipe || !PhotoSwipeUI_Default) {
510            return;
511        }
512
513        e.preventDefault();
514        openPhotoSwipe(this);
515    });
516
517    var parseThumbnailElements = function(gallery, el) {
518        var elements = $(gallery).find('a[data-size]').has('img'),
519            galleryItems = [],
520            index;
521
522        elements.each(function(i) {
523            var $el = $(this),
524                size = $el.data('size').split('x'),
525                caption;
526
527            if($el.attr('data-caption-title') != null) {
528                caption = '<div class="pswp__caption__title">'+$el.attr('data-caption-title')+'</div>';
529            }
530
531            if($el.attr('data-caption-desc') != null) {
532                if(caption == null) caption = '';
533                caption = caption + '<div class="pswp__caption__desc">'+$el.attr('data-caption-desc')+'</div>';
534            }
535
536            galleryItems.push({
537                src: $el.attr('href'),
538                w: parseInt(size[0], 10),
539                h: parseInt(size[1], 10),
540                title: caption,
541                msrc: $el.find('img').attr('src'),
542                el: $el
543            });
544            if (el === $el.get(0)) {
545                index = i;
546            }
547        });
548
549        return [galleryItems, parseInt(index, 10)];
550    };
551
552    var openPhotoSwipe = function(element, disableAnimation) {
553        var pswpElement = $('.pswp').get(0),
554            galleryElement = $(element).parents('.gallery, .hentry, .main, body').first(),
555            gallery,
556            options,
557            items, index;
558
559        items = parseThumbnailElements(galleryElement, element);
560        index = items[1];
561        items = items[0];
562
563        options = {
564            index: index,
565            getThumbBoundsFn: function(index) {
566                var image = items[index].el.find('img'),
567                    offset = image.offset();
568
569                return {
570                    x: offset.left,
571                    y: offset.top,
572                    w: image.width()
573                };
574            },
575            showHideOpacity: true,
576            history: false
577        };
578
579        if (disableAnimation) {
580            options.showAnimationDuration = 0;
581        }
582
583        // Pass data to PhotoSwipe and initialize it
584        gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
585        gallery.init();
586    };
587
588
589    // ------------------------------------------------------------------------
590    // Classie Script
591    // ------------------------------------------------------------------------
592    (function(window) {
593        'use strict';
594        function classReg(className) {
595            return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
596        }
597        var hasClass, addClass, removeClass;
598        if ('classList' in document.documentElement) {
599            hasClass = function(elem, c) {
600                return elem.classList.contains(c);
601            };
602            addClass = function(elem, c) {
603                elem.classList.add(c);
604            };
605            removeClass = function(elem, c) {
606                elem.classList.remove(c);
607            };
608        } else {
609            hasClass = function(elem, c) {
610                return classReg(c).test(elem.className);
611            };
612            addClass = function(elem, c) {
613                if (!hasClass(elem, c)) {
614                    elem.className = elem.className + ' ' + c;
615                }
616            };
617            removeClass = function(elem, c) {
618                elem.className = elem.className.replace(classReg(c), ' ');
619            };
620        }
621
622        function toggleClass(elem, c) {
623            var fn = hasClass(elem, c) ? removeClass : addClass;
624            fn(elem, c);
625        }
626        var classie = {
627            hasClass: hasClass,
628            addClass: addClass,
629            removeClass: removeClass,
630            toggleClass: toggleClass,
631            has: hasClass,
632            add: addClass,
633            remove: removeClass,
634            toggle: toggleClass
635        };
636        if (typeof define === 'function' && define.amd) {
637            define(classie);
638        } else {
639            window.classie = classie;
640        }
641
642    })(window);
643    // ------------------------------------------------------------------------
644    // Animated Header
645    // ------------------------------------------------------------------------
646
647    var cbpAnimatedHeader = (function() {
648        var docElem = document.documentElement,
649            header = document.querySelector('.navbar-default'),
650            didScroll = false,
651            changeHeaderOn = 50;
652
653        function init() {
654            window.addEventListener('scroll', function(event) {
655                if (!didScroll) {
656                    didScroll = true;
657                    setTimeout(scrollPage, 100);
658                }
659            }, false);
660            window.addEventListener('load', function(event) {
661                if (!didScroll) {
662                    didScroll = true;
663                    setTimeout(scrollPage, 100);
664                }
665            }, false);
666        }
667
668        function scrollPage() {
669            var sy = scrollY();
670            if (sy >= changeHeaderOn) {
671                classie.add(header, 'navbar-shrink');
672                $(".topbar-search-container").removeClass('active');
673                $(".topbar-search .toggle-search").removeClass('sway-times');
674            } else {
675                if (!$(".panel-screen-overlay.active").length) {
676                  if ( typeof(header) != 'undefined' && header != null ) {
677                    classie.remove(header, 'navbar-shrink');
678                  }
679                }
680            }
681            didScroll = false;
682        }
683
684        function scrollY() {
685            return window.pageYOffset || docElem.scrollTop;
686        }
687        if (!$(header).hasClass("fixed-menu")) {
688        init();
689        }
690    })();
691
692
693})(jQuery);
694
695
696
697function scrollEvent() {
698
699    if (!is_touch_device()) {
700        viewportTop = jQuery(window).scrollTop();
701
702        if (jQuery(window).width())
703
704            jQuery('.parallax-overlay').each(function() {
705            elementOffset = jQuery(this).offset().top;
706            var size = jQuery(this).attr('data-vc-kd-parallax');
707            if (jQuery(this).hasClass('header-overlay')) {
708            	size = 1.3;
709            }
710            distance = (elementOffset - viewportTop) * ( 1 - size );
711            jQuery(this).css('transform', 'translate3d(0, ' + distance + 'px,0)');
712        	});
713
714        	jQuery('.kd-parallax-image .vc_figure img').each(function() {
715                elementOffset = jQuery(this).offset().top;
716                distance = (elementOffset - viewportTop) * -0.5;
717        		jQuery(this).css('transform', 'translateY(' + distance + 'px)');
718        	});
719
720    }
721}
722
723
724
725function is_touch_device() {
726    return 'ontouchstart' in window || 'onmsgesturechange' in window;
727}

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.