1(($) => { 2 3 if( !$( '.advanced-search' ) ) return; 4 5 let $filters = $( '.advanced-search [data-slug]' ); 6 let $grid = $( '.grid' ); 7 let $gridPagination = $( '.pagination' ); 8 let results; 9 let $noResults; 10 let $url = $( '.reset-filter' ).attr( 'data-slug' ); 11 12 $filters.each(function() { 13 $( this ).on( 'click', (e) => { 14 e.preventDefault(); 15 if( $( this ).attr( 'data-taxonomy' ) === 'subcategories' ) { 16 let $active = $( this ).parent().parent().parent().parent().parent().find( '.active-filter' ); 17 $active.removeClass( 'active-filter' ); 18 $( this ).addClass( 'active-filter' ); 19 } else if( $( this ).attr( 'data-taxonomy' ) === 'act-impact' ) { 20 $( this ).parent().parent().find( '.active-filter' ).each(function() { 21 $( this ).removeClass( 'active-filter' ); 22 }); 23 $( this ).addClass( 'active-filter' ); 24 } else { 25 $( this ).toggleClass( 'active-filter' ); 26 } 27 editFilterInputs($('#filters-' + $(this).attr('data-taxonomy')), $(this).attr('data-id'), $(this).attr('data-taxonomy')); 28 filterActs( 1 ); 29 }); 30 }); 31 32 $( document ).on( 'click', '.advanced-pagination', (e) => { 33 e.preventDefault(); 34 35 subCatIds = $('#filters-subcategories').val().split(','); 36 themeIds = $('#filters-themed-events').val().split(','); 37 actIds = $('#filters-act-impact').val().split(','); 38 39 40 $.ajax({ 41 type: 'POST', 42 url: ajaxadvancedfilters.ajaxurl, 43 data: { 44 action: 'ajax_advanced_filters', 45 subCats: subCatIds, 46 themes: themeIds, 47 acts: actIds, 48 page: e.target.dataset.pagination 49 }, 50 success: function( result ) { 51 let $html = $( '<div />' ).html( $.parseHTML( result ) ); 52 let $cards = $html.find( '.card' ); 53 let $pagination = $html.find( '.pagination' ); 54 55 $( 'html, body' ).animate({ 56 scrollTop: $( '.acts' ).offset().top 57 }, 1200); 58 59 if( $( '.active-filter' ).length > 0 ) { 60 $( 'body' ).addClass( 'advanced-search-in-use' ); 61 $( '.reset-filter' ).removeClass( 'active' ); 62 } 63 64 $( '.no-results' ).fadeOut(); 65 $grid.find( '[data-reveal]' ).each(function() { 66 $(this).find("*").css({ "transition-delay" : "0ms" }); 67 $(this).attr('data-reveal', false); 68 }); 69 70 setTimeout(() => { 71 $grid.empty(); 72 if( $cards.length ) { 73 if( $noResults ) { 74 $noResults.remove(); 75 } 76 77 $grid.append( $cards ); 78 } else { 79 $noResults = $( '<h2 data-reveal class="no-results text:4 font:apigo-hv uppercase colour:light">No Entertainment Found</h2>' ); 80 $noResults.css({ "display" : "none" }); 81 $grid.before( $noResults ); 82 } 83 84 $gridPagination.empty(); 85 $pagination.find( 'a' ).each(function() { 86 let link = $( this ).attr( 'href' ); 87 let base = $url; 88 let newLink = base.substring(0, base.length - 1) + link; 89 $( this ).attr( 'href', newLink ); 90 $( this ).addClass( 'advanced-pagination' ); 91 $( this ).attr( 'data-pagination', $( this ).text() ); 92 93 }); 94 $gridPagination.append( $pagination.children() ); 95 96 if( $( '.page-numbers.next' ) ) { 97 $( '.page-numbers.next' ).attr( 'data-pagination', $( '.current' ).next().text() ); 98 } 99 100 if( $( '.page-numbers.prev' ) ) { 101 $( '.page-numbers.prev' ).attr( 'data-pagination', $( '.current' ).prev().text() ); 102 } 103 104 $( window ).on( 'popstate', function(event) { 105 event.preventDefault(); 106 107 if( $( '.page-numbers.prev' ) ) { 108 $( '.page-numbers.prev' ).click(); 109 } 110 111 }); 112 113 }, 1000); 114 115 setTimeout(() => { 116 if( $noResults ) { 117 $noResults.fadeIn(); 118 } 119 $grid.parent().find( '[data-reveal]' ).each(function() { 120 $(this).attr('data-reveal', 'revealed'); 121 }); 122 }, 1250); 123 } 124 }); 125 126 }); 127 128 function editFilterInputs(inputField, value, taxonomy) { 129 currentFilters = inputField.val().split(','); 130 const newFilter = value.toString(); 131 if (currentFilters.includes(newFilter)) { 132 const i = currentFilters.indexOf(newFilter); 133 currentFilters.splice(i, 1); 134 inputField.val(currentFilters); 135 } else { 136 if( taxonomy === 'themed-events' ) { 137 inputField.val(inputField.val() + ',' + newFilter); 138 } else { 139 inputField.val(',' + newFilter); 140 } 141 } 142 } 143 144 function filterActs( page ) { 145 subCatIds = $('#filters-subcategories').val().split(','); 146 themeIds = $('#filters-themed-events').val().split(','); 147 actIds = $('#filters-act-impact').val().split(','); 148 $.ajax({ 149 type: 'POST', 150 url: ajaxadvancedfilters.ajaxurl, 151 data: { 152 action: 'ajax_advanced_filters', 153 subCats: subCatIds, 154 themes: themeIds, 155 acts: actIds, 156 page: page 157 }, 158 success: function( result ) { 159 let $html = $( '<div />' ).html( $.parseHTML( result ) ); 160 let $cards = $html.find( '.card' ); 161 let $pagination = $html.find( '.pagination' ); 162 $( '.filters-apply' ).on( 'click', (e) => { 163 164 165 e.preventDefault(); 166 if( $( '.active-filter' ).length > 0 ) { 167 $( 'body' ).addClass( 'advanced-search-in-use' ); 168 $( '.reset-filter' ).removeClass( 'active' ); 169 } 170 171 $( '.no-results' ).fadeOut(); 172 $grid.find( '[data-reveal]' ).each(function() { 173 $(this).find("*").css({ "transition-delay" : "0ms" }); 174 $(this).attr('data-reveal', false); 175 }); 176 177 setTimeout(() => { 178 $grid.empty(); 179 if( $cards.length ) { 180 if( $noResults ) { 181 $noResults.remove(); 182 } 183 184 $grid.append( $cards ); 185 } else { 186 $noResults = $( '<h2 data-reveal class="no-results text:4 font:apigo-hv uppercase colour:light">No Entertainment Found</h2>' ); 187 $noResults.css({ "display" : "none" }); 188 $grid.before( $noResults ); 189 } 190 191 $gridPagination.empty(); 192 $pagination.find( 'a' ).each(function() { 193 let link = $( this ).attr( 'href' ); 194 let base = $url; 195 let newLink = base.substring(0, base.length - 1) + link; 196 $( this ).attr( 'href', newLink ); 197 $( this ).addClass( 'advanced-pagination' );
198 $( this ).attr( 'data-pagination', $( this ).text() ); 199 200 if( $( '.page-numbers.next' ) ) { 201 $( '.page-numbers.next' ).attr( 'data-pagination', $( '.current' ).next().text() ); 202 } 203 204 if( $( '.page-numbers.prev' ) ) { 205 $( '.page-numbers.prev' ).attr( 'data-pagination', $( '.current' ).prev().text() ); 206 } 207 208 $( window ).on( 'popstate', function(event) { 209 event.preventDefault(); 210 211 if( $( '.page-numbers.prev' ) ) { 212 $( '.page-numbers.prev' ).click(); 213 } 214 215 }); 216 }); 217 $gridPagination.append( $pagination.children() ); 218 }, 1000); 219 220 setTimeout(() => { 221 if( $noResults ) { 222 $noResults.fadeIn(); 223 } 224 $grid.parent().find( '[data-reveal]' ).each(function() { 225 $(this).attr('data-reveal', 'revealed'); 226 }); 227 }, 1250); 228 }); 229 } 230 }); 231 } 232 233 234})( 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.