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

Cornerstone updates #164

Merged
merged 2 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion content-az.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ function getChars($pages){
}
}
echo '</nav>';

?>
<input id="azFilterInput" type="text" class="form-control" aria-label="search site A to Z" placeholder="Type here to filter this list" />
<?php
// Generate AZ List
//if( !preg_match($pattern, $exclude, $matches) ){
$letters = array();
Expand Down
39 changes: 37 additions & 2 deletions js/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ jQuery(document).ready(function($) {
var elementsToScan = [
'#comments',
'#site-navigation',
'article.page'
'article.page',
'#page-sidebar'
]

$.each(elementsToScan, function(index, value){
Expand Down Expand Up @@ -269,7 +270,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 +336,4 @@ $(document).ready(function() {
$('#uc-header .container').fadeIn('slow');
});

})
});