mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
Portal: Filter was not looking in the item description in tree mode.
SVN:trunk[4893]
This commit is contained in:
@@ -6,82 +6,78 @@
|
|||||||
* Project Website: http://wiki.aiwsolutions.net/dOQKO
|
* Project Website: http://wiki.aiwsolutions.net/dOQKO
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// WARNING : GLA 2016-02-19 : We have altered the lib as it was no longer maintained nor flexible enough
|
|
||||||
// - Added callback
|
|
||||||
// - Added latinisation of the search (accents removing)
|
|
||||||
|
|
||||||
jQuery.fn.treeListFilter = function(list, timeout, callback) {
|
jQuery.fn.treeListFilter = function(list, timeout, callback) {
|
||||||
var list = jQuery(list);
|
var list = jQuery(list);
|
||||||
var input = this;
|
var input = this;
|
||||||
var keyTimeout;
|
var keyTimeout;
|
||||||
var lastFilter = '';
|
var lastFilter = '';
|
||||||
|
|
||||||
// Default timeout
|
// Default timeout
|
||||||
if (timeout === undefined) {
|
if (timeout === undefined) {
|
||||||
timeout = 200;
|
timeout = 200;
|
||||||
}
|
}
|
||||||
// GLA : Default callback
|
// Default callback
|
||||||
if (callback === undefined) {
|
if (callback === undefined) {
|
||||||
callback = function(){ return null; };
|
callback = function(){ return null; };
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterList(ulObject, filterValue) {
|
function filterList(ulObject, filterValue) {
|
||||||
if (!ulObject.is('ul') && !ulObject.is('ol')) {
|
if (!ulObject.is('ul') && !ulObject.is('ol')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var children = ulObject.children();
|
var children = ulObject.children();
|
||||||
var result = false;
|
var result = false;
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var liObject = jQuery(children[i]);
|
var liObject = jQuery(children[i]);
|
||||||
if(liObject.is('li')) {
|
if(liObject.is('li')) {
|
||||||
var display = false;
|
var display = false;
|
||||||
if (liObject.children().length > 0) {
|
if (liObject.children().length > 0) {
|
||||||
for (var j = 0; j < liObject.children().length; j++) {
|
for (var j = 0; j < liObject.children().length; j++) {
|
||||||
var subDisplay = filterList(jQuery(liObject.children()[j]), filterValue);
|
var subDisplay = filterList(jQuery(liObject.children()[j]), filterValue);
|
||||||
display = display || subDisplay;
|
display = display || subDisplay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!display) {
|
if (!display) {
|
||||||
// GLA : Modified the search so it looks for each parts of the search and not the entire sentance
|
// Modified the search so it looks for each parts of the search and not the entire sentance
|
||||||
// GLA : Modified the text to remove accents (latinise())
|
// Modified the text to remove accents (latinise())
|
||||||
var text = liObject.find('a.tree-item').text();
|
var text = liObject.find('.tree-item-wrapper').text();
|
||||||
var textLC = text.toLowerCase().latinise();
|
var textLC = text.toLowerCase().latinise();
|
||||||
var filterValues = filterValue.split(' ');
|
var filterValues = filterValue.split(' ');
|
||||||
var display = true;
|
var display = true;
|
||||||
|
|
||||||
for(var k in filterValues)
|
for(var k in filterValues)
|
||||||
{
|
{
|
||||||
if(textLC.indexOf(filterValues[k]) < 0)
|
if(textLC.indexOf(filterValues[k]) < 0)
|
||||||
{
|
{
|
||||||
display = false;
|
display = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
liObject.css('display', display ? '' : 'none');
|
liObject.css('display', display ? '' : 'none');
|
||||||
result = result || display;
|
result = result || display;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.on('change', function(event) {
|
input.on('change', function(event) {
|
||||||
// GLA : Modified the search t remove accents (latinise())
|
// Modified the search t remove accents (latinise())
|
||||||
var filter = input.val().toLowerCase().trim().latinise();
|
var filter = input.val().toLowerCase().trim().latinise();
|
||||||
//var startTime = new Date().getTime();
|
//var startTime = new Date().getTime();
|
||||||
filterList(list, filter);
|
filterList(list, filter);
|
||||||
//var endTime = new Date().getTime();
|
//var endTime = new Date().getTime();
|
||||||
//console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + 'ms');
|
//console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + 'ms');
|
||||||
callback();
|
callback();
|
||||||
return false;
|
return false;
|
||||||
}).keydown(function() {
|
}).keydown(function() {
|
||||||
clearTimeout(keyTimeout);
|
clearTimeout(keyTimeout);
|
||||||
keyTimeout = setTimeout(function() {
|
keyTimeout = setTimeout(function() {
|
||||||
if( input.val() === lastFilter ) return;
|
if( input.val() === lastFilter ) return;
|
||||||
lastFilter = input.val();
|
lastFilter = input.val();
|
||||||
input.change();
|
input.change();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user