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