mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fixed problem with RED._ being unavailable to module code
This commit is contained in:
parent
5ea68dafc4
commit
cb1d18c7c8
@ -200,6 +200,7 @@ var RED = (function() {
|
||||
RED.workspaces.init();
|
||||
RED.clipboard.init();
|
||||
RED.view.init();
|
||||
RED.editor.init();
|
||||
|
||||
RED.deploy.init(RED.settings.theme("deployButton",null));
|
||||
|
||||
|
@ -16,8 +16,14 @@
|
||||
|
||||
|
||||
RED.clipboard = (function() {
|
||||
// TODO: Fix issue where text outside an inner function cannot be NLS-enabled since RED._ is not available yet when that code is run
|
||||
var dialog = $('<div id="clipboard-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
|
||||
|
||||
var dialog;
|
||||
var dialogContainer;
|
||||
var exportNodesDialog;
|
||||
var importNodesDialog;
|
||||
|
||||
function setupDialogs(){
|
||||
dialog = $('<div id="clipboard-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
|
||||
.appendTo("body")
|
||||
.dialog({
|
||||
modal: true,
|
||||
@ -27,7 +33,7 @@ RED.clipboard = (function() {
|
||||
buttons: [
|
||||
{
|
||||
id: "clipboard-dialog-ok",
|
||||
text: "Ok", //RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
if (/Import/.test(dialog.dialog("option","title"))) {
|
||||
RED.view.importNodes($("#clipboard-import").val());
|
||||
@ -37,14 +43,14 @@ RED.clipboard = (function() {
|
||||
},
|
||||
{
|
||||
id: "clipboard-dialog-cancel",
|
||||
text: "Cancel", //RED._("dialog.cancel"),
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "clipboard-dialog-close",
|
||||
text: "Close", //RED._("dialog.close"),
|
||||
text: RED._("dialog.close"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
@ -59,20 +65,20 @@ RED.clipboard = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
var dialogContainer = dialog.children(".dialog-form");
|
||||
dialogContainer = dialog.children(".dialog-form");
|
||||
|
||||
var exportNodesDialog = '<div class="form-row">'+
|
||||
'<label for="node-input-export" style="display: block; width:100%;"><i class="fa fa-clipboard"></i>'+'Nodes:' /*RED._("dialog.nodes")*/+'</label>'+
|
||||
exportNodesDialog = '<div class="form-row">'+
|
||||
'<label for="node-input-export" style="display: block; width:100%;"><i class="fa fa-clipboard"></i>'+RED._("dialog.nodes")+'</label>'+
|
||||
'<textarea readonly style="resize: none; width: 100%; border-radius: 0px;font-family: monospace; font-size: 12px; background:#eee; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-export" rows="5"></textarea>'+
|
||||
'</div>'+
|
||||
'<div class="form-tips">'+
|
||||
'Select the text above and copy to the clipboard with Ctrl-C.'+
|
||||
//RED._("dialog.selectToCopy")+
|
||||
RED._("dialog.selectToCopy")+
|
||||
'</div>';
|
||||
|
||||
var importNodesDialog = '<div class="form-row">'+
|
||||
'<textarea style="resize: none; width: 100%; border-radius: 0px;font-family: monospace; font-size: 12px; background:#eee; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-import" rows="5" placeholder="'+'Paste nodes here' /*RED._("dialog.pasteNodesHere")*/+'"></textarea>'+
|
||||
importNodesDialog = '<div class="form-row">'+
|
||||
'<textarea style="resize: none; width: 100%; border-radius: 0px;font-family: monospace; font-size: 12px; background:#eee; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-import" rows="5" placeholder="'+RED._("dialog.pasteNodesHere")+'"></textarea>'+
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function validateImport() {
|
||||
var importInput = $("#clipboard-import");
|
||||
@ -132,6 +138,7 @@ RED.clipboard = (function() {
|
||||
|
||||
return {
|
||||
init: function() {
|
||||
setupDialogs();
|
||||
RED.view.on("selection-changed",function(selection) {
|
||||
if (!selection.nodes) {
|
||||
RED.menu.setDisabled("menu-item-export",true);
|
||||
|
@ -168,6 +168,7 @@ RED.editor = (function() {
|
||||
return removedLinks;
|
||||
}
|
||||
|
||||
function createDialog(){
|
||||
$( "#dialog" ).dialog({
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
@ -178,7 +179,7 @@ RED.editor = (function() {
|
||||
buttons: [
|
||||
{
|
||||
id: "node-dialog-ok",
|
||||
text: "Ok", // RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
if (editing_node) {
|
||||
var changes = {};
|
||||
@ -230,10 +231,10 @@ RED.editor = (function() {
|
||||
newValue = input.val();
|
||||
}
|
||||
if (newValue != null) {
|
||||
if (editing_node[d] != newValue) {
|
||||
if (d === "outputs" && (newValue.trim() === "" || isNaN(newValue))) {
|
||||
continue;
|
||||
}
|
||||
if (editing_node[d] != newValue) {
|
||||
if (editing_node._def.defaults[d].type) {
|
||||
if (newValue == "_ADD_") {
|
||||
newValue = "";
|
||||
@ -294,7 +295,7 @@ RED.editor = (function() {
|
||||
},
|
||||
{
|
||||
id: "node-dialog-cancel",
|
||||
text: "Cancel", // RED._("dialog.cancel"),
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
if (editing_node && editing_node._def) {
|
||||
if (editing_node._def.oneditcancel) {
|
||||
@ -346,6 +347,7 @@ RED.editor = (function() {
|
||||
editing_node = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a config-node select box for this property
|
||||
@ -740,7 +742,7 @@ RED.editor = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Cannot NLS enable until RED._ is exposed
|
||||
function createNodeConfigDialog(){
|
||||
$( "#node-config-dialog" ).dialog({
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
@ -751,7 +753,7 @@ RED.editor = (function() {
|
||||
buttons: [
|
||||
{
|
||||
id: "node-config-dialog-ok",
|
||||
text: "Ok", // RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
var configProperty = $(this).dialog('option','node-property');
|
||||
var configId = $(this).dialog('option','node-id');
|
||||
@ -811,7 +813,7 @@ RED.editor = (function() {
|
||||
},
|
||||
{
|
||||
id: "node-config-dialog-cancel",
|
||||
text: "Cancel", // RED._("dialog.cancel"),
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
var configType = $(this).dialog('option','node-type');
|
||||
var configId = $(this).dialog('option','node-id');
|
||||
@ -854,7 +856,9 @@ RED.editor = (function() {
|
||||
RED.sidebar.config.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createSubflowDialog(){
|
||||
$( "#subflow-dialog" ).dialog({
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
@ -865,7 +869,7 @@ RED.editor = (function() {
|
||||
buttons: [
|
||||
{
|
||||
id: "subflow-dialog-ok",
|
||||
text: "Ok", // RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
if (editing_node) {
|
||||
var i;
|
||||
@ -912,7 +916,7 @@ RED.editor = (function() {
|
||||
},
|
||||
{
|
||||
id: "subflow-dialog-cancel",
|
||||
text: "Cancel", // RED._("dialog.cancel")
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
editing_node = null;
|
||||
@ -937,6 +941,7 @@ RED.editor = (function() {
|
||||
}
|
||||
});
|
||||
$("#subflow-dialog form" ).submit(function(e) { e.preventDefault();});
|
||||
}
|
||||
|
||||
|
||||
function showEditSubflowDialog(subflow) {
|
||||
@ -959,6 +964,11 @@ RED.editor = (function() {
|
||||
|
||||
|
||||
return {
|
||||
init: function(){
|
||||
createDialog();
|
||||
createNodeConfigDialog();
|
||||
createSubflowDialog();
|
||||
},
|
||||
edit: showEditDialog,
|
||||
editConfig: showEditConfigNodeDialog,
|
||||
editSubflow: showEditSubflowDialog,
|
||||
|
@ -78,7 +78,9 @@ RED.workspaces = (function() {
|
||||
$( "#node-dialog-rename-workspace" ).dialog("open");
|
||||
}
|
||||
|
||||
var workspace_tabs = RED.tabs.create({
|
||||
var workspace_tabs;
|
||||
function createWorkspaceTabs(){
|
||||
workspace_tabs = RED.tabs.create({
|
||||
id: "workspace-tabs",
|
||||
onchange: function(tab) {
|
||||
if (tab.type == "subflow") {
|
||||
@ -117,16 +119,17 @@ RED.workspaces = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#node-dialog-rename-workspace form" ).submit(function(e) { e.preventDefault();});
|
||||
$( "#node-dialog-rename-workspace" ).dialog({
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
title: "Rename sheet", // RED._("dialog.renameSheet"),
|
||||
title: RED._("dialog.renameSheet"),
|
||||
buttons: [
|
||||
{
|
||||
class: 'leftButton',
|
||||
text: "Delete", // RED._("dialog.delete"),
|
||||
text: RED._("dialog.delete"),
|
||||
click: function() {
|
||||
var workspace = $(this).dialog('option','workspace');
|
||||
$( this ).dialog( "close" );
|
||||
@ -134,7 +137,7 @@ RED.workspaces = (function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Ok", // RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
var workspace = $(this).dialog('option','workspace');
|
||||
var label = $( "#node-input-workspace-name" ).val();
|
||||
@ -148,7 +151,7 @@ RED.workspaces = (function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Cancel", // RED._("dialog.cancel"),
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
@ -165,10 +168,10 @@ RED.workspaces = (function() {
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
title: "Confirm delete", // RED._("dialog.confirmDelete"),
|
||||
title: RED._("dialog.confirmDelete"),
|
||||
buttons: [
|
||||
{
|
||||
text: "Ok", // RED._("dialog.ok"),
|
||||
text: RED._("dialog.ok"),
|
||||
click: function() {
|
||||
var workspace = $(this).dialog('option','workspace');
|
||||
deleteWorkspace(workspace,true);
|
||||
@ -176,7 +179,7 @@ RED.workspaces = (function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Cancel", // RED._("dialog.cancel"),
|
||||
text: RED._("dialog.cancel"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
@ -190,8 +193,10 @@ RED.workspaces = (function() {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
createWorkspaceTabs();
|
||||
$('#btn-workspace-add-tab').on("click",function(e) {addWorkspace(); e.preventDefault()});
|
||||
RED.sidebar.on("resize",workspace_tabs.resize);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user