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++) {
|
for (i=0;i<Math.min(results.length,25);i++) {
|
||||||
searchResults.editableList('addItem',results[i])
|
searchResults.editableList('addItem',results[i])
|
||||||
}
|
}
|
||||||
|
if (results.length > 25) {
|
||||||
|
searchResults.editableList('addItem', {
|
||||||
|
more: {
|
||||||
|
results: results,
|
||||||
|
start: 25
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
searchResults.editableList('addItem',{});
|
searchResults.editableList('addItem',{});
|
||||||
}
|
}
|
||||||
@ -186,8 +194,27 @@ RED.search = (function() {
|
|||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
} else if (evt.keyCode === 13) {
|
} else if (evt.keyCode === 13) {
|
||||||
// Enter
|
// Enter
|
||||||
if (results.length > 0) {
|
children = searchResults.children();
|
||||||
reveal(results[Math.max(0,selected)].node);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,12 +226,32 @@ RED.search = (function() {
|
|||||||
addButton: false,
|
addButton: false,
|
||||||
addItem: function(container,i,object) {
|
addItem: function(container,i,object) {
|
||||||
var node = object.node;
|
var node = object.node;
|
||||||
if (node === undefined) {
|
var div;
|
||||||
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
|
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 {
|
} else {
|
||||||
var def = node._def;
|
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 nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
|
||||||
var colour = RED.utils.getNodeColor(node.type,def);
|
var colour = RED.utils.getNodeColor(node.type,def);
|
||||||
|
Loading…
Reference in New Issue
Block a user