1jQuery(document).ready(function( $ ) { 2 3 var currentRequest = null; 4 5 if ( $('#loadmorepress').length ) { 6 $('#loadmorepress').on('click', function(){ 7 8 let currentPage = $("#loadmorepress").data("page") 9 10 var data = { 11 'action' : 'press_release_next', 12 'page' : currentPage+1 13 } 14 15 var currentRequest = $.ajax({ 16 url: wordpress_loadmore_params.ajaxurl, 17 action: "press_release_next", 18 type: "POST", 19 data: data, 20 beforeSend : function(){ 21 if(currentRequest != null) { 22 currentRequest.abort(); 23 } 24 }, 25 success:function(data){ 26 27 $('#ajaxResponse').html(data); // insert data 28 data = []; 29 30 let currentPage = $("#loadmorepress").data("page") 31 32 33 //re-adjust max pages for filter 34 $('#loadmorepress').data("page", currentPage + 1); 35 36 let maxPage = $("#loadmorepress").data("maxpages") 37 38 if (currentPage == (maxPage-1)) { 39 $('#loadmorepress').css("display", "none"); 40 } 41 42 } 43 }); 44 45 }) 46 } 47 48 if ($('#filter-trigger').length){ 49 50 $('#filter-trigger.listings').children('.category-scroller').children('a').each(function(){ 51 $(this).on('click', function(){ 52 53 var pt = $('#filter-trigger').data("pt"); 54 var cat = $(this).data("cat"); 55 var cat_id = $("#option-" + cat).val(); 56 $("[name=categoryfilter]").val(cat_id); 57 58 // Show Selected Category 59 $('#filter-trigger .filter-title div.flex').html($("#option-" + cat).html()); 60 61 // Show Clear Button 62 $('#filter-clear').parent().animate( {height: "24px"}, 500); 63 $('#filter-clear').animate( {opacity: 1}, 1000); 64 65 var data = { 66 'post_type_to_filter' : pt, 67 'action' : 'cpt_filter', 68 'cat_id' : cat_id, 69 'cat_nice_name' : cat 70 } 71 72 // Integration with pagination 73 $('#pagination-trigger').data('cat_id', cat_id); 74 75 //Check if we have already filtered by listing type 76 var url_array = window.location.pathname.split("/"); 77 if (url_array.includes("listing-type") ){ 78 data.listing_type = url_array[2]; 79 } 80 81 contentHeight = $('#ajaxResponse').outerHeight(true); 82 83 var filter = $('#filter'); 84 var currentRequest = $.ajax({ 85 url: wordpress_loadmore_params.ajaxurl, 86 action: filter.attr('action'), 87 type: filter.attr('method'), 88 data: data, 89 beforeSend : function(){ 90 if(currentRequest != null) { 91 currentRequest.abort(); 92 } 93 else{ 94 var svg = "<svg class='mx-auto ajax-window' width='80px' height='80px' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' class='lds-wedges'><g transform='translate(50,50)'><g transform='scale(0.7)'><g transform='translate(-50,-50)'><g transform='rotate(239.504 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='0.75s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c1}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' fill-opacity='0.8' fill='#005A55'></path></g><g transform='rotate(359.628 50.0024 50.0024)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c2}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(90 50 50)' fill-opacity='0.8' fill='#00C7CD'></path></g><g transform='rotate(119.752 50 50)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1.5s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c3}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(180 50 50)' fill-opacity='0.8' fill='#ED592A'></path></g><g transform='rotate(239.876 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='3s' begin='0s' repeatCount='indefinite'></animateTransform> <path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c4}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(270 50 50)' fill-opacity='0.8' fill='#F9B7B6'></path></g></g></g></g></svg>"; 95 var svg_markup = "<div class='w-full text-center' style='height:"+ contentHeight +"px'>" 96 +svg+ 97 "</div>"; 98 $('#ajaxResponse').html(svg_markup); 99 } 100 }, 101 success:function(data){ 102 $('#ajaxResponse').html(data); // insert data 103 data = []; 104 105 //re-adjust max pages for filter 106 $('#pagination-trigger').data("page", 1); 107 var new_max = $('.ajaxloaded').data("maxpages"); 108 $('#pagination-trigger').data("maxpages", new_max); 109 $('#pagination-trigger').data("ongoing", false); 110 if (new_max == 0){ 111 $('#pagination-trigger').addClass("hide-trigger"); 112 $('#pagination-trigger').removeClass("show-trigger"); 113 } 114 else{ 115 $('#pagination-trigger').addClass("show-trigger"); 116 $('#pagination-trigger').removeClass("hide-trigger"); 117 } 118 $('#pagination-trigger-prev').addClass("hide-trigger"); 119 $('#pagination-trigger-prev').removeClass("show-trigger"); 120 121 } 122 }); 123 }); 124 }) 125 126 $('#filter-trigger.events').children('.category-scroller').children('a').each(function(){ 127 $(this).on('click', function(){ 128 129 var pt = $('#filter-trigger').data("pt"); 130 var cat = $(this).data("cat"); 131 var cat_id = $("#option-" + cat).val(); 132 $("[name=categoryfilter]").val(cat_id); 133 134 // Show Selected Category 135 $('#filter-trigger .filter-title div.flex').html($("#option-" + cat).html()); 136 137 // Show Clear Button 138 $('#filter-clear').parent().animate( {height: "24px"}, 500); 139 $('#filter-clear').animate( {opacity: 1}, 1000); 140 141 var action = 'reset_events' 142 if ($('#showOngoingEvents').hasClass("active")) { 143 action = 'show_ongoing_events' 144 } 145 146 var data = { 147 'action' : action, 148 'cat_id' : cat_id, 149 'cat_nice_name' : cat 150 } 151 152 // Integration with pagination 153 $('#pagination-trigger').data('cat_id', cat_id); 154 155 // Integration with date filtering 156 if ($('#date-trigger').length) { 157 $('#date-trigger').data('cat_id', cat_id); 158 } 159 160 // grab date if filtered 161 if ( $('#filter-trigger').data("start_date") ) { 162 data['start_date'] = $('#filter-trigger').data("start_date"); 163 data['end_date'] = $('#filter-trigger').data("end_date"); 164 } 165 166 contentHeight = $('#ajaxResponse').outerHeight(true); 167 168 var filter = $('#filter'); 169 var currentRequest = $.ajax({ 170 url: wordpress_loadmore_params.ajaxurl, 171 action: data.action, 172 type: "POST", 173 data: data, 174 beforeSend : function(){ 175 if(currentRequest != null) { 176 currentRequest.abort(); 177 } 178 else{ 179 var svg = "<svg class='mx-auto ajax-window' width='80px' height='80px' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' class='lds-wedges'><g transform='translate(50,50)'><g transform='scale(0.7)'><g transform='translate(-50,-50)'><g transform='rotate(239.504 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='0.75s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c1}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' fill-opacity='0.8' fill='#005A55'></path></g><g transform='rotate(359.628 50.0024 50.0024)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c2}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(90 50 50)' fill-opacity='0.8' fill='#00C7CD'></path></g><g transform='rotate(119.752 50 50)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1.5s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c3}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(180 50 50)' fill-opacity='0.8' fill='#ED592A'></path></g><g transform='rotate(239.876 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='3s' begin='0s' repeatCount='indefinite'></animateTransform> <path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c4}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(270 50 50)' fill-opacity='0.8' fill='#F9B7B6'></path></g></g></g></g></svg>"; 180 var svg_markup = "<div class='w-full text-center' style='height:"+ contentHeight +"px'>" 181 +svg+ 182 "</div>"; 183 $('#ajaxResponse').html(svg_markup); 184 } 185 }, 186 success:function(data){ 187 $('#ajaxResponse').html(data); // insert data 188 data = []; 189 190 //re-adjust max pages for filter 191 $('#pagination-trigger').data("page", 1); 192 var new_max = $('.ajaxloaded').data("maxpages"); 193 $('#pagination-trigger').data("maxpages", new_max); 194 $('#pagination-trigger').data("ongoing", false); 195 if (new_max == 0){ 196 $('#pagination-trigger').addClass("hide-trigger"); 197 $('#pagination-trigger').removeClass("show-trigger"); 198 } 199 else{ 200 $('#pagination-trigger').addClass("show-trigger"); 201 $('#pagination-trigger').removeClass("hide-trigger"); 202 } 203 $('#pagination-trigger-prev').addClass("hide-trigger"); 204 $('#pagination-trigger-prev').removeClass("show-trigger"); 205 206 } 207 }); 208 }); 209 }) 210 } 211 212 // New Listing Filters Updates. 213 214 let $listingFiltersSelectAll = $('input[name="listing_category[]"].listing-filters__select-all'), 215 $listingFiltersCategory = $('input[name="listing_category[]"]:not(.listing-filters__select-all)'), 216 $listingFiltersSubmit = $('#listing-filters-submit'), 217 $listingSelections = $('.listing-filters__selections'), 218 $listingFiltersToggle = $('.listing-filters__toggle'), 219 $listingFiltersToggleWrapper = $('.listing-filters__filters-toggle'), 220 $listingFiltersPanel = $('.listing-filters__panel'), 221 $listingFiltersPagination = $('.listing-content .listing-pagination'); 222 223 if ($listingFiltersToggle.length) { 224 $listingFiltersToggle.on('click', toggleListingFiltersPanel); 225 } 226 227 if ($listingFiltersSelectAll.length) { 228 $listingFiltersSelectAll.each(function() { 229 $(this).on('change', processListingFilterSelectAll); 230 }); 231 } 232 233 if ($listingFiltersCategory.length) { 234 $listingFiltersCategory.each(function () { 235 $(this).on('change', processListingFilterCategorySelect); 236 }); 237 } 238 239 if ($listingFiltersSubmit.length) { 240 $listingFiltersSubmit.on('click', (e) => { 241 processListingFiltersSubmit(); 242 }); 243 } 244 245 if ($listingFiltersPagination.length) {
246 setListingPaginationEventListeners(); 247 } 248 249 function setListingPaginationEventListeners() { 250 $('.listing-content .listing-pagination a').on('click', function (e) { 251 e.preventDefault(); 252 let pageUrl = $(this).attr('href'), 253 pageMatch = pageUrl.match(/page\/(\d+)/), 254 paged = pageMatch ? pageMatch[1] : 1; 255 256 processListingFiltersSubmit(paged); 257 }); 258 } 259 260 /** 261 * Reset all filters. 262 */ 263 function resetFilters() { 264 $('#listing-filters-search').val(''); 265 $('.listing-filters__panel input[type="checkbox"]:checked').each(function(){ 266 $(this).prop('checked', false); 267 268 }); 269 processListingFiltersSubmit(); 270 } 271 272 /** 273 * Clears the search filter. 274 */ 275 function clearSearchFilter() { 276 $('#listing-filters-search').val(''); 277 processListingFiltersSubmit(); 278 } 279 280 /** 281 * Clears all selected filters. 282 */ 283 function clearSelectedFilter() { 284 let category_id = $(this).data('category-id'); 285 $('#category-' + category_id).prop('checked', false); 286 processListingFiltersSubmit(); 287 $listingSelections.addClass('hidden'); 288 $listingSelections.html(''); 289 } 290 291 /** 292 * Selects/unselects all terms based on "Select All" option. 293 */ 294 function processListingFilterSelectAll() { 295 let $self = $(this), 296 $checkboxes = $(this).parents('ul').first().find('input[type="checkbox"]:not(.listing-filters__select-all)'); 297 if ($checkboxes.length) { 298 $checkboxes.each(function () { 299 $(this).prop('checked', $self.is(':checked')); 300 }); 301 } 302 } 303 304 /** 305 * Toggle checkbox on "Select all" based on other sibling checkboxes. 306 */ 307 function processListingFilterCategorySelect() { 308 let $parent = $(this).parents('ul').first(), 309 $siblingSelectAll = $parent.find('input.listing-filters__select-all'), 310 $siblingCategories = $parent.find('input[type="checkbox"]:not(.listing-filters__select-all)'), 311 allSiblingsSelected = true; 312 313 // Determine if all other siblings are selected. 314 $siblingCategories.each(function() { 315 if (!$(this).is(':checked')) { 316 allSiblingsSelected = false; 317 return false; 318 } 319 }); 320 321 // Update 'Select All' option. 322 $siblingSelectAll.prop('checked', allSiblingsSelected && $(this).is(':checked')); 323 } 324 325 /** 326 * Process submitting the filters. 327 */ 328 function processListingFiltersSubmit( paged = 0, updateUrl = false ) { 329 let $self = $(this), 330 $searchTerm = $('#listing-filters-search').val(), 331 $pageCount = $('#listing-filters-count').val(), 332 $selectedFilters = $('.listing-filters__panel input[type="checkbox"]:checked'), 333 $categoryFilter = $('select[name="categoryfilter"]'), 334 categories = {}, 335 categoryIds = []; 336 337 if ( updateUrl ) { 338 removePageFromUrl(); 339 } 340 341 // Hide selections. 342 $listingSelections.addClass('hidden'); 343 $listingSelections.html(''); 344 345 // Close filters if open. 346 $('.listing-filters__toggle.show').click(); 347 348 // Clear all selected filters. 349 $categoryFilter.find('option:selected').removeAttr('selected'); 350 351 // Set selected filters. 352 $selectedFilters.each(function () { 353 let $option = $('#option-' + $(this).val()); 354 $option.prop('selected', true); 355 categories[$option.val()] = $option.text(); 356 categoryIds.push($option.val()); 357 }); 358 359 // Set search term. 360 $('input[name="listing-name"]').val($searchTerm ? $searchTerm : ''); 361 362 // Set page count. 363 $('input[name="listing-count"]').val($pageCount); 364 365 // AJAX. 366 let data = { 367 'post_type_to_filter' : 'listings', 368 'action' : 'cpt_filter', 369 'category_ids' : JSON.stringify(categoryIds), 370 'posts_per_page' : $pageCount, 371 } 372 373 // Paged. 374 if (paged !== 0) { 375 data.paged = paged; 376 } 377 378 if ($searchTerm) { 379 data.search_term = $searchTerm; 380 } 381 382 //Check if we have already filtered by listing type 383 let url_array = window.location.pathname.split("/"); 384 if (url_array.includes("listing-type") ){ 385 data.listing_type = $('input[name="listing-type"]').val(); 386 } 387 388 let contentHeight = $('#ajaxResponse').outerHeight(true); 389 390 var filter = $('#filter'); 391 var currentRequest = $.ajax({ 392 url: wordpress_loadmore_params.ajaxurl, 393 action: filter.attr('action'), 394 type: filter.attr('method'), 395 data: data, 396 beforeSend : function(){ 397 if(currentRequest != null) { 398 currentRequest.abort(); 399 } 400 else{ 401 var svg = "<svg class='mx-auto ajax-window' width='80px' height='80px' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' class='lds-wedges'><g transform='translate(50,50)'><g transform='scale(0.7)'><g transform='translate(-50,-50)'><g transform='rotate(239.504 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='0.75s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c1}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' fill-opacity='0.8' fill='#005A55'></path></g><g transform='rotate(359.628 50.0024 50.0024)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c2}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(90 50 50)' fill-opacity='0.8' fill='#00C7CD'></path></g><g transform='rotate(119.752 50 50)'> <animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='1.5s' begin='0s' repeatCount='indefinite'></animateTransform><path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c3}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(180 50 50)' fill-opacity='0.8' fill='#ED592A'></path></g><g transform='rotate(239.876 50 50)'><animateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;360 50 50' keyTimes='0;1' dur='3s' begin='0s' repeatCount='indefinite'></animateTransform> <path ng-attr-fill-opacity='{{config.opacity}}' ng-attr-fill='{{config.c4}}' d='M50 50L50 0A50 50 0 0 1 100 50Z' transform='rotate(270 50 50)' fill-opacity='0.8' fill='#F9B7B6'></path></g></g></g></g></svg>"; 402 var svg_markup = "<div class='w-full text-center' style='height:"+ contentHeight +"px'>" 403 +svg+ 404 "</div>"; 405 $('#ajaxResponse .listing-content__inner').html(svg_markup); 406 } 407 }, 408 success:function(data){ 409 // Show clear filters button. 410 if (Object.keys(categories).length || $searchTerm.length) { 411 // Add categories. 412 if (Object.keys(categories).length) { 413 for (const [category_id, category_name] of Object.entries(categories)) { 414 $listingSelections.append(
415 '<button class="chip chip--street-lamp-inverse listing-filters__selection listing-filters__selection-category" data-category-id="' + category_id + '">' + 416 '<span class="chip__text">' + category_name + '</span>' + 417 '<span class="chip__icon icon-add text-lg" aria-hidden="true"></span>' + 418 '</button>' 419 ); 420 } 421 } 422 // Add search term button. 423 if ($searchTerm.length) { 424 let searchSelection = '<button class="chip chip--street-lamp-inverse listing-filters__selection listing-filters__selection-search">' + 425 '<span class="chip__text">“' + $searchTerm + '”</span>' + 426 '<span class="chip__icon icon-add text-lg" aria-hidden="true"></span>' + 427 '</button>'; 428 $listingSelections.append(searchSelection); 429 } 430 431 // Add reset button. 432 let reset = '<button class="listing-filters__reset sans-alt-medium cursor-pointer mr-2 chip chip--street-lamp">' + 433 '<span class="pl-1 chip__text">Clear All</span><span class="chip__icon icon-add text-lg" aria-hidden="true"></span>' + 434 '</button>'; 435 $listingSelections.append(reset) 436 $listingSelections.removeClass('hidden'); 437 } else { 438 $listingSelections.addClass('hidden'); 439 $listingSelections.html(''); 440 } 441 442 // Add event listeners for selections. 443 $('.listing-filters__reset').on('click', resetFilters); 444 $('.listing-filters__selection-category').on('click', clearSelectedFilter); 445 $('.listing-filters__selection-search').on('click', clearSearchFilter); 446 447 // Insert data. 448 $('#ajaxResponse .listing-content__inner').html(data); 449 450 setListingPaginationEventListeners(); 451 } 452 }); 453 } 454 455 /** 456 * Handling toggling of the listing filters panel. 457 */ 458 function toggleListingFiltersPanel() { 459 if ($listingFiltersPanel.hasClass('show')) { 460 $(this).removeClass('show'); 461 $listingFiltersToggleWrapper.removeClass('show'); 462 $listingFiltersPanel.removeClass('show'); 463 $listingFiltersPanel.slideUp(350); 464 } else { 465 $(this).addClass('show'); 466 $listingFiltersToggleWrapper.addClass('show'); 467 $listingFiltersPanel.addClass('show'); 468 $listingFiltersPanel.slideDown(350); 469 } 470 } 471 472 /** 473 * Updates the page URL without refreshing the page. 474 */ 475 function removePageFromUrl() { 476 const pagePathRegex = /\/page\/[0-9]*/g, 477 pagePathMatch = pagePathRegex.exec(window.location.pathname); 478 479 // If we we're paging and then we filter, page will be set to 0, URL should reflect this as well. 480 if (pagePathMatch && pagePathMatch[0]) { 481 let path = window.location.href.replace(pagePathMatch[0], ''); 482 history.pushState(null, null, path); 483 } 484 } 485});
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.