PageSourceSearch

https://www.coleraine.qc.ca/includes/javascript/main.js?v=54

js coleraine.qc.ca collected 2026-10-02 13:18:50 UTC 15,058 bytes, 440 lines download raw bytes

1var page = {};
2
3// ------------------------------------------------------------
4// URL methods
5// ------------------------------------------------------------
6
7page.getCurrentUrl = function(){
8    return page.cleanUrl(window.location.href);
9};
10
11page.cleanUrl = function(url){
12    if (url != undefined)
13        return url.split("?")[0].split("#")[0];
14    return "";
15};
16
17page.isRootUrl = function(){
18    return page.isUrl("");
19};
20
21page.isUrl = function(url){
22    return page.cleanUrl(location.pathname) == "/" + url || page.cleanUrl(location.pathname) == url;
23};
24
25page.getDomain = function(url){
26    var a = document.createElement('a');
27    a.href = page.cleanUrl(url);
28    return a.hostname;
29};
30
31page.isExternalLink = function(url){
32    return page.getDomain(page.getCurrentUrl()) != page.getDomain(url);
33};
34
35page.changeExternalLinkTarget = function(){
36    $('ul.menu li a').each(function(){
37        if (page.isExternalLink($(this).attr('href')))
38            $(this).attr('target', 'blank');
39    });
40};
41
42
43var toggleAlert = function()
44{
45    $('.alerte-underbar').show();
46    
47    if ($('.alerte-top').is(":visible")) {
48        $('.alerte-top').slideUp("slow", function() {
49            $('.alerte-top').hide();
50            $('#lnkAlerte').text('Afficher l\'alerte');
51            //$('header').animate({ height: "90px" }, 200, function(){ /* Once completed */ });
52        });
53    } else {
54        $('.alerte-top').slideDown("slow", function() {
55            $('.alerte-top').show();
56            $('#lnkAlerte').text('Cacher l\'alerte');
57            //$('header').animate({ height: "170px" }, 200, function(){ /* Once completed */ });
58        });
59    }
60};
61
62;(function($) {
63
64   'use strict'
65
66    var isMobile = {
67        Android: function() {
68            return navigator.userAgent.match(/Android/i);
69        },
70        BlackBerry: function() {
71            return navigator.userAgent.match(/BlackBerry/i);
72        },
73        iOS: function() {
74            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
75        },
76        Opera: function() {
77            return navigator.userAgent.match(/Opera Mini/i);
78        },
79        Windows: function() {
80            return navigator.userAgent.match(/IEMobile/i);
81        },
82        any: function() {
83            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
84        }
85    };
86
87    var responsiveMenu = function() {
88        var menuType = 'desktop';
89
90        $(window).on('load resize', function() {
91            var currMenuType = 'desktop';
92            if ( matchMedia( 'only screen and (max-width: 991px)' ).matches ) {
93                currMenuType = 'mobile';
94            }
95
96            if ( currMenuType !== menuType ) {
97                menuType = currMenuType;
98
99                if ( currMenuType === 'mobile' ) {
100                    var $mobileMenu = $('#mainnav').attr('id', 'mainnav-mobi').hide();
101                    var hasChildMenu = $('#mainnav-mobi').find('li:has(ul)');
102
103                    $('#header').after($mobileMenu);
104                    hasChildMenu.children('ul').hide();
105                    hasChildMenu.children('a').after('<span class="btn-submenu"></span>');
106                    $('.btn-menu').removeClass('active');
107                } else {
108                    var $desktopMenu = $('#mainnav-mobi').attr('id', 'mainnav').removeAttr('style');
109
110                    $desktopMenu.find('.submenu').removeAttr('style');
111                    $('#header').find('.nav-wrap').append($desktopMenu);
112                    $('.btn-submenu').remove();
113                }
114            }
115        });
116
117        $('.btn-menu').on('click', function() {            
118            $('#mainnav-mobi').slideToggle(300);
119            $(this).toggleClass('active');
120        });
121
122        $(document).on('click', '#mainnav-mobi li .btn-submenu', function(e) {
123            $(this).toggleClass('active').next('ul').slideToggle(300);
124            e.stopImmediatePropagation()
125        });
126    }
127
128    var headerFixed = function() {        
129
130        if ( $('body').hasClass('header-sticky') ) {
131            var hd_height = $('#header').height();           
132            $(window).on('load scroll', function(){                
133                if ( $(window).scrollTop() >
133 hd_height + 30 ) {
134                    $('#header').addClass('downscrolled');                      
135                } else {                    
136                    $('#header').removeClass('downscrolled');                   
137                }
138                if( $(window).scrollTop() > 145 ) {
139                    $('#header').addClass('upscrolled');                    
140                } else {
141                    $('#header').removeClass('upscrolled');                    
142                }
143            })            
144        }   
145    }
146
147    var onepage_nav = function () {
148        $('.page-template-front-page .mainnav > ul > li > a').on('click',function() {           
149            var anchor = $(this).attr('href').split('#')[1];            
150            var largeScreen = matchMedia('only screen and (min-width: 992px)').matches;
151            var headerHeight = 0;
152            headerHeight = $('.header').height();            
153            if ( anchor ) {
154                if ( $('#'+anchor).length > 0 ) {
155                   if ( $('.header-sticky').length > 0 && largeScreen ) {
156                        headerHeight = headerHeight;
157                   } else {
158                        headerHeight = 0;
159                   }                   
160                   var target = $('#'+anchor).offset().top - headerHeight;
161                   $('html,body').animate({scrollTop: target}, 1000, 'easeInOutExpo');
162                }
163            }
164            return false;
165        })
166
167        $('.mainnav ul > li > a').on( 'click', function() {
168            $( this ).addClass('active').parent().siblings().children().removeClass('active');
169        });
170    }  
171
172    var widgetSlider = function() { 
173        if ( $().flexslider ) {
174            $('.widget-slider').each(function() {
175                var $this = $(this)
176                $this.find('.flexslider').flexslider({
177                    animation      :  "slide",
178                    direction      :  "horizontal", // vertical
179                    pauseOnHover   :  true,
180                    useCSS         :  false,
181                    easing         :  "swing",
182                    animationSpeed :  500,
183                    slideshowSpeed :  5000,
184                    controlNav     :  true,
185                    directionNav   :  false,
186                    slideshow      :  true,
187                    smoothHeight   :  true
188                }); // flexslider
189            }); // blog-sider
190        }
191    };
192
193    var gallerySlider = function() { 
194        if ( $().flexslider ) {
195            $('.project-gallery-slider').each(function() {
196                var $this = $(this)
197                $this.find('.flexslider').flexslider({
198                    animation      :  "slide",
199                    direction      :  "horizontal", // vertical
200                    pauseOnHover   :  true,
201                    useCSS         :  false,
202                    easing         :  "swing",
203                    animationSpeed :  500,
204                    slideshowSpeed :  5000,
205                    controlNav     :  true,
206                    directionNav   :  true,
207                    slideshow      :  true,
208                    prevText       :  '<i class="fa fa-angle-left"></i>',
209                    nextText       :  '<i class="fa fa-angle-right"></i>',
210                    smoothHeight   :  true
211                }); // flexslider
212            }); // blog-sider
213        }
214    };  
215
216    var flatClients = function() {
217        $('.flat-row').each(function() {               
218            if ( $().owlCarousel ) {
219                $(this).find('.flat-clients').owlCarousel({
220                    loop: true,
221                    margin: 30,
222                    nav: false,
223                    dots: false,                     
224                    autoplay: true,                    
225                    responsive:{
226                        0:{
227                            items: 1
228                        },
229                        480:{
230                            items: 3
231                        },
232                        767:{
233                            items: 3
234                        },
235                        991:{
236                            items: 3
237                        },
238                        1200: {
239                            items: 4
240                        }
241                    }
242                });
243            }
244        });
245    };
246
247    var detectViewport = function() {
248        $('[data-waypoint-active="yes"]').waypoint(function() {
249            $(this).trigger('on-appear');
250        }, { offset: '90%', triggerOnce: true });
251
252        $(window).on('load', function() {
253            setTimeout(function() {
254                $.waypoints('refresh');
255            }, 100);
256        });
257    };
258
259    var flatSearch = function () {
260        $('.flat-search').on( 'click', function () {
261            if( !$('.top-search' ).hasClass( "show" ))
262                $('.top-search').addClass( 'show' );
263            else
264                $( '.top-search' ).removeClass( 'show' );
265        });
266    }           
267
268    var flatTabs = function () {
269        $('.flat-tabs').each(function() {
270
271            $(this).children('.content-tab').children().hide();
272            $(this).children('.content-tab').children().first().show();
273
274            $(this).find('.menu-tab').children('li').on('click', function(e) {
275                var liActive = $(this).index(),
276                    contentActive = $(this).siblings().removeClass('active').parents('.flat-tabs').children('.content-tab').children().eq(liActive);
277
278                contentActive.addClass('active').fadeIn('slow');
279                contentActive.siblings().removeClass('active');
280                $(this).addClass('active').parents('.flat-tabs').children('.content-tab').children().eq(liActive).siblings().hide();
281                e.preventDefault();
282            });
283        });
284    };
285    
286    var goTop = function() {
287        $(window).scroll(function() {
288            if ( $(this).scrollTop() > 800 ) {
289                $('.go-top').addClass('show');
290            } else {
291                $('.go-top').removeClass('show');
292            }
293        }); 
294
295        $('.go-top').on('click', function() {            
296            $("html, body").animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo');
297            return false;
298        });
299    };
300
301    var retinaLogos = function() {
302      var retina = window.devicePixelRatio > 1 ? true : false;
303        if( retina ) {
304            $( '.header .logo' ).find('img').attr( {src:'./images/[email protected]',width:'286',height:'120'} );   
305        }
306    };    
307    
308    var parallax = function() {
309        if ( $().parallax && isMobile.any() == null ) {
310            $('.parallax1').parallax("50%", 0.2);
311            $('.parallax2').parallax("50%", 0.4);  
312            $('.parallax3').parallax("50%", 0.5);            
313        }
314    };  
315
316    var setHomeLinkMenu = function() {
317        $('.mainnav > ul > li:first-of-type').addClass("home");
318    };
319    
320    var setCurrentLinkMenu = function() {
321        $('.mainnav .menu').find('a').each(function(){
322            var a = $(this);
323            if ((getUrl(a) === getCurrentUrl()) || ((getUrl(a) + '/') === getCurrentUrl())) {
324                if ($(a).parent().parent().parent().prop('tagName') == 'LI')
325                    $(a).parent().parent().parent().children('a').addClass("active");
326                else
327                    $(a).addClass("active");
328            }
329        });
330    };
331    
332    var setCurrentRightPageNav = function() {
333        $('.mainnav .menu').find('a').each(function(){
334            var a = $(this);
335            if ((getUrl(a) === getCurrentUrl()) || ((getUrl(a) + '/') === getCurrentUrl())) {
336                if ($(a).parent().parent().parent().prop('tagName') == 'LI'){
337                    $(a).parent().parent().find('li').each(function(i,e){
338                        var className = '';
339                        
340                        if ((getUrl($(e).find('a')) === getCurrentUrl()) || ((getUrl($(e).find('a')) + '/') === getCurrentUrl()))
341                            className = 'active';
342                        
343                        $('#right-navigation-in-page ul').append($('<li>')
344                            .addClass('menu-item')
345                            .append($('<a>')
346                                .attr('href', $(e).find('a').attr('href'))
347                                .addClass(className)
348                                .text($(e).text())
349                            )
350                        );
351                    });
352                }
353            }
354        });
355    };
356    
357    var setTopLinkMenu = function() {
358        $('.top-navigator li.with-sub ul').addClass("right-sub-menu");
359    };
360    
361    var getCurrentUrl = function(){
362        return cleanUrl(window.location.href);
363    };
364    
365    var cleanUrl = function(url){
366        if (url !== undefined)
367            return url.split("?")[0].split("#")[0].replace("//", "/");
368        return "";
369    };
370    
371    var getUrl = function(a){
372        return cleanUrl($(a).attr('href'));
373    };
374    
375    var isRootUrl = function(){
376        return isUrl("");
377    };
378    
379    var isUrl = function(url){
380        return cleanUrl(location.pathname) == "/" + url || cleanUrl(location.pathname) == url;
381    };
382    
383    var getDomain = function(url){
384        var a = document.createElement('a');
385        a.href = cleanUrl(url);
386        return a.hostname;
387    };
388    
389    var isExternalLink = function(url){
390        return getDomain(getCurrentUrl()) != getDomain(url);
391    };
392    
393    var showAlertIfNecessary = function(){
394        if ($('#tdAlertContent').html().trim().length > 10) {
395            $('.navbar-fixed-top').removeClass("navbar-fixed-top");
396            $('.carousel').css("margin-top", "-30px");
397            if (isRootUrl()) {
398                toggleAlert();
399            } else {
400                $('.alerte-underbar').show();
401            }
402        }
403        
404        $('.alerte-top').on('click', function(){
405            toggleAlert();
406        });
407    };
408    
409    var addMenuClasses = function() {
410        $('.menu .with-sub').each(function(e){
411            $(this).addClass("has-children");
412        });
413    };
414    
415    $(function() { 
416        if ( matchMedia( 'only screen and (min-width: 991px)' ).matches ) {
417            headerFixed();
418        }
419        
420        setCurrentLinkMenu();
421        setTopLinkMenu();
422        setCurrentRightPageNav();
423        showAlertIfNecessary();
424        addMenuClasses();
425        
426        widgetSlider();
427        goTop();        
428        onepage_nav();
429        gallerySlider();
430        flatTabs();
431        flatClients();
432        flatSearch();
433        responsiveMenu();
434        detectViewport();
435        retinaLogos(); 
436        parallax();
437        
438        page.changeExternalLinkTarget();
439    });
440})(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.