PageSourceSearch

https://fraservalleyconservancy.ca/wp-content/themes/anvil-theme/scripts/site-js.js?ver=1790584605

js fraservalleyconservancy.ca collected 2026-10-02 17:28:01 UTC 16,928 bytes, 563 lines download raw bytes

1jQuery(function ($) {
2// The function actually applying the offset
3    function offsetAnchor() {
4      if (location.hash.length !== 0) {
5        window.scrollTo(window.scrollX, window.scrollY - 200);
6      }
7    }
8
9    // Captures click events of all <a> elements with href starting with #
10    $(document).on('click', 'a[href^="#"]', function(event) {
11      // Click events are captured before hashchanges. Timeout
12      // causes offsetAnchor to be called after the page jump.
13      window.setTimeout(function() {
14        offsetAnchor();
15      }, 0);
16    });
17
18    // Set the offset when entering page with hash present in the url
19    window.setTimeout(offsetAnchor, 0);
20
21    function setCookie(key, value, expiry) {
22        var expires = new Date();
23        expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000));
24        document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
25    }
26
27    function getCookie(key) {
28        var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
29        return keyValue ? keyValue[2] : null;
30    }
31
32    function eraseCookie(key) {
33        var keyValue = getCookie(key);
34        setCookie(key, keyValue, '-1');
35    }
36
37//
38
39var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
40
41if (isIE11) {
42    $('body').addClass('ie11');
43}
44    /*
45    |----------------------------------------------------------------
46    |  Object fit fallback for ie11,
47    |  Call this function with an array of selectors for image containers
48    |  using Object Fit
49    |----------------------------------------------------------------
50    */
51    if (isIE11) {
52        function objectFitFallback(selectors) {
53            if (!Array.isArray(selectors)) {
54                selectors = selectors.split();
55            }
56            selectors.forEach(function (element) {
57                $(element).each(function () {
58                    var $container = $(this),
59                    imgUrl = $container.find('img:not(.background-img)').prop('src');
60
61                    if (imgUrl) {
62                        $container
63                        .css('backgroundImage', 'url(' + imgUrl + ')')
64                        .addClass('compat-object-fit');
65                    }
66                });
67            });
68        }
69
70        objectFitFallback(['.image-container', '.image-column', '.woocommerce-loop-product__link']);
71    }
72
73
74
75
76
77    //resource page filter
78    if( $('#resource-filter') ) {
79        $('#resource-filter').appendTo('.page-banner > .row');
80
81    }
82
83
84
85    //dealing with header scroll
86
87    var lastScrollTop = 0;
88    var stickyOffset = $('.site-header').offset().top;
89    var windowArray = window.location.href.split('/');
90    var lastItem = windowArray[windowArray.length - 1];
91
92
93    if( lastItem.charAt(0) === '#' ) {
94        $(lastItem).css('padding-top', 50);
95
96    }
97
98
99
100    window.addEventListener("scroll", function(){
101
102
103        var st = window.pageYOffset || document.documentElement.scrollTop;
104        var width = $(document).width();
105        var sticky = $('.site-header');
106
107
108        if (st > stickyOffset && width > 979) {
109            sticky.addClass('sticky');
110            sticky.addClass('invisible');
111        } else {
112            sticky.removeClass('sticky')
113        }
114
115
116
117
118        if ( (st > lastScrollTop || st < stickyOffset ) && st > stickyOffset && width > 979 ){
119
120            $('.site-header').addClass('invisible');
121
122
123        } else {
124
125            $('.site-header').removeClass('invisible');
126
127        }
128
129
130   lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
131}, false);
132
133
134
135
136
137
138
139    /*
140     |----------------------------------------------------------------
141     |  Mobile Trigger
142     |  (targeting all .menu-trigger, so they're syncornized )
143     |----------------------------------------------------------------
144     */
145     $('.fs-menu-trigger').click(function (e) {
146        e.preventDefault();
147
148        $('body').toggleClass('menu-opened');
149        $('.main-menu').slideToggle(250);
150    });
151
152
153    /*
154     |----------------------------------------------------------------
155     |  Mobile Sub-menu Trigger
156     |----------------------------------------------------------------
157     */
158     $(".menu-item-has-children > a")
159     .append('<span class="mobile-submenu-trigger"><i class="fa fa-caret-down" aria-hidden="true"></i></span>');
160
161     $(".mobile-submenu-trigger").click(function (e) {
162        e.preventDefault();
163        e.stopPropagation();
164
165        $(this).toggleClass('opened');
166        $(this).parent().siblings('.sub-menu').slideToggle();
167    });
168
169
170    /*
171     |----------------------------------------------------------------
172     |  Smooth Scrolling
173     |  (targeting all [data-smooth-scroll])
174     |----------------------------------------------------------------
175     */
176     $('.smooth-scroll, [data-smooth-scroll]').on('click', smoothScroll);
177
178
179    /*
180   |----------------------------------------------------------------
181   |  Accordion
182   |----------------------------------------------------------------
183   */
184   $(".accordion-holder").each(function () {
185    var $self = $(this);
186
187    $self.find(".accordion-label").on('click', function (e) {
188        e.preventDefault();
189            //Close open siblings
190            $('.accordion-entry').not($(this).parent()).attr('data-status', 'closed');
191            $("[data-status='closed'] .accordion-content").slideUp(250);
192
193            //Toggle the selected section
194            $(this).siblings('.accordion-content').slideToggle(250);
195            $(this).parent().attr(
196                'data-status',
197                $(this).parent().attr('data-status') === 'opened' ? 'closed' : 'opened'
198                );
199        });
200
201    $(".close", $self).click(function (e) {
202        $(this).parents('.accordion-content').slideToggle(250);
203        $(".accordion-entry", $self).attr('data-status', 'closed');
204    });
205});
206
207    /*
208    |----------------------------------------------------------------
209    |  Tabs
210    |----------------------------------------------------------------
211    */
212
213    function openTab(evt, tabId) {
214        var i, tabcontent, tablinks;
215
216        // Get all elements with class="tabcontent" and hide them
217        tabcontent = document.getElementsByClassName("tab-content");
218        for (i = 0; i < tabcontent.length; i++) {
219            tabcontent[i].style.display = "none";
220        }
221
222        // Get all elements with class="tablinks" and remove the class "active"
223        tablinks = document.getElementsByClassName("tab-link");
224        for (i = 0; i < tablinks.length; i++) {
225            tablinks[i].className = tablinks[i].className.replace(" active", "");
226        }
227
228        // Show the current tab, and add an "active" class to the button that opened the tab
229        document.getElementById(tabId).style.display = "block";
230        evt.currentTarget.className += " active";
231    }
232
233    /*
234    |----------------------------------------------------------------
235    |  Loop slideout
236    |----------------------------------------------------------------
237    */
238
239    function resetSlideout() {
240        $('.loop-hidden').slideUp(250);
241        $('.loop-content').removeClass('show-slideout');
242        $('.minus').removeClass('show-icon');
243        $('.plus').removeClass('hide-icon');
244    };
245
246    $('.slideout-item .container .loop-content').on('click', function () {
247
248        var parent = $(this).parent().parent();
249
250        if ($(this).hasClass('show-slideout')) {
251            resetSlideout();
252        } else {
253            resetSlideout();
254            parent.find('.loop-hidden').slideDown(250);
255            parent.find('.loop-content').addClass('show-slideout');
256            parent.find('.plus').addClass('hide-icon');
257            parent.find('.minus').addClass('show-icon')
258        }
259
260    });
261
262    $('.close').on('click', function () {
263        resetSlideout();
264    });
265
266
267    /*
268|----------------------------------------------------------------
269|  Testimonial slider
270|----------------------------------------------------------------
271*/
272
273$('.testimonial-slider').slick({
274    autoplay: true,
275    infinite: true,
276    dots: false,
277    arrows: true,
278    fade: false,
279    swipe: true,
280    prevArrow: '<i class="fa fa-angle-left prevArrow" aria-hidden="true"></i>',
281    nextArrow: '<i class="fa fa-angle-right nextArrow" aria-hidden="true"></i>',
282    autoplaySpeed: 5000,
283});
284
285
286    /*
287     |----------------------------------------------------------------
288     |  Gallery Slider
289     |----------------------------------------------------------------
290     */
291     $('.single-item').slick({
292        dots: true,
293        infinite: true,
294        speed: 300,
295        lazyLoad: 'false',
296        slidesToShow: 1,
297        adaptiveHeight: true,
298        prevArrow: '<div class="slick-prev"><i class="fal fa-chevron-left" aria-hidden="true"></i></div>',
299        nextArrow: '<div class="slick-next"><i class="fal fa-chevron-right" aria-hidden="true"></i></div>'
300    });
301
302
303
304
305     $(document).ready(function(){
306
307        $('.gallery-wrapper').slick({
308            slidesToShow: 1,
309            slidesToScroll: 1,
310            dots: false,
311            draggable: true,
312            swipe: true,
313            arrows: false,
314            lazyLoad: 'false',
315            adaptiveHeight: true,
316            fade: true,
317            asNavFor: '.slick-thumbnail-grid'
318
319        });
320    });
321
322
323
324
325     $('.slick-thumbnail-grid').slick({
326      asNavFor: '.slick',
327      slidesToShow: 3,
328      slidesToScroll: 1,
329      infinite: true,
330      lazyLoad: 'false',
331      dots: false,
332      arrows: true,
333      prevArrow: '<div class="slick-prev"><i class="fal fa-angle-left"></i></div>',
334      nextArrow: '<div class="slick-next"><i class="fal fa-angle-right"></i></div>',
335      centerMode: false,
336      focusOnSelect: true,
337
338  });
339
340
341    /*
342    |----------------------------------------------------------------
343    | Counter
344    |----------------------------------------------------------------
345    */
346
347    $.fn.isInViewport = function () {
348        var element = $(this);
349        if (element.length) {
350            var elementTop = $(this).offset().top;
351            var viewportTop = $(window).scrollTop();
352            var viewportBottom = viewportTop + $(window).height();
353            return elementTop > viewportTop && elementTop < viewportBottom;
354        }
355    };
356
357    $(window).on('resize scroll load', function () {
358        if ($('.statistic').isInViewport()) {
359            $('.stat').each(function () {
360                var $this = $(this),
361                countTo = $this.attr('data-count');
362                $({countNum: $this.text()}).animate({
363                    countNum: countTo
364                },
365                {
366                    duration: 1500,
367                    easing: 'linear',
368                    step: function () {
369                        $this.text(Math.floor(this.countNum));
370                    },
371                    complete: function () {
372                        $this.text(this.countNum);
373                    }
374
375                });
376            });
377            $(window).off('scroll');
378        }
379    });
380
381    /*
382      |----------------------------------------------------------------
383      |  Search form Error Handling
384      |----------------------------------------------------------------
385      */
386
387      $('form[method="get"]').submit(function () {
388        $(this).find(':input').each(function () {
389            var inp = $(this);
390            if (!inp.val()) {
391                inp.remove();
392            }
393        });
394    });
395
396    /*
397      |----------------------------------------------------------------
398      |  Simple submit
399      |----------------------------------------------------------------
400      */
401      $('#simple-filter select').on('change', function () {
402        this.form.submit();
403    });
404
405
406    /*
407      |----------------------------------------------------------------
408      |  Smooth Scroll
409      |----------------------------------------------------------------
410      */
411
412      function smoothScroll(e) {
413        var $target = $($(this).attr('data-smooth-scroll'));
414
415        if (!$target.size()) {
416            var href = $(this).attr('href').split("#");
417            $target = $('#' + href[href.length - 1]);
418        }
419
420        if ($target.size()) {
421            e.preventDefault();
422
423            $('html, body').animate({
424                scrollTop: $target.offset().top - 50
425            }, 250);
426        }
427    }
428
429    function configureMenus() {
430        if (window.innerWidth <= 766) {
431            //combine menus
432            $('ul.utility-menu > li').addClass('moved-item');
433            $('ul.utility-menu > li').appendTo('.small-nav ul.main-menu');
434            $('ul.utility-menu').remove('.moved-item');
435        }
436
437        if (window.innerWidth > 766) {
438            //split menus
439            $('ul.main-menu > li.moved-item').appendTo('ul.utility-menu');
440            $('ul.main-menu').remove('ul.main-menu > li.moved-item');
441            $('ul.utility-menu > li').removeClass('moved-item');
442        }
443    }
444
445    /*
446    |----------------------------------------------------------------
447    |  Filter form Error Handling
448    |----------------------------------------------------------------
449    */
450
451    $('form[method="get"]').submit(function () {
452        $(this).find(':input').each(function () {
453            var inp = $(this);
454            if (!inp.val()) {
455                inp.remove();
456            }
457        });
458    });
459
460    $('.taxonomy-select').on('change', function () {
461        var taxSelects = $('.search-form').find('.taxonomy-select');
462        taxSelects = Array.from(taxSelects);
463        var formHasValue = taxSelects.reduce(function (acc, curr) {
464            return !!curr.options[curr.selectedIndex].value || acc;
465        }, false);
466
467        if (formHasValue) {
468            $('#filter-submit-button').removeAttr('disabled');
469        } else {
470            $('#filter-submit-button').addAttr('disabled');
471        }
472    });
473
474    $('#search-input').on('change input', function (e) {
475        if ($(this).val()) {
476            $('#filter-submit-button').removeAttr('disabled');
477        } else if (!$(this.val())) {
478            $('#filter-submit-button').addAttr('disabled');
479        }
480    });
481
482
483    // dynamically set the height of image container based on an absolute positioned elements height
484    function setCtaHeight() {
485        var parent = $('.right-floating-content-full-width');
486        var contentHeight = parent.find('.content-container').outerHeight();
487        var image = parent.find('.image-column');
488
489        if (window.innerWidth > 979) {
490            image.css({
491                height: contentHeight + 200 + "px",
492            });
493        } else {
494            image.css({
495                height: 'auto',
496            });
497        }
498    }
499
500    /*
501    |----------------------------------------------------------------
502    | minimal functions
503    | todo: move to separate js file to be conditionally loaded when minimal is active
504    |----------------------------------------------------------------
505    */
506
507    function setMinimalThemeBannerBackgroundPosition() {
508        var container = $('.minimal').find('.page-banner');
509        var desiredBannerContainer = container.children('.row');
510        if (window.innerWidth > 1200) {
511            var offset = (container.outerWidth() - desiredBannerContainer.outerWidth()) / 2;
512
513            var offsetCss = 'right ' + offset + 'px center';
514            container.css('background-position', offsetCss);
515        }
516        else {
517            container.css({'backgroundPosition': 'right center'});
518        }
519    }
520    (function moveFooterSocialList() {
521        var footerSocial = $(".minimal").find('.footer-logo-column .social-list');
522        var contactContainer = $(".minimal").find('.footer-menu.address-column');
523        contactContainer.append(footerSocial);
524    })();
525    (function moveSiteCopyright() {
526        var footerCopyright = $(".minimal").find('.copyright-column');
527        var logoContainer = $(".minimal").find('.footer-logo-column');
528        console.log(footerCopyright);
529        logoContainer.append(footerCopyright);
530    })();
531
532    /*
533    |----------------------------------------------------------------
534    | Window resize event handler with initial function calls
535    |----------------------------------------------------------------
536    */
537    setCtaHeight();
538    configureMenus();
539    setMinimalThemeBannerBackgroundPosition();
540    var delay = 250,
541    throttled = false;
542
543    $(window).on('resize', function () {
544        if (!throttled) {
545            setCtaHeight();
546            configureMenus();
547            setMinimalThemeBannerBackgroundPosition();
548            throttled = true;
549            // set a timeout to un-throttle
550            setTimeout(function () {
551                throttled = false;
552            }, delay);
553        }
554
555    });
556
557
558    //Disables right-click save on images
559  $("body").on("contextmenu", "img", function(e) {
560    return false;
561  });
562
563});

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.