1jQuery(document).ready(function($) { 2 3 // Global Vars 4 var body = $('body'); 5 6 // Topmenu Vars 7 var supermenu = $('.supermenu'); 8 var supermenu__desktop = $('.supermenu__desktop'); 9 var supermenu__mobile = $('.supermenu__mobile'); 10 var supermenu__spacer = $('.supermenu__spacer'); 11 var supermenu__primary_logo = $('.supermenu__primary-logo'); 12 var supermenu__alt_logo = $('.supermenu__alt-logo'); 13 var supermenu__logo_visible = 'supermenu__logo-visible'; 14 var supermenu__toggler = $('.supermenu__toggler'); 15 var supermenu__menu_items = $('.supermenu__mobile #supermenu__menu_items'); 16 17 // Superside Vars 18 var superside = $('.superside'); 19 var superside__toggler = $('.superside__toggler, .superside__close__icon'); 20 21/************** 22 * TOPMENU 23 **************/ 24 // Returns true if the users has scrolled past ETP 25 function supermenu__etp_crossed() { 26 var scroll = $(window).scrollTop(); 27 if (scroll >= supermenu_vars.sm_effect_triggerpoint) { 28 return true; 29 } 30 } 31 32 // Toggles Topmenu (Mobile menu) 33 supermenu__toggler.on('click', function(e) { 34 e.preventDefault(); 35 e.stopPropagation(); 36 supermenu__menu_items.toggleClass('supermenu--expand'); 37 $(this).children().toggleClass('toggler--close-x'); 38 }); 39 40 // Toggles Dropdowns 41 $('.supermenu__mobile .supermenu--dropdown-toggler').on('click', function(e) { 42 $(this).parent().toggleClass('supermenu__mobile--icon-rotated') 43 $(this).siblings('.sub-menu').toggleClass('supermenu--expand-dropdown'); 44 }); 45 46 // Adds alt-styles to supermenu after ETP 47 $(window).scroll(function() { 48 if ( supermenu_vars.sm_change_menu_styles === 'yes' && supermenu__etp_crossed() ) { 49 supermenu.addClass('supermenu--alt-styles'); 50 } else if ( supermenu_vars.sm_change_menu_styles === 'yes' && !supermenu__etp_crossed() ){ 51 supermenu.removeClass('supermenu--alt-styles'); 52 } 53 }); 54 55 // Adds Full Width Class to Supermenu after ETP 56 $(window).scroll(function() { 57 if ( supermenu_vars.sm_change_menu_width === 'full-width' && supermenu__etp_crossed() ) { 58 supermenu.addClass('supermenu--fullwidth'); 59 } else if ( supermenu_vars.sm_change_menu_width === 'full-width' && !supermenu__etp_crossed() ) { 60 supermenu.removeClass('supermenu--fullwidth'); 61 } 62 }); 63 64 // Adds Full Width Class to Supermenu after ETP 65 $(window).scroll(function() { 66 if ( supermenu__etp_crossed() ) { 67 supermenu.addClass('supermenu--etpcrossed'); 68 } else { 69 supermenu.removeClass('supermenu--etpcrossed'); 70 } 71 }); 72 73 // Fixed on Scrollup 74 $(window).scroll(function() { 75 if ( supermenu_vars.sm_fixed_menu === 'supermenu--fixed-scrollup' ) { 76 var supermenu = document.querySelector(".supermenu"); 77 var headroom = new Headroom(supermenu); 78 headroom.init(); 79 } 80 }); 81 82 // Fixed on Scrollup - Spacer 83 /*$(window).scroll(function() { 84 if ( $(supermenu).hasClass('supermenu--fixed-scrollup') ) { 85 if ( $(supermenu).hasClass('supermenu--fixed') && !$(supermenu).hasClass('supermenu--top')) { 86 supermenu__spacer.addClass('supermenu--show-spacer'); 87 } else if ( $(supermenu).hasClass('supermenu--not-fixed') ) { 88 supermenu__spacer.removeClass('supermenu--show-spacer'); 89 } else if ( $(supermenu).hasClass('supermenu--fixed') && $(supermenu).hasClass('supermenu--top') ) { 90 supermenu__spacer.removeClass('supermenu--show-spacer'); 91 } else { 92 supermenu__spacer.removeClass('supermenu--show-spacer'); 93 } 94 } 95 });*/ 96 97 // Fixed after ETP 98 $(window).scroll(function() { 99 if ( supermenu_vars.sm_fixed_menu === 'supermenu--fixed-after-etp' ) { 100 if ( supermenu__etp_crossed() && supermenu_vars.sm_fade_in_after_etp === 'no' ) { 101 supermenu.addClass('supermenu--fixed'); 102 supermenu__spacer.addClass('supermenu--show-spacer'); 103 } else if ( !supermenu__etp_crossed() && supermenu_vars.sm_fade_in_after_etp === 'no' ) { 104 supermenu.removeClass('supermenu--fixed'); 105 supermenu__spacer.removeClass('supermenu--show-spacer'); 106 } else if ( supermenu__etp_crossed() && supermenu_vars.sm_fade_in_after_etp === 'yes' ) { 107 supermenu.addClass('supermenu--fixed'); 108 supermenu.addClass('fadeIn'); 109 supermenu__spacer.addClass('supermenu--show-spacer'); 110 } else if ( !supermenu__etp_crossed() && supermenu_vars.sm_fade_in_after_etp === 'yes' ) { 111 supermenu.removeClass('supermenu--fixed'); 112 supermenu.removeClass('fadeIn'); 113 supermenu__spacer.removeClass('supermenu--show-spacer'); 114 } 115 } 116 }); 117 118 /* Add is-social-icon class to menu item if it has icon */ 119 $(".supermenu__menu-item-name:has(._mi)").parent().parent().addClass('is-social-icon'); 120 121 /* Removing spacing on top if on mobile and logged in */ 122 if ( $(window).width() < 600 && $(body).hasClass('admin-bar') ) { 123 $(window).on('scroll', function(e) { 124 var scroll = $(window).scrollTop(); 125 if ( scroll >= 46 ) { 126 supermenu.css( "top", "0" ); 127 } else { 128 supermenu.css( "top", "46px" ); 129 } 130 }); 131 } 132 133 134/************ 135 * SUPERSIDE 136 ************/ 137 // Toggles Superside 138 superside__toggler.on('click', function(e) { 139 if ( supermenu_vars.sm_superside_layout == 'aside' ) { 140 if( $(window).scrollTop() == 0 ) { 141 e.preventDefault(); 142 e.stopPropagation(); 143 body.toggleClass('superside--open'); 144 } else { 145 $("html, body").animate({scrollTop: 0}, 300); 146 setTimeout(function(){ body.toggleClass('superside--open'); }, 300); 147 } 148 } else { 149 e.preventDefault(); 150 e.stopPropagation(); 151 body.toggleClass('superside--open'); 152 } 153 }); 154 155 //Prevent Superside Flicker on Pageload 156 $('.superside').css("display", "block"); 157 158 // Close Superside on Body Click 159 $('body').on('click', function(e) { 160 body.removeClass('superside--open'); 161 }); 162 163 // Stop Superside from closing on Body Click 164 superside.on('click', function(e) { 165 e.stopPropagation(); 166 }); 167 168 // Open Superside on hash link click 169 $('a[href="#togglesuperside"]').on('click', function(event) { 170 event.preventDefault(); 171 event.stopPropagation(); 172 $("html, body").animate({ scrollTop: 0 }, "slow"); 173 body.toggleClass('superside--open'); 174 }); 175 176 // Superside Dropdown on Hover 177 $(function () { 178 $('.superside.ss-on-hover .menu-item-has-children').on('hover', function(event) { 179 $(this).children('a').toggleClass('rotate-icon'); 180 $(this).children('.sub-menu').toggleClass('show'); 181 }); 182 }); 183 184 /* Superside Dropdown on Click */ 185 $(function () {
186 $('.superside.ss-on-click .menu-item-has-children > a').on('click', function(event) { 187 event.preventDefault(); 188 $(this).toggleClass('rotate-icon'); 189 $(this).parent().children('.sub-menu').toggleClass('show'); 190 }); 191 }); 192 193/************* 194 * SEARCHFORM 195 *************/ 196 // Toggle Search 197 $(function () { 198 $('a[href="#smsearch"]').on('click', function(event) { 199 event.preventDefault(); 200 $('#smsearch').addClass('searchform--open'); 201 $('.supermenu__searchform input[type="search"]').focus(); 202 }); 203 $('#smsearch').on('click keyup', function(event) { 204 if (event.target == this || event.target.className == 'close' || event.keyCode == 27) { 205 $(this).removeClass('searchform--open'); 206 } 207 }); 208 }); 209 210 $('.supermenu__searchform_close').on('click', function(event) { 211 $('#smsearch').removeClass('searchform--open'); 212 event.preventDefault(); 213 }); 214 215 216 // Modernizr IE version test 217 // Jon Suderman 2013 218 (function(){ 219 220 // https://gist.github.com/padolsey/527683#comment-786682 221 var ie = (function(){ 222 223 // for-loop saves characters over while 224 for( var v = 3, 225 226 // b just as good as a div with 2 fewer characters 227 el = document.createElement('b'), 228 229 // el.all instead of el.getElementsByTagName('i') 230 // empty array as loop breaker (and exception-avoider) for non-IE and IE10+ 231 all = el.all || []; 232 233 // i tag not well-formed since we know that IE5-IE9 won't mind 234 el.innerHTML = '<!--[if gt IE ' + (++v) + ']><i><![endif]-->', 235 all[0]; 236 ); 237 238 // instead of undefined, returns the documentMode for IE10+ compatibility 239 // non-IE will still get undefined as before 240 return v > 4 ? v : document.documentMode; 241 242 }()); 243 244 // Check if ie version has been detected 245 if (typeof ie !== 'undefined') { 246 247 // Add ie classes to html element 248 document.documentElement.className += ' ie ie' + ie; 249 250 // Assign ie to Modernizr if available 251 if (typeof Modernizr !== 'undefined') { 252 Modernizr.ie = ie; 253 } 254 255 // Otherwise, assign ie to the window 256 else { 257 window.ie = ie; 258 } 259 260 } 261 262 })(); 263 264}); 265/*! 266 * headroom.js v0.7.0 - Give your page some headroom. Hide your header until you need it 267 * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/headroom.js 268 * License: MIT 269 */ 270 271(function(window, document) { 272 273 'use strict'; 274 275 /* exported features */ 276 277 var features = { 278 bind : !!(function(){}.bind), 279 classList : 'classList' in document.documentElement, 280 rAF : !!(window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame) 281 }; 282 window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; 283 284 /** 285 * Handles debouncing of events via requestAnimationFrame 286 * @see http://www.html5rocks.com/en/tutorials/speed/animations/ 287 * @param {Function} callback The callback to handle whichever event 288 */ 289 function Debouncer (callback) { 290 this.callback = callback; 291 this.ticking = false; 292 } 293 Debouncer.prototype = { 294 constructor : Debouncer, 295 296 /** 297 * dispatches the event to the supplied callback 298 * @private 299 */ 300 update : function() { 301 this.callback && this.callback(); 302 this.ticking = false; 303 }, 304 305 /** 306 * ensures events don't get stacked 307 * @private 308 */ 309 requestTick : function() { 310 if(!this.ticking) { 311 requestAnimationFrame(this.rafCallback || (this.rafCallback = this.update.bind(this))); 312 this.ticking = true; 313 } 314 }, 315 316 /** 317 * Attach this as the event listeners 318 */ 319 handleEvent : function() { 320 this.requestTick(); 321 } 322 }; 323 /** 324 * Check if object is part of the DOM 325 * @constructor 326 * @param {Object} obj element to check 327 */ 328 function isDOMElement(obj) { 329 return obj && typeof window !== 'undefined' && (obj === window || obj.nodeType); 330 } 331 332 /** 333 * Helper function for extending objects 334 */ 335 function extend (object /*, objectN ... */) { 336 if(arguments.length <= 0) { 337 throw new Error('Missing arguments in extend function'); 338 } 339 340 var result = object || {}, 341 key, 342 i; 343 344 for (i = 1; i < arguments.length; i++) { 345 var replacement = arguments[i] || {}; 346 347 for (key in replacement) { 348 // Recurse into object except if the object is a DOM element 349 if(typeof result[key] === 'object' && ! isDOMElement(result[key])) { 350 result[key] = extend(result[key], replacement[key]); 351 } 352 else { 353 result[key] = result[key] || replacement[key]; 354 } 355 } 356 } 357 358 return result; 359 } 360 361 /** 362 * Helper function for normalizing tolerance option to object format 363 */ 364 function normalizeTolerance (t) { 365 return t === Object(t) ? t : { down : t, up : t }; 366 } 367 368 /** 369 * UI enhancement for fixed headers. 370 * Hides header when scrolling down 371 * Shows header when scrolling up 372 * @constructor 373 * @param {DOMElement} elem the header element 374 * @param {Object} options options for the widget 375 */ 376 function Headroom (elem, options) { 377 options = extend(options, Headroom.options); 378 379 this.lastKnownScrollY = 0; 380 this.elem = elem; 381 this.debouncer = new Debouncer(this.update.bind(this)); 382 this.tolerance = normalizeTolerance(options.tolerance); 383 this.classes = options.classes; 384 this.offset = options.offset; 385 this.scroller = options.scroller; 386 this.initialised = false;
387 this.onPin = options.onPin; 388 this.onUnpin = options.onUnpin; 389 this.onTop = options.onTop; 390 this.onNotTop = options.onNotTop; 391 } 392 Headroom.prototype = { 393 constructor : Headroom, 394 395 /** 396 * Initialises the widget 397 */ 398 init : function() { 399 if(!Headroom.cutsTheMustard) { 400 return; 401 } 402 403 this.elem.classList.add(this.classes.initial); 404 405 // defer event registration to handle browser 406 // potentially restoring previous scroll position 407 setTimeout(this.attachEvent.bind(this), 100); 408 409 return this; 410 }, 411 412 /** 413 * Unattaches events and removes any classes that were added 414 */ 415 destroy : function() { 416 var classes = this.classes; 417 418 this.initialised = false; 419 this.elem.classList.remove(classes.unpinned, classes.pinned, classes.top, classes.initial); 420 this.scroller.removeEventListener('scroll', this.debouncer, false); 421 }, 422 423 /** 424 * Attaches the scroll event 425 * @private 426 */ 427 attachEvent : function() { 428 if(!this.initialised){ 429 this.lastKnownScrollY = this.getScrollY(); 430 this.initialised = true; 431 this.scroller.addEventListener('scroll', this.debouncer, false); 432 433 this.debouncer.handleEvent(); 434 } 435 }, 436 437 /** 438 * Unpins the header if it's currently pinned 439 */ 440 unpin : function() { 441 var classList = this.elem.classList, 442 classes = this.classes; 443 444 if(classList.contains(classes.pinned) || !classList.contains(classes.unpinned)) { 445 classList.add(classes.unpinned); 446 classList.remove(classes.pinned); 447 this.onUnpin && this.onUnpin.call(this); 448 } 449 }, 450 451 /** 452 * Pins the header if it's currently unpinned 453 */ 454 pin : function() { 455 var classList = this.elem.classList, 456 classes = this.classes; 457 458 if(classList.contains(classes.unpinned)) { 459 classList.remove(classes.unpinned); 460 classList.add(classes.pinned); 461 this.onPin && this.onPin.call(this); 462 } 463 }, 464 465 /** 466 * Handles the top states 467 */ 468 top : function() { 469 var classList = this.elem.classList, 470 classes = this.classes; 471 472 if(!classList.contains(classes.top)) { 473 classList.add(classes.top); 474 classList.remove(classes.notTop); 475 this.onTop && this.onTop.call(this); 476 } 477 }, 478 479 /** 480 * Handles the not top state 481 */ 482 notTop : function() { 483 var classList = this.elem.classList, 484 classes = this.classes; 485 486 if(!classList.contains(classes.notTop)) { 487 classList.add(classes.notTop); 488 classList.remove(classes.top); 489 this.onNotTop && this.onNotTop.call(this); 490 } 491 }, 492 493 /** 494 * Gets the Y scroll position 495 * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY 496 * @return {Number} pixels the page has scrolled along the Y-axis 497 */ 498 getScrollY : function() { 499 return (this.scroller.pageYOffset !== undefined) 500 ? this.scroller.pageYOffset 501 : (this.scroller.scrollTop !== undefined) 502 ? this.scroller.scrollTop 503 : (document.documentElement || document.body.parentNode || document.body).scrollTop; 504 }, 505 506 /** 507 * Gets the height of the viewport 508 * @see http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript 509 * @return {int} the height of the viewport in pixels 510 */ 511 getViewportHeight : function () { 512 return window.innerHeight 513 || document.documentElement.clientHeight 514 || document.body.clientHeight; 515 }, 516 517 /** 518 * Gets the height of the document 519 * @see http://james.padolsey.com/javascript/get-document-height-cross-browser/ 520 * @return {int} the height of the document in pixels 521 */ 522 getDocumentHeight : function () { 523 var body = document.body, 524 documentElement = document.documentElement; 525 526 return Math.max( 527 body.scrollHeight, documentElement.scrollHeight, 528 body.offsetHeight, documentElement.offsetHeight, 529 body.clientHeight, documentElement.clientHeight 530 ); 531 }, 532 533 /** 534 * Gets the height of the DOM element 535 * @param {Object} elm the element to calculate the height of which 536 * @return {int} the height of the element in pixels 537 */ 538 getElementHeight : function (elm) { 539 return Math.max( 540 elm.scrollHeight, 541 elm.offsetHeight, 542 elm.clientHeight 543 ); 544 }, 545 546 /** 547 * Gets the height of the scroller element 548 * @return {int} the height of the scroller element in pixels 549 */ 550 getScrollerHeight : function () { 551 return (this.scroller === window || this.scroller === document.body) 552 ? this.getDocumentHeight() 553 : this.getElementHeight(this.scroller); 554 }, 555 556 /** 557 * determines if the scroll position is outside of document boundaries 558 * @param {int} currentScrollY the current y scroll position 559 * @return {bool} true if out of bounds, false otherwise 560 */ 561 isOutOfBounds : function (currentScrollY) { 562 var pastTop = currentScrollY < 0,
563 pastBottom = currentScrollY + this.getViewportHeight() > this.getScrollerHeight(); 564 565 return pastTop || pastBottom; 566 }, 567 568 /** 569 * determines if the tolerance has been exceeded 570 * @param {int} currentScrollY the current scroll y position 571 * @return {bool} true if tolerance exceeded, false otherwise 572 */ 573 toleranceExceeded : function (currentScrollY, direction) { 574 return Math.abs(currentScrollY-this.lastKnownScrollY) >= this.tolerance[direction]; 575 }, 576 577 /** 578 * determine if it is appropriate to unpin 579 * @param {int} currentScrollY the current y scroll position 580 * @param {bool} toleranceExceeded has the tolerance been exceeded? 581 * @return {bool} true if should unpin, false otherwise 582 */ 583 shouldUnpin : function (currentScrollY, toleranceExceeded) { 584 var scrollingDown = currentScrollY > this.lastKnownScrollY, 585 pastOffset = currentScrollY >= this.offset; 586 587 return scrollingDown && pastOffset && toleranceExceeded; 588 }, 589 590 /** 591 * determine if it is appropriate to pin 592 * @param {int} currentScrollY the current y scroll position 593 * @param {bool} toleranceExceeded has the tolerance been exceeded? 594 * @return {bool} true if should pin, false otherwise 595 */ 596 shouldPin : function (currentScrollY, toleranceExceeded) { 597 var scrollingUp = currentScrollY < this.lastKnownScrollY, 598 pastOffset = currentScrollY <= this.offset; 599 600 return (scrollingUp && toleranceExceeded) || pastOffset; 601 }, 602 603 /** 604 * Handles updating the state of the widget 605 */ 606 update : function() { 607 var currentScrollY = this.getScrollY(), 608 scrollDirection = currentScrollY > this.lastKnownScrollY ? 'down' : 'up', 609 toleranceExceeded = this.toleranceExceeded(currentScrollY, scrollDirection); 610 611 if(this.isOutOfBounds(currentScrollY)) { // Ignore bouncy scrolling in OSX 612 return; 613 } 614 615 if (currentScrollY <= this.offset ) { 616 this.top(); 617 } else { 618 this.notTop(); 619 } 620 621 if(this.shouldUnpin(currentScrollY, toleranceExceeded)) { 622 this.unpin(); 623 } 624 else if(this.shouldPin(currentScrollY, toleranceExceeded)) { 625 this.pin(); 626 } 627 628 this.lastKnownScrollY = currentScrollY; 629 } 630 }; 631 /** 632 * Default options 633 * @type {Object} 634 */ 635 Headroom.options = { 636 tolerance : { 637 up : 0, 638 down : 0 639 }, 640 offset : 100, 641 scroller: window, 642 classes : { 643 pinned : 'supermenu--fixed', 644 unpinned : 'supermenu--unfixed', 645 top : 'supermenu--top', 646 notTop : 'supermenu--not-top', 647 initial : 'supermenu' 648 } 649 }; 650 Headroom.cutsTheMustard = typeof features !== 'undefined' && features.rAF && features.bind && features.classList; 651 652 window.Headroom = Headroom; 653 654}(window, document));
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.