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

Tidy up nls of command prompt and selection handling

This commit is contained in:
Nick O'Leary 2019-06-07 12:07:58 +01:00
parent ffeb2e91f4
commit 2de9a804a0
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 6 additions and 20 deletions

View File

@ -710,7 +710,8 @@
},
"search": {
"empty": "No matches found",
"addNode": "add a node..."
"addNode": "add a node...",
"actions": "search available actions"
},
"expressionEditor": {
"functions": "Functions",

View File

@ -23,7 +23,7 @@
"ctrl-alt-o": "core:open-project",
"ctrl-g v": "core:show-version-control-tab",
"ctrl-shift-l": "core:show-event-log",
"ctrl-shift-p":"core:show-command-prompt"
"alt-shift-p":"core:show-command-prompt"
},
"red-ui-sidebar-node-config": {
"backspace": "core:delete-config-selection",

View File

@ -21,7 +21,6 @@ RED.commandPrompt = (function() {
var searchResults;
var selected = -1;
var visible = false;
var activeElement;
var results = [];
@ -29,6 +28,8 @@ RED.commandPrompt = (function() {
function search(val) {
scopes = {};
results = [];
selected = -1;
val = val ||"";
searchResults.editableList('empty');
@ -40,18 +41,6 @@ RED.commandPrompt = (function() {
val = val.trim().toLowerCase();
actions.forEach(function(action) {
if (action.scope && action.scope !== "*") {
if (!scopes.hasOwnProperty(action.scope)) {
var target = activeElement;
while (target.nodeName !== 'BODY' && target.id !== action.scope) {
target = target.parentElement;
}
scopes[action.scope] = (target.nodeName !== 'BODY')
}
if (!scopes[action.scope]) {
return;
}
}
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
if (val !== "" && action.label.toLowerCase().indexOf(val) === -1) {
return;
@ -59,8 +48,6 @@ RED.commandPrompt = (function() {
results.push(action);
searchResults.editableList('addItem',action)
})
// searchResults.editableList('addItem',{});
console.log(document.activeElement);
}
@ -83,7 +70,7 @@ RED.commandPrompt = (function() {
function createDialog() {
dialog = $("<div>",{id:"red-ui-commandPrompt",class:"red-ui-search"}).appendTo("#red-ui-main-container");
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
searchInput = $('<input type="text" data-i18n="[placeholder]menu.label.searchInput">').appendTo(searchDiv).searchBox({
searchInput = $('<input type="text" data-i18n="[placeholder]search.actions">').appendTo(searchDiv).searchBox({
delay: 200,
change: function() {
search($(this).val());
@ -158,7 +145,6 @@ RED.commandPrompt = (function() {
function selectCommand(command) {
hide();
RED.actions.invoke(command.id);
console.log(command);
}
function show(v) {
@ -166,7 +152,6 @@ RED.commandPrompt = (function() {
return;
}
if (!visible) {
activeElement = document.activeElement;
RED.keyboard.add("*","escape",function(){hide()});
$("#red-ui-header-shade").show();
$("#red-ui-editor-shade").show();