1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge remote-tracking branch 'upstream/dev' into dev-redo

This commit is contained in:
Kunihiko Toumura 2019-06-23 16:19:15 +09:00
commit b1bff62bf7

View File

@ -23,6 +23,7 @@ RED.actionList = (function() {
var visible = false; var visible = false;
var filterTerm = ""; var filterTerm = "";
var filterTerms = [];
var previousActiveElement; var previousActiveElement;
function ensureSelectedIsVisible() { function ensureSelectedIsVisible() {
@ -46,9 +47,14 @@ RED.actionList = (function() {
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog); var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({ searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
change: function() { change: function() {
filterTerm = $(this).val(); filterTerm = $(this).val().trim();
filterTerms = filterTerm.split(" ");
searchResults.editableList('filter'); searchResults.editableList('filter');
searchResults.find("li.selected").removeClass("selected"); searchResults.find("li.selected").removeClass("selected");
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
}
} }
}); });
@ -61,7 +67,6 @@ RED.actionList = (function() {
var children = searchResults.children(":visible"); var children = searchResults.children(":visible");
if (children.length) { if (children.length) {
$(children[0]).addClass('selected'); $(children[0]).addClass('selected');
RED.a = children[0];
} }
} else { } else {
var nextChild = selectedChild.nextAll(":visible").first(); var nextChild = selectedChild.nextAll(":visible").first();
@ -115,8 +120,17 @@ RED.actionList = (function() {
}, },
scrollOnAdd: false, scrollOnAdd: false,
filter: function(item) { filter: function(item) {
if (filterTerm !== "" && item.label.toLowerCase().indexOf(filterTerm) === -1) { if (filterTerm !== "") {
return false; var pos=0;
for (var i=0;i<filterTerms.length;i++) {
var j = item._label.indexOf(filterTerms[i],pos);
if (j > -1) {
pos = j;
} else {
return false;
}
}
return true;
} }
return true; return true;
} }
@ -156,12 +170,17 @@ RED.actionList = (function() {
}); });
actions.forEach(function(action) { actions.forEach(function(action) {
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()}); action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
action._label = action.label.toLowerCase();
searchResults.editableList('addItem',action) searchResults.editableList('addItem',action)
}) })
RED.events.emit("actionList:open"); RED.events.emit("actionList:open");
visible = true; visible = true;
} }
searchInput.trigger("focus"); searchInput.trigger("focus");
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
}
} }
function hide() { function hide() {