mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
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:
parent
dc4d4f8aa9
commit
350d66d238
|
@ -3,7 +3,10 @@
|
||||||
* Dual licensed under the MIT and GPLv2 licenses just as jQuery is:
|
* Dual licensed under the MIT and GPLv2 licenses just as jQuery is:
|
||||||
* http://jquery.org/license
|
* http://jquery.org/license
|
||||||
*
|
*
|
||||||
|
* Multi-columns fork by natinusala
|
||||||
|
*
|
||||||
* documentation at http://gregweber.info/projects/uitablefilter
|
* documentation at http://gregweber.info/projects/uitablefilter
|
||||||
|
* https://github.com/natinusala/jquery-uitablefilter
|
||||||
*
|
*
|
||||||
* allows table rows to be filtered (made invisible)
|
* allows table rows to be filtered (made invisible)
|
||||||
* <code>
|
* <code>
|
||||||
|
@ -14,12 +17,15 @@
|
||||||
* jQuery object containing table rows
|
* jQuery object containing table rows
|
||||||
* phrase to search for
|
* phrase to search for
|
||||||
* optional arguments:
|
* optional arguments:
|
||||||
* column to limit search too (the column title in the table header)
|
* array of columns to limit search too (the column title in the table header)
|
||||||
* showHidden - if true, will search among the hidden elements
|
|
||||||
* ifHidden - callback to execute if one or more elements was hidden
|
* 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($) {
|
(function($) {
|
||||||
$.uiTableFilter = function(jq, phrase, column, showHidden, ifHidden){
|
$.uiTableFilter = function(jq, phrase, column, ifHidden, tdElem){
|
||||||
|
if(!tdElem) tdElem = "td";
|
||||||
var new_hidden = false;
|
var new_hidden = false;
|
||||||
if( this.last_phrase === phrase ) return false;
|
if( this.last_phrase === phrase ) return false;
|
||||||
|
|
||||||
|
@ -27,21 +33,40 @@
|
||||||
var words = phrase.toLowerCase().split(" ");
|
var words = phrase.toLowerCase().split(" ");
|
||||||
|
|
||||||
// these function pointers may change
|
// 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 noMatch = function(elem) { elem.hide(); new_hidden = true }
|
||||||
var getText = function(elem) { return elem.text() }
|
var getText = function(elem) { return elem.text() }
|
||||||
|
|
||||||
if( column ) {
|
if( column )
|
||||||
var index = null;
|
{
|
||||||
jq.find("thead > tr:last > th").each( function(i){
|
if (!$.isArray(column))
|
||||||
if( $.trim($(this).text()) == column ){
|
{
|
||||||
index = i; return false;
|
column = new Array(column);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if( index == null ) throw("given column: " + column + " not found")
|
|
||||||
|
|
||||||
getText = function(elem){ return $(elem.find(
|
var index = new Array();
|
||||||
("td:eq(" + index + ")") )).text()
|
|
||||||
|
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 {
|
else {
|
||||||
new_hidden = true;
|
new_hidden = true;
|
||||||
if (showHidden) {
|
var elems = jq.find("tbody:first > tr")
|
||||||
var elems = jq.find("tbody:first > tr");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var elems = jq.find("tbody:first > tr:visible");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elems.each(function(){
|
elems.each(function(){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user