You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've changed your code to support match notification when a match is found.
You are free to use this code:
/*- Copyright (c) 2008 Greg Weber greg at gregweber.info- Dual licensed under the MIT and GPLv2 licenses just as jQuery is:- http://jquery.org/license *- documentation at http://gregweber.info/projects/uitablefilter *- allows table rows to be filtered (made invisible)- <code>- t = $('table')- $.uiTableFilter( t, phrase )- </code>- arguments:- jQuery object containing table rows- phrase to search for- optional arguments:- column to limit search too (the column title in the table header)- ifHidden - callback to execute if one or more elements was hidden */(function($){$.uiTableFilter=function(jq,phrase,column,ifHidden,notifyMatchHandler){varnew_hidden=false;if(this.last_phrase===phrase)returnfalse;varphrase_length=phrase.length;varwords=phrase.toLowerCase().split(" ");// these function pointers may changevarmatches=function(elem){elem.show();if(notifyMatchHandler)notifyMatchHandler(elem);}varnoMatch=function(elem){elem.hide();new_hidden=true}vargetText=function(elem){returnelem.text()}if(column){varindex=null;jq.find("thead > tr:last > th").each(function(i){if($.trim($(this).text())==column){index=i;returnfalse;}});if(index==null)throw("given column: "+column+" not found")getText=function(elem){return$(elem.find(("td:eq("+index+")"))).text()}}// if added one letter to last time,// just check newest word and only need to hideif((words.size>1)&&(phrase.substr(0,phrase_length-1)===this.last_phrase)){if(phrase[-1]===" "){this.last_phrase=phrase;returnfalse;}varwords=words[-1];// just search for the newest word// only hide visible rowsmatches=function(elem){;}varelems=jq.find("tbody:first > tr:visible")}else{new_hidden=true;varelems=jq.find("tbody:first > tr")}elems.each(function(){varelem=$(this);$.uiTableFilter.has_words(getText(elem),words,false) ?
matches(elem) : noMatch(elem);});last_phrase=phrase;if(ifHidden&&new_hidden)ifHidden();returnjq;};// caching for speedup$.uiTableFilter.last_phrase=""// not jQuery dependent// "" [""] -> Boolean// "" [""] Boolean -> Boolean$.uiTableFilter.has_words=function(str,words,caseSensitive){vartext=caseSensitive ? str : str.toLowerCase();for(vari=0;i<words.length;i++){if(text.indexOf(words[i])===-1)returnfalse;}returntrue;}})(jQuery);
The text was updated successfully, but these errors were encountered:
I've changed your code to support match notification when a match is found.
You are free to use this code:
The text was updated successfully, but these errors were encountered: