1jQuery( document ).ready( function( $ ) { 2 3 $('body').addClass('js'); 4 5 // Stop scrolling and obscure body when nav is open 6 $('.navbar-toggler').on('click', function(){ 7 if ($(this).attr( 'aria-expanded') === 'true') { 8 $('body').removeClass('menu-open'); 9 $('.menu-underlay').remove(); 10 } else { 11 $('body').addClass('menu-open').append('<div class="menu-underlay" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"></div>'); 12 } 13 }); 14 15 // Keep parent menus open briefly on desktop so users can reach submenu items. 16 var menuCloseDelay = 300; 17 var menuSwitchOpenDelay = 200; 18 var desktopMenuMediaQuery = window.matchMedia('(min-width: 1200px)'); 19 20 function clearMenuCloseTimer($item) { 21 var timer = $item.data('menu-close-timer'); 22 if (timer) { 23 clearTimeout(timer); 24 $item.removeData('menu-close-timer'); 25 } 26 } 27 28 function clearMenuOpenTimer($item) { 29 var timer = $item.data('menu-open-timer'); 30 if (timer) { 31 clearTimeout(timer); 32 $item.removeData('menu-open-timer'); 33 } 34 } 35 36 function openMenuItem($item) { 37 if (!desktopMenuMediaQuery.matches) { 38 return; 39 } 40 clearMenuCloseTimer($item); 41 $item.addClass('show'); 42 $item.children('button').attr('aria-expanded', 'true'); 43 $item.children('.dropdown-menu').css('display', '').addClass('show'); 44 } 45 46 function closeMenuItem($item) { 47 if (!desktopMenuMediaQuery.matches) { 48 return; 49 } 50 clearMenuOpenTimer($item); 51 $item.removeClass('show'); 52 $item.children('button').attr('aria-expanded', 'false'); 53 $item.children('.dropdown-menu').css('display', '').removeClass('show'); 54 } 55 56 $('.menu-item-has-children').on('mouseenter', function(){ 57 var $item = $(this); 58 if (!desktopMenuMediaQuery.matches) { 59 return; 60 } 61 62 clearMenuCloseTimer($item); 63 clearMenuOpenTimer($item); 64 65 var hasOtherOpen = $('.menu-item-has-children.show').not($item).length > 0; 66 if (hasOtherOpen && !$item.hasClass('show')) { 67 // Prevent CSS :hover from displaying this submenu before the delay completes. 68 $item.children('.dropdown-menu').removeClass('show').css('display', 'none'); 69 $item.data('menu-open-timer', setTimeout(function(){ 70 if ($item.is(':hover') || $item.find(':focus').length) { 71 openMenuItem($item); 72 } else { 73 $item.children('.dropdown-menu').css('display', ''); 74 } 75 }, menuSwitchOpenDelay)); 76 return; 77 } 78 79 openMenuItem($item); 80 }); 81 82 83 $('.menu-item-has-children').on('mouseleave focusout', function(){ 84 if (!desktopMenuMediaQuery.matches) { 85 return; 86 } 87 var $item = $(this); 88 clearMenuOpenTimer($item); 89 clearMenuCloseTimer($item); 90 $item.data('menu-close-timer', setTimeout(function(){ 91 if (!$item.is(':hover') && !$item.find(':focus').length) { 92 closeMenuItem($item); 93 } 94 }, menuCloseDelay)); 95 }); 96 97 // If we cross back to mobile while a timer is pending, clear desktop-only states. 98 desktopMenuMediaQuery.addEventListener('change', function(e){ 99 if (e.matches) { 100 return; 101 } 102 $('.menu-item-has-children').each(function(){ 103 var $item = $(this); 104 clearMenuOpenTimer($item); 105 clearMenuCloseTimer($item); 106 $item.removeClass('show'); 107 $item.children('button').attr('aria-expanded', 'false'); 108 $item.children('.dropdown-menu').css('display', '').removeClass('show'); 109 }); 110 }); 111 112 // Handle search form interactions 113 $('#search-toggle').on('click', function(e){ 114 e.preventDefault(); 115 $('#searchForm').toggleClass('show'); 116 $('#search-toggle').attr('aria-expanded', $('#searchForm').hasClass('show')); 117 $('#searchForm').find('input[type="text"]').focus(); 118 }); 119 120 function closeSearch() { 121 $('#searchForm').removeClass('show'); 122 $('#search-toggle').attr('aria-expanded', 'false'); 123 } 124 125 // if search is open, escape key closes and refocuses on the toggle 126 $(document).on('keydown.search', function(e){ 127 if ($('#searchForm').hasClass('show') && (e.key === 'Escape')) { 128 closeSearch(); 129 $('#search-toggle').focus(); 130 $(document).off('keydown.search'); 131 } 132 }); 133 134 // if focus moves away from search form, close the search form 135 $(document).on('focusin', function(e){ 136 if ($('#searchForm').hasClass('show') && !$(e.target).closest('#searchForm').length && !$(e.target).is('#search-toggle')) { 137 closeSearch(); 138 } 139 }); 140 141 // Close search form if clicking outside of it 142 $(document).on('click', function(e){ 143 if ($('#searchForm').hasClass('show') && !$(e.target).closest('#searchForm').length && !$(e.target).is('#search-toggle')) { 144 closeSearch(); 145 } 146 }); 147 148 149 // Handle hiding the menu underlay when the navbar collapses 150 $('.navbar').on('hide.bs.collapse', function(){ 151 $('.menu-underlay').remove(); 152 $('body').removeClass('menu-open'); 153 }); 154 155 156 // provide way to reset events calendar search once it has run, update education page when filters are used, update artist archive featured showing/hiding 157 $(document).ajaxStop(function(){ 158 addReset(); 159 hideFeatured(); 160 }); 161 162 function addReset(){ 163 if (window.location.href.indexOf('/events') > -1 ){ 164 //only run on events page 165 if (window.location.href.indexOf('?tribe-bar-search=') > -1 ) { 166 //add reset button if there's a search term 167 $('#search-reset').removeClass('d-none'); 168 } else { 169 //remove reset button 170 if ( ! $('#search-reset').hasClass('d-none')){ 171 $('#search-reset').addClass('d-none'); 172 } 173 } 174 } else if (window.location.href.indexOf('/education/') > -1 ) { 175 //update the education page h1 to reflect filters as they are used 176 let filter = new URL(document.location).searchParams; 177 let type = filter.get('_sfm_program_type'); 178 let audience = filter.get('_sfm_audience'); 179 180 if( filter.has('_sfm_program_type') && filter.has('_sfm_audience') ) { 181 $('.archive-page-header h1').html('Education - ' + type + ' & ' + audience ); 182 } else if( filter.has('_sfm_program_type')) { 183 $('.archive-page-header h1').html('Education - ' + type); 184 } else if( filter.has('_sfm_audience')){ 185 $('.archive-page-header h1').html('Education - ' + audience); 186 } else { 187 $('.archive-page-header h1').html('Education'); 188 } 189 } 190 } 191 192 193 addReset(); 194 195 196 // ARTIST ARCHIVE 197 198 // Move date sort toggle on Artist Archive below featured artists 199 function moveSort() { 200 if( $('body').hasClass('post-type-archive-schubert_artists') ) { 201 let featuredHeight = $('#featured-artists').height() + 185; 202 $('.sf-field-sort_order').css('bottom', -featuredHeight); 203 } 204 } 205 moveSort(); 206 207 var resizeTimer; 208 209 $(window).on('resize', function(e) { 210 211 clearTimeout(resizeTimer); 212 resizeTimer = setTimeout(function() { 213 214 moveSort(); 215 216 }, 200); 217 218 }); 219 220 // Remove Featured if Search or Filtering is in use 221 function hideFeatured(){ 222 if( $('body').hasClass('post-type-archive-schubert_artists') ){ 223 //only run on artist archive page 224 if ( 225 (window.location.href.indexOf('_sfm_instrument_type') > -1) 226 || (window.location.href.indexOf('_sf_s') > -1) 227 || (window.location.href.indexOf('sf_paged') > -1) 228 ){ 229 // hide featured and move sort accordingly if view is filtered or on page 2+ 230 $('#featured-artists').hide(); 231 $('.sf-field-sort_order').css('bottom', '-100px'); 232 } else { 233 // show featured and run moveSort funtion to place sort filter 234 $('#featured-artists').show(); 235 moveSort(); 236 } 237 } 238 } 239 240 hideFeatured(); 241 242 243 244});
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.