Your IP : 216.73.216.229


Current Path : /home/jeromecohp/www/aesecure/third/tablesorter/js/extras/
Upload File :
Current File : /home/jeromecohp/www/aesecure/third/tablesorter/js/extras/jquery.quicksearch.js

// @file : /third/tablesorter/js/extras/jquery.quicksearch.js
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:54
// @license : This program is a commercial software.  You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.

(function($, window, document, undefined){
$.fn.quicksearch=function (target, opt){
var timeout, cache, rowcache, jq_results, val='', e=this, options=$.extend({
delay: 100,
selector: null,
stripeRows: null,
loader: null,
noResults: '',
childRow: 'tablesorter-childRow',
matchedResultsCount: 0,
bind: 'keyup',
onBefore: function (){
return;},
onAfter: function (){
return;},
show: function (){
this.style.display="";},
hide: function (){
this.style.display="none";},
prepareQuery: function (val){
return val.toLowerCase().split(' ');},
testQuery: function (query, txt, _row){
for (var i=0; i < query.length; i +=1){
if(txt.indexOf(query[i])===-1){
return false;}}
return true;}}, opt);
this.go=function (){
var i=0,
numMatchedRows=0,
noresults=true,
query=options.prepareQuery(val),
val_empty=(val.replace(' ','').length===0);
for (var i=0, len=rowcache.length; i < len; i++){
if(val_empty || options.testQuery(query, cache[i], rowcache[i]) ||
($(rowcache[i]).hasClass(options.childRow) && $(rowcache[i > 1?i - 1:0]).is(':visible'))){
options.show.apply(rowcache[i]);
noresults=false;
numMatchedRows++;}else{
options.hide.apply(rowcache[i]);}}
if(noresults){
this.results(false);}else{
this.results(true);
this.stripe();}
this.matchedResultsCount=numMatchedRows;
this.loader(false);
options.onAfter();
return this;};
this.search=function (submittedVal){
val=submittedVal;
e.trigger();};
this.currentMatchedResults=function(){
return this.matchedResultsCount;};
this.stripe=function (){
if(typeof options.stripeRows==="object" && options.stripeRows !==null)
{
var joined=options.stripeRows.join(' ');var stripeRows_length=options.stripeRows.length;
jq_results.not(':hidden').each(function (i){
$(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);});}
return this;};
this.strip_html=function (input){
var output=input.replace(new RegExp('<[^<]+\>','g'), "");
output=$.trim(output.toLowerCase());
return output;};
this.results=function (bool){
if(typeof options.noResults==="string" && options.noResults !==""){
if(bool){
$(options.noResults).hide();}else{
$(options.noResults).show();}}
return this;};
this.loader=function (bool){
if(typeof options.loader==="string" && options.loader !==""){
(bool)?$(options.loader).show():$(options.loader).hide();}
return this;};
this.cache=function (){
jq_results=$(target);
if(typeof options.noResults==="string" && options.noResults !==""){
jq_results=jq_results.not(options.noResults);}
var t=(typeof options.selector==="string") ?
jq_results.find(options.selector):$(target).not(options.noResults);
cache=t.map(function (){
return e.strip_html(this.innerHTML);});
rowcache=jq_results.map(function (){
return this;});
val=val || this.val() || "";
return this.go();};
this.trigger=function (){
this.loader(true);
options.onBefore();
window.clearTimeout(timeout);
timeout=window.setTimeout(function (){
e.go();}, options.delay);
return this;};
this.cache();
this.results(true);
this.stripe();
this.loader(false);
return this.each(function (){
$(this).on(options.bind, function (){
val=$(this).val();
e.trigger();});});};}(jQuery, this, document));