1/* 2* 3* Custom scripts for Foundations 4* */ 5 6 7jQuery(document).ready(function ($) { 8 9 // On click of the "Sort by name" button in the filters, this code takes all the posts from the container and sorts them alphabetically by last name. 10 $('.sort-alphabetically').on('click', function () { 11 var peopleContainer = $(this).parents('.people-filters'); 12 var numberId = $('.number-id', peopleContainer).data('number'); 13 var $posts = $('#page-row-' + numberId + ' .text-people-item'); // select all posts with the aforementioned class 14 $posts.sort(function (a, b) { 15 var titleA = $(a).find('.title').text().trim(); 16 var titleB = $(b).find('.title').text().trim(); 17 18 // Extract the last name from the post titles 19 var lastNameA = titleA.split(' ').pop().toUpperCase(); 20 var lastNameB = titleB.split(' ').pop().toUpperCase(); 21 22 return (lastNameA < lastNameB) ? -1 : (lastNameA > lastNameB) ? 1 : 0; // Sort the posts by last name 23 }); 24 25 $('#page-row-' + numberId + ' .people-container').empty().append($posts); // Take all the sorted posts and put them back in the respective container 26 }); 27}); 28 29jQuery(window).load(function () { 30 var $ = jQuery, 31 body = $('body') 32 33 34 body.on('change', '.ajax-filter-select', function (e) { 35 36 37 38 var peopleContainer = $(this).parents('.people-filters'); 39 $('.filter-loader', peopleContainer).html(loader_html()) 40 var selectedParty = $('.party-filter', peopleContainer).val(); 41 var selectedWard = $('.ward-filter', peopleContainer).val(); 42 var selectedRole = $('.role-filter', peopleContainer).data('role'); 43 var numberId = $('.number-id', peopleContainer).data('number'); 44 45 46 // An ajax function that filters all the posts by Party and/or Ward. 47 // The Role filter is controlled by the wp-admin backend and is a hidden input to maintain the Role filter through ajax. 48 jQuery.ajax({ 49 type: "post", 50 dataType: "html", 51 url: aubAjax.ajaxurl,// where to get data. 52 data: {action: 'filter_people', party: selectedParty, ward: selectedWard, role: selectedRole}, 53 success: function (response) { 54 // APPEND RESULTS 55 $('#page-row-' + numberId + ' .people-container').html(response) 56 loader_destroy() 57 }, 58 }); 59 }); 60}); 61 62 63// show a loader 64function loader_html() { 65 return '<span class="loader"></span>'; 66} 67 68// remove the loader 69function loader_destroy() { 70 jQuery('.loader', jQuery('body')).remove(); 71}
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.