Created
October 15, 2013 14:01
-
-
Save toledox82/6992043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Live Search | |
function liveSearch() { | |
// Active tab All | |
if ($('#search-filter').val() == '') { | |
$('#filter-all').addClass('active'); | |
} else { | |
$('.tabs .button').removeClass('active'); | |
} | |
// Retrieve the input field text and reset the count to zero | |
var filter = $('#search-filter').val(), count = 0; | |
// Loop through the comment list | |
$(".main-list li").each(function(){ | |
// If the list item does not contain the text phrase fade it out | |
if ($(this).text().search(new RegExp(filter, "i")) < 0) { | |
$(this).hide(); | |
// Show the list item if the phrase matches and increase the count by 1 | |
} else { | |
$(this).show(); | |
count++; | |
} | |
}); | |
// Update the counter | |
switch(count) | |
{ | |
case 0: | |
$("#filter-count").text("nenhum domínio"); | |
break; | |
case 1: | |
$("#filter-count").text(count + " domínio"); | |
break; | |
default: | |
$("#filter-count").text(count + " domínios"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment