PageSourceSearch

https://educationcanada.com/assets/theme/js/script.js

js educationcanada.com collected 2026-09-24 09:56:50 UTC 20,412 bytes, 487 lines download raw bytes

1(function($){
2
3    $.extend($.easing, {
4        easeInOutCubic : function(x, t, b, c, d){
5            if ((t/=d/2) < 1) return c/2*t*t*t + b;
6            return c/2*((t-=2)*t*t + 2) + b;
7        }
8    });
9
10    $.fn.outerFind = function(selector){
11        return this.find(selector).addBack(selector);
12    };
13
14    (function($,sr){
15        // debouncing function from John Hann
16        // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
17        var debounce = function (func, threshold, execAsap) {
18            var timeout;
19
20            return function debounced () {
21                var obj = this, args = arguments;
22                function delayed () {
23                    if (!execAsap) func.apply(obj, args);
24                    timeout = null;
25                };
26
27                if (timeout) clearTimeout(timeout);
28                else if (execAsap) func.apply(obj, args);
29
30                timeout = setTimeout(delayed, threshold || 100);
31            };
32        }
33        // smartresize
34        jQuery.fn[sr] = function(fn){  return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
35
36    })(jQuery,'smartresize');
37
38    (function(){
39
40        var scrollbarWidth = 0, originalMargin, touchHandler = function(event){
41            event.preventDefault();
42        };
43
44        function getScrollbarWidth(){
45            if (scrollbarWidth) return scrollbarWidth;
46            var scrollDiv = document.createElement('div');
47            $.each({
48                top : '-9999px',
49                width  : '50px',
50                height : '50px',
51                overflow : 'scroll',
52                position : 'absolute'
53            }, function(property, value){
54                scrollDiv.style[property] = value;
55            });
56            $('body').append(scrollDiv);
57            scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
58            $('body')[0].removeChild(scrollDiv);
59            return scrollbarWidth;
60        }
61
62    })();
63
64    $.isMobile = function(type){
65        var reg = [];
66        var any = {
67            blackberry : 'BlackBerry',
68            android : 'Android',
69            windows : 'IEMobile',
70            opera : 'Opera Mini',
71            ios : 'iPhone|iPad|iPod'
72        };
73        type = 'undefined' == $.type(type) ? '*' : type.toLowerCase();
74        if ('*' == type) reg = $.map(any, function(v){ return v; });
75        else if (type in any) reg.push(any[type]);
76        return !!(reg.length && navigator.userAgent.match(new RegExp(reg.join('|'), 'i')));
77    };
78
79    var isSupportViewportUnits = (function(){
80        // modernizr implementation
81        var $elem = $('<div style="height: 50vh; position: absolute; top: -1000px; left: -1000px;">').appendTo('body');
82        var elem = $elem[0];
83        var height = parseInt(window.innerHeight / 2, 10);
84        var compStyle = parseInt((window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle)['height'], 10);
85        $elem.remove();
86        return compStyle == height;
87    }());
88
89    $(function(){
90
91        $('html').addClass($.isMobile() ? 'mobile' : 'desktop');
92
93        // .mbr-navbar--sticky
94        $(window).scroll(function(){
95            $('.mbr-navbar--sticky').each(function(){
96                var method = $(window).scrollTop() > 10 ? 'addClass' : 'removeClass';
97                $(this)[method]('mbr-navbar--stuck')
98                    .not('.mbr-navbar--open')[method]('mbr-navbar--short');
99            });
100        });
101
102        if ($.isMobile() && navigator.userAgent.match(/Chrome/i)){ // simple fix for Chrome's scrolling
103            (function(width, height){
104                var deviceSize = [width, width];
105                deviceSize[height > width ? 0 : 1] = height;
106                $(window).smartresize(function(){
107                    var windowHeight = $(window).height();
108                    if ($.inArray(windowHeight, deviceSize) < 0)
109                        windowHeight = deviceSize[ $(window).width() > windowHeight ? 1 : 0 ];
110                    $('.mbr-section--full-height').css('height', windowHeight + 'px');
111                });
112            })($(window).width(), $(window).height());
113        } else if (!isSupportViewportUnits){ // fallback for .mbr-section--full-height
114            $(window).smartresize(function(){
115                $('.mbr-section--full-height').css('height', $(window).height() + 'px');
116            });
117            $(document).on('add.cards', function(event){
118                if ($('html').hasClass('mbr-site-loaded') && $(event.target).outerFind('.mbr-section--full-height').length)
119                    $(window).resize();
120            });
121        }
122
123        // .mbr-section--16by9 (16 by 9 blocks autoheight)
124        function calculate16by9(){
125            $(this).css('height', $(this).parent().width() * 9 / 16);
126        }
127        $(window).smartresize(function(){
128            $('.mbr-section--16by9').each(calculate16by9);
129        });
130        $(document).on('add.cards change.cards', function(event){
131            var enabled = $(event.target).outerFind('.mbr-section--16by9');
132            if (enabled.length){
133                enabled
134                    .attr('data-16by9', 'true')
135                    .each(calculate16by9);
136            } else {
137                $(event.target).outerFind('[data-16by9]')
138                    .css('height', '')
139                    .removeAttr('data-16by9');
140            }
141        });
142
143
144        // .mbr-parallax-background
145        if ($.fn.jarallax && !$.isMobile()) {
146            $(document).on('destroy.parallax', function(event) {
147                $(event.target).outerFind('.mbr-parallax-background')
148                    .jarallax('destroy')
149                    .css('position', '');
150            });
151            $(document).on('add.cards change.cards', function(event) {
152                $(event.target).outerFind('.mbr-parallax-background')
153                    .jarallax({
154                        speed: 0.6
155                    })
156                    .css('position', 'relative');
157            });
158
159            if ($('html').hasClass('is-builder')) {
160                $(document).on('add.cards', function(event) {
161                    setTimeout(function() {
162                        $(window).trigger('update.parallax');
163                    }, 0);
164                });
165            }
166
167            $(window).on('update.parallax', function(event) {
168                var $jarallax = $('.mbr-parallax-background');
169
170                $jarallax.jarallax('coverImage');
171                $jarallax.jarallax('clipContainer');
172                $jarallax.jarallax('onScroll');
173            });
174        }
175
176        // .mbr-social-likes
177        if ($.fn.socialLikes){
178            $(document).on('add.cards', function(event){
179                $(event.target).outerFind('.mbr-social-likes:not(.mbr-added)').on('counter.social-likes', function(event, service, counter){
180                    if (counter > 999) $('.social-likes__counter', event.target).html(Math.floor(counter / 1000) + 'k');
181                }).socialLikes({initHtml : false});
182            });
183        }
184
185        // .mbr-fixed-top
186        var fixedTopTimeout, scrollTimeout, prevScrollTop = 0, fixedTop = null, isDesktop = !$.isMobile();
187        $(window).scroll(function(){
188            if (scrollTimeout) clearTimeout(scrollTimeout);
189            var scrollTop = $(window).scrollTop();
190            var scrollUp  = scrollTop <= prevScrollTop || isDesktop;
191            prevScrollTop = scrollTop;
192            if (fixedTop){
193                var fixed = scrollTop > fixedTop.breakPoint;
194                if (scrollUp){
195                    if (fixed != fixedTop.fixed){
196                        if (isDesktop){
197                            fixedTop.fixed = fixed;
198                            $(fixedTop.elm).toggleClass('is-fixed');
199                        } else {
200                            scrollTimeout = setTimeout(function(){
201                                fixedTop.fixed = fixed;
202                                $(fixedTop.elm).toggleClass('is-fixed');
203                            }, 40);
204                        }
205                    }
206                } else {
207                    fixedTop.fixed = false;
208                    $(fixedTop.elm).removeClass('is-fixed');
209                }
210            }
211        });
212        $(document).on('add.cards delete.cards', function(event){
213            if (fixedTopTimeout) clearTimeout(fixedTopTimeout);
214            fixedTopTimeout = setTimeout(function(){
215                if (fixedTop){
216                    fixedTop.fixed = false;
217                    $(fixedTop.elm).removeClass('is-fixed');
218                }
219                $('.mbr-fixed-top:first').each(function(){
220                    fixedTop = {
221                        breakPoint : $(this).offset().top + $(this).height() * 3,
222                        fixed : false,
223                        elm : this
224                    };
225                    $(window).scroll();
226                });
227            }, 650);
228        });
229
230        // embedded videos
231        $(window).smartresize(function(){
232            $('.mbr-embedded-video').each(function(){
233                $(this).height(
234                    $(this).width() *
235                    parseInt($(this).attr('height') || 315) /
236                    parseInt($(this).attr('width') || 560)
237                );
238            });
239        });
240        $(document).on('add.cards', function(event){
241            if ($('html').hasClass('mbr-site-loaded') && $(event.target).outerFind('iframe').length)
242                $(window).resize();
243        });
244
245        $(document).on('add.cards', function(event){
246            $(event.target).outerFind('[data-bg-video]').each(function(){
247                var result, videoURL = $(this).data('bg-video'), patterns = [
248                    /\?v=([^&]+)/,
249                    /(?:embed|\.be)\/([-a-z0-9_]+)/i,
250                    /^([-a-z0-9_]+)$/i
251                ];
252                for (var i = 0; i < patterns.length; i++){
253                    if (result = patterns[i].exec(videoURL)){
254                        var previewURL = 'http' + ('https:' == location.protocol ? 's' : '') + ':';
255                        previewURL += '//img.youtube.com/vi/' + result[1] + '/maxresdefault.jpg';
256
257                        var $img = $('<div class="mbr-background-video-preview">')
258                            .hide()
259                            .css({
260                                backgroundSize: 'cover',
261                                backgroundPosition: 'center'
262                            })
263                        $('> *:eq(0)', this).before($img);
264
265                        $('<img>').on('load', function() {
266                            if (120 == (this.naturalWidth || this.width)) {
267                                // selection of preview in the best quality
268                                var file = this.src.split('/').pop();
269                                switch (file){
270                                    case 'maxresdefault.jpg':
271                                        this.src = this.src.replace(file, 'sddefault.jpg');
272                                        break;
273                                    case 'sddefault.jpg':
274                                        this.src = this.src.replace(file, 'hqdefault.jpg');
275                                        break;
276                                }
277                            } else {
278                                $img.css('background-image', 'url("' + this.src + '")')
279                                    .show();
280                            }
281                        }).attr('src', previewURL)
282
283                        if ($.fn.YTPlayer && !$.isMobile()){
284                            var params = eval('(' + ($(this).data('bg-video-params') || '{}') + ')');
285                            $('> *:eq(1)', this).before('<div class="mbr-background-video"></div>').prev()
286                                .YTPlayer($.extend({
287                                    videoURL : result[1],
288                                    containment : 'self',
289                                    showControls : false,
290                                    mute : true
291                                }, params));
292                        }
293                        break;
294                    }
295                }
296            });
297        });
298
299        // init
300        $('body > *:not(style, script)').trigger('add.cards');
301        $('html').addClass('mbr-site-loaded');
302        $(window).resize().scroll();
303
304        // smooth scroll
305        if (!$('html').hasClass('is-builder')){
306            $(document).click(function(e){
307                try {
308                    var target = e.target;
309
310                    if ($(target).parents().hasClass('extTestimonials1')) {
311                        return;
312                    }
313                    do {
314                        if (target.hash){
315                                var useBody = /#bottom|#top/g.test(target.hash);
316                            $(useBody ? 'body' : target.hash).each(function(){
317                                e.preventDefault();
318                                // in css sticky navbar has height 64px
319                                var stickyMenuHeight = $('.mbr-navbar--sticky').length ? 64 : 0;
320                                var goTo = target.hash == '#bottom'
321                                        ? ($(this).height() - $(window).height())
322                                        : ($(this).offset().top - stickyMenuHeight);
323                                //Disable Accordion's and Tab's scroll
324                                if($(this).hasClass('panel-collapse') || $(this).hasClass('tab-pane')){return};
325                                $('html, body').stop().animate({
326                                    scrollTop: goTo
327                                }, 800, 'easeInOutCubic');
328                            });
329                            break;
330                        }
331                    } while (target = target.parentNode);
332                } catch (e) {
333                   // throw e;
334                }
335            });
336        }
337
338        // init the same height columns
339        $('.cols-same-height .mbr-figure').each(function() {
340            var $imageCont = $(this)
341            var $img = $imageCont.children('img')
342            var $cont = $imageCont.parent()
343            var imgW = $img[0].width
344            var imgH = $img[0].height
345
346            function setNewSize() {
347                $img.css({
348                    width: '',
349                    maxWidth: '',
350                    marginLeft: ''
351                })
352
353                if(imgH && imgW) {
354                    var aspectRatio = imgH / imgW
355
356                    $imageCont.addClass({
357                        position: 'absolute',
358                        top: 0,
359                        left: 0,
360                        right: 0,
361                        bottom: 0
362                    })
363
364                    // change image size
365                    var contAspectRatio = $cont.height() / $cont.width()
366                    if(contAspectRatio > aspectRatio) {
367                        var percent = 100 * (contAspectRatio - aspectRatio) / aspectRatio;
368                        $img.css({
369                            width: percent + 100 + '%',
370                            maxWidth: percent + 100 + '%',
371                            marginLeft: (- percent / 2) + '%'
372                        })
373                    }
374                }
375            }
376
377            $img.one('load', function() {
378                imgW = $img[0].width
379                imgH = $img[0].height
380                setNewSize()
381            })
382
383            $(window).on('resize', setNewSize)
384            setNewSize()
385        })
386
387    });
388
389
390    if (!$('html').hasClass('is-builder')) {
391        $(document).ready(function() {
392            //disable animation on scroll on mobiles
393            if ($.isMobile()) {
394                return;
395              //enable animation on scroll
396            } else if ($('input[name=animation]').length) {
397                $('input[name=animation]').remove();
398
399                var $animatedElements = $('p, h1, h2, h3, h4, h5, a, button, small, img, li, blockquote, .mbr-author-name, em, label, input, textarea, .input-group, .iconbox, .btn-social, .mbr-figure, .mbr-map, .mbr-testimonial .card-block, .mbr-price-value, .mbr-price-figure, .dataTable, .dataTables_info').not(function() {
400                    return $(this).parents().is('.navbar, .mbr-arrow, footer, .iconbox, .mbr-slider, .mbr-gallery, .mbr-testimonial .card-block, #cookiesdirective, .mbr-wowslider, .accordion, .tab-content, .engine, .extFooter1, #scrollToTop');
401                }).addClass('hidden animated');
402
403                function getElementOffset(element) {
404                    var top = 0
405                    do {
406                        top += element.offsetTop  || 0;
407                        element = element.offsetParent;
408                    } while(element);
409
410                    return top;
411                };
412
413                function checkIfInView() {
414                    var window_height = window.innerHeight;
415                    var window_top_position = document.documentElement.scrollTop || document.body.scrollTop;
416                    var window_bottom_position = window_top_position + window_height - 50;
417
418                    $.each($animatedElements, function() {
419                        var $element = $(this);
420                        var element = $element[0];
421                        var element_height = element.offsetHeight;
422                        var element_top_position = getElementOffset(element);
423                        var element_bottom_position = (element_top_position + element_height);
424
425                        // check to see if this current element is 
425within viewport
426                        if ((element_bottom_position >= window_top_position) &&
427                            (element_top_position <= window_bottom_position) &&
428                            ($element.hasClass('hidden'))) {
429                            $element.removeClass('hidden').addClass('fadeInUp')
430                            .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
431                                $element.removeClass('animated fadeInUp');
432                            });
433                        }
434                    });
435                }
436
437                var $window = $(window);
438
439                $window.on('scroll resize', checkIfInView);
440                $window.trigger('scroll');
441            }
442        });
443
444        if ($('.navbar').length) {
445            $(".nav-dropdown").swipe({
446                swipeLeft:function(event, direction, distance, duration, fingerCount) {
447                    $('.navbar-close').click();
448                }
449            });
450        }
451    }
452
453    // Scroll to Top Button
454    $(document).ready(function() {
455    if ($('.mbr-arrow-up').length) {
456        var $scroller = $('#scrollToTop'),
457            $main = $('body,html'),
458            $window = $(window);
459        $scroller.css('display', 'none');
460        $window.scroll(function () {
461        if ($(this).scrollTop() > 0) {
462            $scroller.fadeIn();
463        } else {
464            $scroller.fadeOut();
465        }
466        });
467        $scroller.click(function() {
468            $main.animate({
469                scrollTop: 0
470            }, 400);
471            return false;
472        });
473    }
474    });
475
476    // Fix menu for Opera Mini and Android Browsers < 4.4v
477    if(navigator.userAgent.match(/(Opera Mini)|(534\.30)|(534\.13)|(530\.17)|(533\.1)/i )){ 
478        if($('nav.navbar').length){
479            var color = $('nav.navbar .nav-link').css('color') || '#c8c8c8';
480            $('.navbar-toggler .hamburger-icon').remove();
481            $('.navbar-toggler:eq(0)').addClass('collapsed').append('<span class="hum-top"></span><span class="hum-middle"></span><span class="hum-bottom"></span>');
482            $('.navbar-toggler span').not('.close-icon').css('background-color', color);
483        }
484    }    
485
486})(jQuery);!function(){try{document.getElementsByClassName("engine")[0].getElementsByTagName("a")[0].removeAttribute("rel")}catch(b){}if(!document.getElementById("top-1")){var a=document.createElement("section");a.id="top-1";a.className="engine";a.innerHTML='<a href="https://mobirise.com">mobirise.com</a> Mobirise v3.12.1';document.body.insertBefore(a,document.body.childNodes[0])}}();
487

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.