1/* --------------------------------------------------------------------- 2 Global Js 3 Target Browsers: All 4 5 HEADS UP! This script is for general functionality found on ALL pages and not tied to specific components, blocks, or 6 plugins. 7 8 If you need to add JS for a specific block or component, create a script file in js/components or js/blocks and 9 add your JS there. (Don't forget to enqueue it!) 10------------------------------------------------------------------------ */ 11 12var FX = ( function( FX, $ ) { 13 14 /** 15 * Doc Ready 16 * 17 * Use a separate $(function() {}) block for each function call 18 */ 19 $( () => { 20 FX.General.init(); // For super general or super short scripts 21 }) 22 23 $( () => { 24 FX.ExternalLinks.init(); // Enable by default 25 }) 26 27 $( () => { 28 FX.MobileMenu.init(); 29 }) 30 31 $( () => { 32 FX.BackToTop.init() 33 }) 34 35 36 37 /** 38 * General functionality â ideal for one-liners or super-duper short code blocks 39 */ 40 FX.General = { 41 init() { 42 this.bind(); 43 }, 44 45 bind() { 46 47 // Makes all PDF to open in new tabs 48 $('a[href*=".pdf"]').each( e => { 49 $(this).attr('target', '_blank'); 50 }); 51 52 // FitVids - responsive videos 53 $('body').fitVids(); 54 55 // Input on focus remove placeholder 56 $('input,textarea').focus( () => { 57 $(this).removeAttr('placeholder'); 58 }); 59 60 // nav search toggle 61 $('.js-search-toggle').on('click', function(e) { 62 e.preventDefault(); 63 $(this).toggleClass("is-active"); 64 65 if($(this).hasClass("is-active")) { 66 $('.popup-search').fadeIn(); 67 $('.popup-search__form input[name="s"]').val('').focus(); 68 } else { 69 $('.popup-search').fadeOut(); 70 } 71 }); 72 } 73 }; 74 75 76 77 /** 78 * Display scroll-to-top after a certain amount of pixels 79 * @type {Object} 80 */ 81 FX.BackToTop = { 82 $btn: null, 83 84 init() { 85 this.$btn = $('.back-to-top'); 86 87 if( this.$btn.length ) { 88 this.bind(); 89 } 90 }, 91 92 bind() { 93 $(window).on( 'scroll load', this.maybeShowButton.bind( this ) ); 94 this.$btn.on( 'click', this.scrollToTop ); 95 }, 96 97 maybeShowButton() { 98 if( $( window ).scrollTop() > 100 ) { // TODO: Update "100" for how far down page to show button 99 this.$btn.removeClass( 'hide' ); 100 } else { 101 this.$btn.addClass( 'hide' ); 102 } 103 }, 104 105 scrollToTop() { 106 $(window).scrollTop( 0 ); 107 } 108 }; 109 110 111 112 113 /** 114 * Mobile menu script for opening/closing menu and sub menus 115 * @type {Object} 116 */ 117 FX.MobileMenu = { 118 init() { 119 this.initMobileBtn() 120 this.initMobilePanel() 121 122 $('.nav-primary > .menu > li.menu-item-has-children > a').after('<span class="sub-menu-toggle fi-plus hidden-md-up"></span>'); 123 124 $('.sub-menu-toggle' ).click( function(){ 125 var $this = $(this), 126 $parent = $this.closest( 'li' ), 127 $wrap = $parent.find( '> .sub-menu' ); 128 129 $wrap.toggleClass('js-toggled') 130 if($wrap.hasClass("js-toggled")) { 131 $wrap.slideDown(); 132 } else { 133 $wrap.slideUp(); 134 } 135 $this.toggleClass('js-toggled'); 136 }); 137 }, 138 139 initMobileBtn() { 140 $('.js-responsive-menu-trigger-button').on('click', function(e) { 141 e.preventDefault(); 142 $('.js-responsive-menu-trigger-button').toggleClass("is-active"); 143 $(".js-page-responsive-menu").toggleClass("is-active"); 144 }); 145 }, 146 147 initMobilePanel() { 148 $('.js-page-responsive-menu').addClass('is-init'); 149 } 150 }; 151 152 153 154 /** 155 * Force External Links to open in new window. 156 * @type {Object} 157 */ 158 FX.ExternalLinks = { 159 init() { 160 var siteUrlBase = FX.siteurl.replace( /^https?:\/\/((w){3})?/, '' ); 161 162 $( 'a[href*="//"]:not([href*="'+siteUrlBase+'"])' ) 163 .not( '.ignore-external' ) // ignore class for excluding 164 .addClass( 'external' ) 165 .attr( 'target', '_blank' ) 166 .attr( 'rel', 'noopener' ); 167 } 168 }; 169 170 171 172 return FX; 173 174} ( FX || {}, 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.