Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Updates to content-az.php and js/cs.js. Added a search field that fil…
…ters the list in the A-Z index.
  • Loading branch information
Zurawel committed Sep 17, 2018
1 parent ffd92e7 commit e891e03
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion content-az.php
Expand Up @@ -69,7 +69,9 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
}
}
echo '</nav>';

?>
<input id="azFilterInput" type="text" class="form-control" aria-label=“search site a-z” placeholder="Type here to filter this list" />
<?php
// Generate AZ List
//if( !preg_match($pattern, $exclude, $matches) ){
$letters = array();
Expand Down
36 changes: 35 additions & 1 deletion js/cs.js
Expand Up @@ -269,7 +269,41 @@ function squareImg(img){

};

/*
Filter Functionality for the A-Z Index
The function will hide any text that does not match the filter input and remove letters
if there are no matches for that letter.
*/
var filterEvent = null;

$("#azFilterInput").keyup(function(){
azFilter();
});

function azFilter(){
var filterInput = $("#azFilterInput").val();

// Show everything that could have been hidden
$(".az-letter:hidden, .az-letter-list li:hidden").each(function(){
$(this).show();
});

if(filterInput !== ""){
// Select any az-letter-page class where the text does not match the regular expression
$("a.az-letter-page").filter( function(i){ return $(this).html().match(new RegExp(filterInput, "i")) === null }).each(function(){
$(this).parent("li").hide();
var numberOfVisibleListItems = $(this).parents(".az-letter-list").children("li:visible").length;

// If there are no visible list items for a letter than we will hide the whole div
if(numberOfVisibleListItems === 0){
$(this).parents(".az-letter").hide();
}
});
}
}

/* ========================================= */

$(document).ready(function(){
stickyFoot();
Expand Down Expand Up @@ -301,4 +335,4 @@ $(document).ready(function() {
$('#uc-header .container').fadeIn('slow');
});

})
});

0 comments on commit e891e03

Please sign in to comment.