1 2 // DETECT DEVICE 3 $(window).bind('load resize', function() { 4 5 // BROWSER CLASS 6 if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { 7 $("body").addClass("browser-safari"); 8 } 9 if (navigator.userAgent.match(/iP(hone|od|ad)/i)) { 10 $("body").removeClass("browser-safari"); 11 jQuery('body').addClass('browser-ios'); 12 } 13 // ADD PADDING TO TOP NAV IF CTA PRESENT ON LARGE SCREENS 14 var ctaWidth = $('html:not([dir="rtl"]) nav.cta-links').outerWidth(); 15 $('nav.secondary').css('padding-right', ctaWidth + 15); 16 var ctaWidth = $('html[dir="rtl"] nav.cta-links').outerWidth(); 17 $('nav.secondary').css('padding-left', ctaWidth + 5); 18 19 }); 20 21 // FIX PARALLAX 22 // IE 11 background-attachment:fixed will jitter on scroll if this is missing 23 jQuery(function() { 24 if (navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) { 25 $('body').on("mousewheel", function() { 26 event.preventDefault(); 27 var wd = event.wheelDelta; 28 var csp = window.pageYOffset; 29 window.scrollTo(0, csp - wd); 30 }); 31 } 32 }); 33 34 // ADD CLASS TO HTML ELEMENT WHEN THE MOBILE/BURGER NAVIGATION IS PRESENT 35 (function($) { 36 var $window = $(window), 37 $html = $('html'); 38 39 function resize() { 40 if ($window.width() < 992) { 41 return $html.addClass('mobile-width'); 42 } 43 $html.removeClass('mobile-width'); 44 } 45 $window 46 .resize(resize) 47 .trigger('load resize'); 48 })(jQuery); 49 50 // IMPROVE SCROLL PERFORMANCE FOR 51 // ANIMATION & 52 // HEADER HIDE/REVEAL 53 function debounce(func, wait, immediate) { 54 var timeout; 55 return function() { 56 var context = this, 57 args = arguments; 58 var later = function() { 59 timeout = null; 60 if (!immediate) func.apply(context, args); 61 }; 62 var callNow = immediate && !timeout; 63 clearTimeout(timeout); 64 timeout = setTimeout(later, wait); 65 if (callNow) func.apply(context, args); 66 }; 67 }; 68 var myEfficientScroll = debounce(function() { 69 // TRIGGER ANIMATIONS 70 // http://www.oxygenna.com/tutorials/scroll-animations-using-waypoints-js-animate-css 71 function onScrollInit(items, trigger) { 72 73 items.each(function() { 74 var osElement = $(this), 75 osAnimationClass = osElement.attr('data-os-animation'), 76 osAnimationDelay = osElement.attr('data-os-animation-delay'); 77 78 osElement.css({ 79 '-webkit-animation-delay': osAnimationDelay, 80 '-moz-animation-delay': osAnimationDelay, 81 '-ms-animation-delay': osAnimationDelay, 82 'animation-delay': osAnimationDelay 83 }); 84 85 var osTrigger = (trigger) ? trigger : osElement; 86 87 osTrigger.waypoint(function() { 88 osElement.addClass('animated').addClass(osAnimationClass); 89 }, { 90 //triggerOnce: true, 91 offset: '95%' 92 }); 93 }); 94 95 } 96 onScrollInit($('.os-animation')); 97 98 }, 250); 99 window.addEventListener('load', myEfficientScroll); 100 101 $(document).ready(function() { 102 103 cookiePolicy(); 104 105 $(".umbraco-ajax-form form").preventDoubleSubmission(); 106 107 // LAZYSIZES PRELOAD 108 $('img.lazyload').addClass('lazypreload'); 109 110 // Main Navigation 111 // $(".navigation nav.main ul li.active").addClass("mobile-open-child"); 112 $(".navigation nav.main ul li span").click(function() { 113 if ($(".navigation nav.main ul li span").length) { 114 $(this).parent().toggleClass("open-child"); 115 $(this).parent().siblings().removeClass("open-child"); 116 $(this).parent().toggleClass("open-child_mobile"); 117 $(this).parent().siblings().removeClass("open-child_mobile"); 118 } else { 119 $(this).parent().toggleClass("open-child"); 120 $(this).parent().toggleClass("open-child_mobile"); 121 } 122 }); 123 $(".navigation nav.main ul li.has-child.active").addClass("open-child_mobile"); 124 $("html").click(function() { 125 $(".navigation nav.main ul li.open-child").removeClass("open-child"); 126 }); 127 $(".navigation nav.main ul li span, header a.expand").click(function(e) { 128 e.stopPropagation(); 129 }); 130 131 // EXPAND MOBILE NAVIVAGTION 132 $("header#site-header a.expand").click(function() { 133 if ($(".navigation .reveal").length) { 134 $("header#site-header a.expand").toggleClass('active'); 135 $("html").toggleClass('reveal-out'); 136 } else { 137 $("header#site-header a.expand").toggleClass('active'); 138 $("html").toggleClass('reveal-out'); 139 } 140 }); 141 142 // EXPAND Anchor Mobile Navigation 143 $(".anchors-component .expand").click(function() { 144 if ($(".anchors-component nav").length) { 145 $(".anchors-component .expand").toggleClass('anchor-active'); 146 $(".anchors-component nav").toggleClass('open-mobile'); 147 } else { 148 $(".anchors-component .expand").toggleClass('anchor-active'); 149 $(".anchors-component nav").toggleClass('open-mobile'); 150 } 151 }); 152 153 // EXPAND HEADER SEARCH 154 $("header#site-header .site-search a.expand-search").click(function() { 155 if ($("header#site-header .site-search").length) { 156 $("header#site-header .site-search").toggleClass('open-search'); 157 $("header#site-header .site-search .form-control").focus(); 158 } else { 159 $("header#site-header .site-search").toggleClass('open-search'); 160 } 161 }); 162 $("html").click(function() { 163 $("header#site-header .site-search").removeClass("open-search"); 164 }); 165 $("header#site-header .site-search").click(function(e) { 166 e.stopPropagation(); 167 }); 168 169 //RTL for Slick 170 function rtl_slick(){ 171 if(jQuery("html").is('[dir="rtl"]')) { 172 return true; 173 } else { 174 return false; 175 }} 176 177 // BANNER 178 // PLAYS VIDEO IN BANNER 179 $('.banner-component .slides').on('init', function(ev, el) { 180 $('video').each(function() { 181 this.play(); 182 }); 183 }); 184 // ALL CAROUSELS 185 $(".component:not(.banner-component) .slides, footer#site-footer .slides").slick({ 186 rtl: rtl_slick(), 187 infinite: true, 188 speed: 600, 189 adaptiveHeight: true, 190 prevArrow: '<div class="slick-prev"><i class="icon usn_ion-ios-arrow-back"></i>', 191 nextArrow: '<div class="slick-next"><i class="icon usn_ion-ios-arrow-forward"></i>' 192 }); 193 $(".banner-component .slides, .swp .slides").slick({ 194 rtl: rtl_slick(), 195 infinite: true, 196 speed: 600, 197 fade: true, 198 adaptiveHeight: true, 199 prevArrow: '<div class="slick-prev"><i class="icon usn_ion-ios-arrow-back"></i>', 200 nextArrow: '<div class="slick-next"><i class="icon usn_ion-ios-arrow-forward"></i>' 201 }); 202 203 // SCROLL PROMPT 204 // 3 DIFFERENT VERSIONS 205 // ACCOUNTS FOR DIFFERENT OFFSETS DEPENDING: 206 // SCREEN WIDTH &/OR HEADER SHOWN 207 $('html:not(.mobile-width) body:not(.no-header) .scroll-prompt').click(function() { 208 var target; 209 $("section").next().each(function(i, element) { 210 target = ($(element).offset().top - 60);
211 if (target - 10 > $(document).scrollTop()) { 212 return false; // break 213 } 214 }); 215 $("html, body").animate({ 216 scrollTop: target 217 }, 600); 218 }); 219 $('html.mobile-width body:not(.no-header) .scroll-prompt').click(function() { 220 var target; 221 $("section").next().each(function(i, element) { 222 target = ($(element).offset().top - 90); 223 if (target - 10 > $(document).scrollTop()) { 224 return false; // break 225 } 226 }); 227 $("html, body").animate({ 228 scrollTop: target 229 }, 600); 230 }); 231 $('html body.no-header .scroll-prompt').click(function() { 232 var target; 233 $("section").next().each(function(i, element) { 234 target = ($(element).offset().top - 0); 235 if (target - 10 > $(document).scrollTop()) { 236 return false; // break 237 } 238 }); 239 $("html, body").animate({ 240 scrollTop: target 241 }, 600); 242 }); 243 244 // Anchor Navigation 245 // NEED TO FIX OFFSET FOR HEADER 246 var sections = $('section'), 247 nav = $('.anchors-component'), 248 anchor_nav_height = $('.anchors-component').outerHeight() 249 nav_height = $('header#site-header').outerHeight(); 250 nav_heightShort = $('header#site-header').outerHeight() / 2; 251 $(window).on('scroll', function () { 252 var cur_pos = $(this).scrollTop(); 253 sections.each(function() { 254 255 if ($("header#site-header").length) { 256 var top = $(this).offset().top - nav_heightShort - anchor_nav_height, 257 bottom = top + $(this).outerHeight(); 258 } else { 259 var top = $(this).offset().top - anchor_nav_height, 260 bottom = top + $(this).outerHeight(); 261 } 262 263 if (cur_pos >= top && cur_pos <= bottom) { 264 nav.find('a').removeClass('active'); 265 sections.removeClass('active'); 266 267 $(this).addClass('active'); 268 nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active'); 269 } 270 }); 271 }); 272 nav.find('a').on('click', function () { 273 var $el = $(this), 274 href = $(this).attr('href'); 275 $(".anchors-component .expand").removeClass('anchor-active'); 276 $(".anchors-component nav").removeClass('open-mobile'); 277 if ($("header#site-header").length) { 278 $('html, body').animate({ 279 scrollTop: $(href).offset().top - nav_heightShort - anchor_nav_height 280 }, 500); 281 } else { 282 $('html, body').animate({ 283 scrollTop: $(href).offset().top - anchor_nav_height 284 }, 500); 285 } 286 return false; 287 }); 288 289 }); 290 291 // LIGHTBOX 292 $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) { 293 event.preventDefault(); 294 $(this).ekkoLightbox(); 295 }); 296 297 // HEADER SCROLLING 298 var didScroll; 299 var lastScrollTop = 0; 300 var delta = 60; 301 var navbarHeight = $('header').outerHeight(); 302 303 // FIXED HEADER 304 $(window).scroll(function(event) { 305 didScroll = true; 306 var scroll = $(window).scrollTop(); 307 if (scroll >= 60) { 308 $("html").removeClass("reached-top"); 309 } else { 310 $("html").addClass("reached-top").removeClass("nav-down").removeClass("nav-up"); 311 } 312 }); 313 setInterval(function() { 314 if (didScroll) { 315 hasScrolled(); 316 didScroll = false; 317 } 318 }, 5); 319 320 function hasScrolled() { 321 var st = $(this).scrollTop(); 322 // Make sure they scroll more than delta 323 if (Math.abs(lastScrollTop - st) <= delta) 324 return; 325 if (st > lastScrollTop && st > navbarHeight) { 326 // Scroll Down 327 $('html').removeClass('nav-down').addClass('nav-up'); 328 } else { 329 // Scroll Up 330 $('html').addClass('nav-down').removeClass('nav-up'); 331 } 332 lastScrollTop = st; 333 } 334 335 // COOKIE NOTICE FUNCTION 336 function cookiePolicy() { 337 var cookiePanel = $('.usn-notification'), 338 cookieName = "cookieNotice"; 339 340 checkCookie(); 341 342 $('.accept-cookies').on('click', function(e) { 343 e.preventDefault(); 344 setCookie(); 345 }); 346 347 // Get cookie 348 function getCookie(c_name) { 349 350 var i, x, y, ARRcookies = document.cookie.split(";"); 351 for (i = 0; i < ARRcookies.length; i++) { 352 x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); 353 y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); 354 x = x.replace(/^\s+|\s+$/g, ""); 355 if (x == c_name) { 356 return unescape(y); 357 } 358 } 359 360 } 361 362 // Set cookie 363 function setCookie() { 364 365 var exdate = new Date(); 366 exdate.setDate(exdate.getDate() + exdays); 367 var c_value = "accepted" + ((exdays == null) ? "" : "; path=/; expires=" + exdate.toUTCString()); 368 document.cookie = cookieName + " =" + c_value; 369 cookiePanel.addClass("closed"); 370 cookiePanel.removeClass("open"); 371 } 372 373 // Check cookie 374 function checkCookie() { 375 376 var username = getCookie(cookieName); 377 if (username != null && username != "") { 378 cookiePanel.addClass("closed"); 379 cookiePanel.removeClass("open"); 380 } else { 381 cookiePanel.addClass("open"); 382 cookiePanel.removeClass("closed"); 383 } 384 385 } 386 387 }; 388 389 // jQuery plugin to prevent double submission of forms 390 jQuery.fn.preventDoubleSubmission = function() { 391 392 $(this).on('submit', function(e) { 393 394 e.preventDefault(); 395 396 var $form = $(this); 397 398 if ($form.data('submitted') === true) { 399 // Previously submitted - don't submit again 400 } else { 401 if ($form.valid()) { 402 // Mark it so that the next submit can be ignored 403 $form.data('submitted', true); 404 405 /*show loader*/ 406 $form.find(".ajax-loading").show(); 407 408 // Make ajax call form submission 409 $.ajax({
410 url: $form.attr('action'), 411 type: 'POST', 412 cache: false, 413 data: $form.serialize(), 414 success: function(result) { 415 416 var thankYouMessage = $form.find('input[name="umbraco_submit_message"]').val(); 417 418 $form.find('.form-container').html("<div class='umbraco-forms-submitmessage alert alert-success' role='alert'>" + thankYouMessage + "</div>"); 419 $form.find(".ajax-loading").hide(); 420 }, 421 error: function() { 422 /*hide loader*/ 423 $form.find(".ajax-loading").hide(); 424 $form.find('.UmbracoFormMessage').html("<div class='alert alert-danger alert-dismissible text-center'>An error occured. Please try again.</div>"); 425 } 426 }); 427 } 428 } 429 430 }); 431 432 // Keep chainability 433 return this; 434 };
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.