PageSourceSearch

https://nsi-canada.ca/wp-content/themes/nsi-2021/js/global.js?ver=1

js nsi-canada.ca collected 2026-10-01 10:24:58 UTC 10,819 bytes, 340 lines download raw bytes

1// ------------------------------------------------
2// add class to target users with js or no js
3// ------------------------------------------------
4    document.documentElement.classList.remove("no-js");
5document.documentElement.classList.add("js");
6
7// ------------------------------------------------
8// is touch device
9// ------------------------------------------------
10    function is_touch_device() {
11    var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
12    var mq = function (query) {
13        return window.matchMedia(query).matches;
14    }
15    if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
16        return true;
17    }
18    var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
19    return mq(query);
20}
21
22    // ------------------------------------------------
23// is keyboard user
24    // ------------------------------------------------
25    (function () {
26    'use strict';
27
28    function keyboardFocus (e) {
29        if (e.keyCode !== 9) {
30            return;
31        }
32
33        switch (e.target.nodeName.toLowerCase()) {
34            case 'input':
35            case 'select':
36            case 'textarea':
37                break;
38            default:
39                document.documentElement.classList.add('keyboard-focus');
40                document.removeEventListener('keydown', keyboardFocus, false);
41        }
42    }
43
44    document.addEventListener('keydown', keyboardFocus, false);
45})();
46
47    // ------------------------------------------------
48// make bg image square function
49    // ------------------------------------------------
50// add class "make-square" to elements
51// not tested, may be broken. contact Nikki if broken
52document.addEventListener("DOMContentLoaded", function () {
53    let squim = $('.make-square');
54
55    if (squim) {
56        function squareImage() {
57            let squimWidth = $('.make-square').width();
58            $('.make-square').css("height", squimWidth + 'px');
59        }
60        // init
61        squareImage();
62        window.addEventListener("resize", squareImage);
63    }
64});
65
66document.addEventListener("DOMContentLoaded", function () {
67    // ------------------------------------------------
68    // hamburger nav
69    // ------------------------------------------------
70    // grab the button to toggle the hamburger nav
71    var toggle = document.querySelector('#menu-button'); 
72    var closeNav = document.querySelector('#close-menu'); 
73    // grab the menu itself that houses all list items 
74    var menu = document.querySelector('#modal-menu'); 
75    // grab the first link within a menu
76    var firstLink = document.querySelector('#menu-main-menu > li:first-child > a'); 
77    // grab every subnav item in the menu
78    var subnavItems = document.querySelectorAll('#menu-main-menu li.menu-item-has-children'); 
79    var subnavLinks = document.querySelectorAll('#menu-main-menu li.menu-item-has-children > a'); 
80  
81    // toggle the main navigation
82    // ------------------------------------------------
83    function toggleNav() {
84      // main navigation is already visible, close it
85      if (menu.classList.contains('is-active')) {
86        toggle.setAttribute('aria-expanded', 'false');
87        menu.classList.remove('is-active');
88      } else {
89        // main navigation is not visible, open it
90        menu.classList.add('is-active');
91        toggle.setAttribute('aria-expanded', 'true');
92      }
93  
94      // set focus on first link within menu
95      // firstLink.focus();
96    }
97  
98    toggle.addEventListener("click", toggleNav);
99    closeNav.addEventListener("click", toggleNav);
100  
101  function deactivateParents() {
102      subnavLinks.forEach(item => {
103          item.addEventListener("click", function(event) {
104              if ( item.parentElement.classList.contains('is-open') ) {
105                  item.unbind(event);
106              } else {
107                  event.preventDefault();
108              }
109              
110          });
111      });
112  }
113  deactivateParents();
114  
115    // toggle each submenu
116    // ------------------------------------------------
117    // run through each subnav item
118    subnavItems.forEach(item => {
119  
120      // when we click on a parent menu item's link, open the subnav for it
121      item.addEventListener("click", openSubNav);
122  
123      // if we click anywhere, check if the click was inside the subnavigation
124      document.addEventListener("click", checkIfSubNav);
125  
126      function openSubNav(e) {
127        // add/remove your open class to the li (instead of the link)
128        item.classList.add('is-open');
129      }
130  
131      function closeSubNav() {          
132        // add/remove your open class to the li (instead of the link)
133        item.classList.remove('is-open');
134      }
135  
136      // if the click is in a subnav, do nothing speical. If it's outside the subnav, close the subnav
137      function checkIfSubNav(e) {
138        var isClickInsideElement = item.contains(e.target);
139          if (!isClickInsideElement) {
140              closeSubNav();
141          }
142      }
143      
144    });
145  });
146
147
148$(document).ready(function () {
149
150    // ------------------------------------------------
151    // add target _blank to all external links, automatically
152    // ------------------------------------------------
153    function targetBlank() {
154    // remove subdomain of current site's url and setup regex
155    var internal = location.host.replace("www.", "");
156        internal = new RegExp(internal, "i");
157        
158    var a = document.getElementsByTagName('a'); // then, grab every link on the page
159    for (var i = 0; i < a.length; i++) {
160      var href = a[i].host; // set the host of each link
161      if( !internal.test(href) ) { // make sure the href doesn't contain current site's host
162        a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes
163        a[i].title = a[i].title +' (opens in new window)';
164      }
165    }
166  };
167  targetBlank();
168    
169    // ------------------------------------------------
170    // scroll events 
171    // ------------------------------------------------
172    $(window).scroll(function () {
173
174    });
175
176    // ------------------------------------------------
177    // search dropdown
178    // ------------------------------------------------
179    var clicked = false;
180    
181    $('#toggleSearch').click(function() {
182        toggleSearchClick();
183    });  
184    
185    // $('#searchClose').click(function() {
186    //     toggleBtnClick();
187    // });
188
189    // hide search on page load
190    $('#searchContainer').addClass('search--hide');
191
192    function toggleSearchClick() {
193        if (clicked) {
194            $('#searchContainer').addClass('search--hide');
195            clicked = false;
196        } else {
197            $('#searchContainer').removeClass('search--hide');
198            clicked = true;
199            $('#s').focus();
200        }
201    }
202
203    gsap.registerPlugin(ScrollTrigger);
204    gsap.registerPlugin(SplitText);
205
206    gsap.from(".gsapSlideUp", {
207        y: 100,
208        duration: 0.5
209    });
210    gsap.from(".gsapSlideLeft", {
211        x: 100,
212        duration: 0.5
213    });
214    gsap.from(".gsapFadeIn", {
215        opacity: 0
216    }); 
217
218    // ------------------------------------------------
219    // gsap timeline - Homepage
220    // ------------------------------------------------
221    splitHomeTitle = new SplitText(".home .section-home-tiles h2", { type: "lines, words" }),
222    splitHomeTitleWords = splitHomeTitle.words; //an array of all the divs that wrap each character
223
224    var TimelineHomepage = gsap.timeline({
225        // scrollTrigger: {
226        //   trigger: "body",
227        //   start: "top top" // when the top of the trigger hits the top of the viewport
228        // }
229      });
230      TimelineHomepage.from([".home #site-logo",".home #menu-essentials-menu a",".home #menu-button"], {
231        duration: .2, 
232        delay: 0,
233        y: 20, 
234        opacity: 0,
235        stagger: 0.1
236    },"-=0.25");
237      TimelineHomepage.from(".home .section-home-tiles .stroke", {
238        delay: 0,
239        x: 1000,
240        opacity: 0,
241        duration: 0.4,
242        ease: "power2.inOut"
243    });
244    
245    TimelineHomepage.from(splitHomeTitleWords, {
246        duration: 0.8,
247        opacity: 0,
248        //scale: 0,
249        y: 20,
250        // rotationX: 180,
251        // transformOrigin: "0% 50% -50",
252        ease: "back",
253        stagger: 0.1
254    });
255    TimelineHomepage.from(".home .home-tiles__tile", {
256        delay: 0,
257        opacity: 0,
258        duration: 0.4,
259        ease: "power2.inOut",
260        stagger: {  
261            from: "random",
262            // ease: "power3.inOut",
263            amount: 0.7
264        }
265    });
266    TimelineHomepage.from(".home .home-tiles__tile .face", {
267        opacity: 0,
268        scale: 1.1,
269        duration: 1.3,
270        delay: 0,
271        ease: "power2.inOut"  
272    },"-=2");
273  
274
275    // ------------------------------------------------
276    // gsap timeline - Home Intro Content
277    // ------------------------------------------------
278    var TimelineBlockquote = gsap.timeline({
279        scrollTrigger: {
280          trigger: ".home-intro-content",
281          start: "bottom bottom" 
282        }
283      });
284
285    splitBlockquote = new SplitText(".quote-layer .quote__text", { type: "words,chars" }),
286    splitBlockquoteWords = splitBlockquote.words; 
287
288    TimelineBlockquote.from(".opening", {
289        delay: 0,
290        opacity: 0,
291        duration: 0.4,
292        scale: 0,
293        x: 20,
294        y: 20,
295        ease: "power2.inOut"
296    });
297    TimelineBlockquote.from(splitBlockquoteWords, {
298        duration: 0.7,
299        opacity: 0,
300        y: 20,
301        ease: "back",
302        stagger: 0.1
303    },"-=0.25");
304
305    TimelineBlockquote.from(".closing", {
306        delay: 0,
307        opacity: 0,
308        duration: 0.4,
309        scale: 0,
310        x: -20,
311        y: 20,
312        ease: "power2.inOut"
313    },"-=0.5");
314
315    // ------------------------------------------------
316    // gsap timeline - partner-logos
317    // ------------------------------------------------
318    var TimelinePartners = gsap.timeline({
319        scrollTrigger: {
320          trigger: ".home .section-partners",
321          start: "top center" 
322        }
323    });
324
325    TimelinePartners.from(".home .section-partners .partner-logos a", {
326        delay: 0,
327        opacity: 0,
328        duration: 0.4,
329        ease: "power2.inOut"
330    });
331    TimelinePartners.from(".home .section-partners .arrow", {
332        delay: 0.2,
333        opacity: 0,
334        x: -40,
335        duration: 0.4,
336        ease: "power2.inOut"
337    });
338
339
340}); // end document.ready

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.