mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow search results to show more than 25 results
This commit is contained in:
parent
5bf9646a76
commit
fe084a4478
@ -125,6 +125,14 @@ RED.search = (function() {
|
||||
for (i=0;i<Math.min(results.length,25);i++) {
|
||||
searchResults.editableList('addItem',results[i])
|
||||
}
|
||||
if (results.length > 25) {
|
||||
searchResults.editableList('addItem', {
|
||||
more: {
|
||||
results: results,
|
||||
start: 25
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
searchResults.editableList('addItem',{});
|
||||
}
|
||||
@ -186,11 +194,30 @@ RED.search = (function() {
|
||||
evt.preventDefault();
|
||||
} else if (evt.keyCode === 13) {
|
||||
// Enter
|
||||
children = searchResults.children();
|
||||
if ($(children[selected]).hasClass("red-ui-search-more")) {
|
||||
var object = $(children[selected]).find(".red-ui-editableList-item-content").data('data');
|
||||
if (object) {
|
||||
searchResults.editableList('removeItem',object);
|
||||
for (i=object.more.start;i<Math.min(results.length,object.more.start+25);i++) {
|
||||
searchResults.editableList('addItem',results[i])
|
||||
}
|
||||
if (results.length > object.more.start+25) {
|
||||
searchResults.editableList('addItem', {
|
||||
more: {
|
||||
results: results,
|
||||
start: object.more.start+25
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (results.length > 0) {
|
||||
reveal(results[Math.max(0,selected)].node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
searchInput.i18n();
|
||||
|
||||
@ -199,12 +226,32 @@ RED.search = (function() {
|
||||
addButton: false,
|
||||
addItem: function(container,i,object) {
|
||||
var node = object.node;
|
||||
if (node === undefined) {
|
||||
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
|
||||
var div;
|
||||
if (object.more) {
|
||||
container.parent().addClass("red-ui-search-more")
|
||||
div = $('<a>',{href:'#',class:"red-ui-search-result red-ui-search-empty"}).appendTo(container);
|
||||
div.text(RED._("palette.editor.more",{count:object.more.results.length-object.more.start}));
|
||||
div.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
searchResults.editableList('removeItem',object);
|
||||
for (i=object.more.start;i<Math.min(results.length,object.more.start+25);i++) {
|
||||
searchResults.editableList('addItem',results[i])
|
||||
}
|
||||
if (results.length > object.more.start+25) {
|
||||
searchResults.editableList('addItem', {
|
||||
more: {
|
||||
results: results,
|
||||
start: object.more.start+25
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
} else if (node === undefined) {
|
||||
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
|
||||
} else {
|
||||
var def = node._def;
|
||||
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
|
||||
div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
|
||||
|
||||
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
|
||||
var colour = RED.utils.getNodeColor(node.type,def);
|
||||
|
Loading…
Reference in New Issue
Block a user