mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Tidy up nls of command prompt and selection handling
This commit is contained in:
parent
ffeb2e91f4
commit
2de9a804a0
@ -710,7 +710,8 @@
|
|||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"empty": "No matches found",
|
"empty": "No matches found",
|
||||||
"addNode": "add a node..."
|
"addNode": "add a node...",
|
||||||
|
"actions": "search available actions"
|
||||||
},
|
},
|
||||||
"expressionEditor": {
|
"expressionEditor": {
|
||||||
"functions": "Functions",
|
"functions": "Functions",
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"ctrl-alt-o": "core:open-project",
|
"ctrl-alt-o": "core:open-project",
|
||||||
"ctrl-g v": "core:show-version-control-tab",
|
"ctrl-g v": "core:show-version-control-tab",
|
||||||
"ctrl-shift-l": "core:show-event-log",
|
"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": {
|
"red-ui-sidebar-node-config": {
|
||||||
"backspace": "core:delete-config-selection",
|
"backspace": "core:delete-config-selection",
|
||||||
|
@ -21,7 +21,6 @@ RED.commandPrompt = (function() {
|
|||||||
var searchResults;
|
var searchResults;
|
||||||
var selected = -1;
|
var selected = -1;
|
||||||
var visible = false;
|
var visible = false;
|
||||||
var activeElement;
|
|
||||||
|
|
||||||
var results = [];
|
var results = [];
|
||||||
|
|
||||||
@ -29,6 +28,8 @@ RED.commandPrompt = (function() {
|
|||||||
|
|
||||||
function search(val) {
|
function search(val) {
|
||||||
scopes = {};
|
scopes = {};
|
||||||
|
results = [];
|
||||||
|
selected = -1;
|
||||||
val = val ||"";
|
val = val ||"";
|
||||||
searchResults.editableList('empty');
|
searchResults.editableList('empty');
|
||||||
|
|
||||||
@ -40,18 +41,6 @@ RED.commandPrompt = (function() {
|
|||||||
val = val.trim().toLowerCase();
|
val = val.trim().toLowerCase();
|
||||||
|
|
||||||
actions.forEach(function(action) {
|
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()});
|
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
|
||||||
if (val !== "" && action.label.toLowerCase().indexOf(val) === -1) {
|
if (val !== "" && action.label.toLowerCase().indexOf(val) === -1) {
|
||||||
return;
|
return;
|
||||||
@ -59,8 +48,6 @@ RED.commandPrompt = (function() {
|
|||||||
results.push(action);
|
results.push(action);
|
||||||
searchResults.editableList('addItem',action)
|
searchResults.editableList('addItem',action)
|
||||||
})
|
})
|
||||||
// searchResults.editableList('addItem',{});
|
|
||||||
console.log(document.activeElement);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +70,7 @@ RED.commandPrompt = (function() {
|
|||||||
function createDialog() {
|
function createDialog() {
|
||||||
dialog = $("<div>",{id:"red-ui-commandPrompt",class:"red-ui-search"}).appendTo("#red-ui-main-container");
|
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);
|
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,
|
delay: 200,
|
||||||
change: function() {
|
change: function() {
|
||||||
search($(this).val());
|
search($(this).val());
|
||||||
@ -158,7 +145,6 @@ RED.commandPrompt = (function() {
|
|||||||
function selectCommand(command) {
|
function selectCommand(command) {
|
||||||
hide();
|
hide();
|
||||||
RED.actions.invoke(command.id);
|
RED.actions.invoke(command.id);
|
||||||
console.log(command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(v) {
|
function show(v) {
|
||||||
@ -166,7 +152,6 @@ RED.commandPrompt = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
activeElement = document.activeElement;
|
|
||||||
RED.keyboard.add("*","escape",function(){hide()});
|
RED.keyboard.add("*","escape",function(){hide()});
|
||||||
$("#red-ui-header-shade").show();
|
$("#red-ui-header-shade").show();
|
||||||
$("#red-ui-editor-shade").show();
|
$("#red-ui-editor-shade").show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user