rrs: Update uitablefilter

Due to filtering issues update to next version with same
license.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
Aníbal Limón 2015-04-13 20:18:58 +00:00 committed by Paul Eggleton
parent dc4d4f8aa9
commit 350d66d238

View File

@ -3,7 +3,10 @@
* Dual licensed under the MIT and GPLv2 licenses just as jQuery is:
* http://jquery.org/license
*
* Multi-columns fork by natinusala
*
* documentation at http://gregweber.info/projects/uitablefilter
* https://github.com/natinusala/jquery-uitablefilter
*
* allows table rows to be filtered (made invisible)
* <code>
@ -14,12 +17,15 @@
* jQuery object containing table rows
* phrase to search for
* optional arguments:
* column to limit search too (the column title in the table header)
* showHidden - if true, will search among the hidden elements
* array of columns to limit search too (the column title in the table header)
* ifHidden - callback to execute if one or more elements was hidden
* tdElem - specific element within <td> to be considered for searching or to limit search to,
* default:whole <td>. useful if <td> has more than one elements inside but want to
* limit search within only some of elements or only visible elements. eg tdElem can be "td span"
*/
(function($) {
$.uiTableFilter = function(jq, phrase, column, showHidden, ifHidden){
$.uiTableFilter = function(jq, phrase, column, ifHidden, tdElem){
if(!tdElem) tdElem = "td";
var new_hidden = false;
if( this.last_phrase === phrase ) return false;
@ -27,21 +33,40 @@
var words = phrase.toLowerCase().split(" ");
// these function pointers may change
var matches = function(elem) { elem.show(); }
var matches = function(elem) { elem.show() }
var noMatch = function(elem) { elem.hide(); new_hidden = true }
var getText = function(elem) { return elem.text() }
if( column ) {
var index = null;
jq.find("thead > tr:last > th").each( function(i){
if( $.trim($(this).text()) == column ){
index = i; return false;
if( column )
{
if (!$.isArray(column))
{
column = new Array(column);
}
});
if( index == null ) throw("given column: " + column + " not found")
getText = function(elem){ return $(elem.find(
("td:eq(" + index + ")") )).text()
var index = new Array();
jq.find("thead > tr:last > th").each(function(i)
{
for (var j = 0; j < column.length; j++)
{
if ($.trim($(this).text()) == column[j])
{
index[j] = i;
break;
}
}
});
getText = function(elem) {
var selector = "";
for (var i = 0; i < index.length; i++)
{
if (i != 0) {selector += ",";}
selector += tdElem + ":eq(" + index[i] + ")";
}
return $(elem.find((selector))).text();
}
}
@ -61,12 +86,7 @@
}
else {
new_hidden = true;
if (showHidden) {
var elems = jq.find("tbody:first > tr");
}
else {
var elems = jq.find("tbody:first > tr:visible");
}
var elems = jq.find("tbody:first > tr")
}
elems.each(function(){