orbit-basic/app/assets/javascripts/inc/search.js

31 lines
1.5 KiB
JavaScript

// JavaScript Document
// can copy code to any of ur desired javascsript
//extended jquery to search fast.
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$(document).ready(function(){
$("#user_filter").keyup(function(){
if($(this).val()){
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").length
if(totalfoundbyname!=0){
$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().parent().slideUp();
//$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().popover('hide');
$("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().parent().slideDown();
$("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().popover('toggle');
}else if(totalfoundbyname==0){
$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").parent().slideUp();
//$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").popover('hide');
$("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").parent().slideDown();
$("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").popover('toggle');
}
}else{
$(".checkbox").popover('hide');
$("div.checkblock").slideDown();
}
})
})