From 6777f2484576bb4bb9a31255d990dbb24e078664 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 29 Jun 2015 16:12:18 +0100 Subject: [PATCH] Ensure library export dialog is i18n'd --- editor/js/nodes.js | 84 +++++++++++++++++++------------------- editor/js/ui/editor.js | 2 +- editor/js/ui/library.js | 51 ++++++++++++----------- editor/templates/index.mst | 8 ++-- 4 files changed, 73 insertions(+), 72 deletions(-) diff --git a/editor/js/nodes.js b/editor/js/nodes.js index 8cb1c0818..2333ed32d 100644 --- a/editor/js/nodes.js +++ b/editor/js/nodes.js @@ -22,20 +22,20 @@ RED.nodes = (function() { var defaultWorkspace; var workspaces = {}; var subflows = {}; - + var dirty = false; - + function setDirty(d) { dirty = d; eventHandler.emit("change",{dirty:dirty}); } - + var registry = (function() { var nodeList = []; var nodeSets = {}; var typeToId = {}; var nodeDefinitions = {}; - + var exports = { getNodeList: function() { return nodeList; @@ -109,7 +109,7 @@ RED.nodes = (function() { if (def.category != "subflows") { def.set = nodeSets[typeToId[nt]]; nodeSets[typeToId[nt]].added = true; - + var ns; if (def.set.module === "node-red") { ns = "node-red"; @@ -144,7 +144,7 @@ RED.nodes = (function() { }; return exports; })(); - + function getID() { return (1+Math.random()*4294967295).toString(16); } @@ -284,7 +284,7 @@ RED.nodes = (function() { var subflowNames = Object.keys(subflows).map(function(sfid) { return subflows[sfid].name; }); - + subflowNames.sort(); var copyNumber = 1; var subflowName = sf.name; @@ -296,7 +296,7 @@ RED.nodes = (function() { }); sf.name = subflowName; } - + subflows[sf.id] = sf; RED.nodes.registerType("subflow:"+sf.id, { defaults:{name:{value:""}}, @@ -307,10 +307,13 @@ RED.nodes = (function() { color: "#da9", label: function() { return this.name||RED.nodes.subflow(sf.id).name }, labelStyle: function() { return this.name?"node_label_italic":""; }, - paletteLabel: function() { return RED.nodes.subflow(sf.id).name } + paletteLabel: function() { return RED.nodes.subflow(sf.id).name }, + set:{ + module: "node-red" + } }); - - + + } function getSubflow(id) { return subflows[id]; @@ -319,7 +322,7 @@ RED.nodes = (function() { delete subflows[sf.id]; registry.removeNodeType("subflow:"+sf.id); } - + function subflowContains(sfid,nodeid) { for (var i=0;i/ '+dirName+''); - $("a",bcli).click(function(e) { + $("a",bcli).click(function(e) { $(this).parent().nextAll().remove(); $.getJSON("library/"+options.url+root+dirName,function(data) { $("#node-select-library").children().first().replaceWith(buildFileList(root+dirName+"/",data)); @@ -141,7 +141,7 @@ RED.library = (function() { } return ul; } - + $('#node-input-name').addClass('input-append-left').css("width","65%").after( '
'+ ''+ @@ -150,15 +150,15 @@ RED.library = (function() { '
  • '+RED._("library.saveToLibrary")+'
  • '+ '
    ' ); - - - + + + $('#node-input-'+options.type+'-menu-open-library').click(function(e) { $("#node-select-library").children().remove(); var bc = $("#node-dialog-library-breadcrumbs"); bc.children().first().nextAll().remove(); libraryEditor.setValue('',-1); - + $.getJSON("library/"+options.url,function(data) { $("#node-select-library").append(buildFileList("/",data)); $("#node-dialog-library-breadcrumbs a").click(function(e) { @@ -168,10 +168,10 @@ RED.library = (function() { }); $( "#node-dialog-library-lookup" ).dialog( "open" ); }); - + e.preventDefault(); }); - + $('#node-input-'+options.type+'-menu-save-library').click(function(e) { //var found = false; var name = $("#node-input-name").val().replace(/(^\s*)|(\s*$)/g,""); @@ -217,7 +217,7 @@ RED.library = (function() { $( "#node-dialog-library-save" ).dialog( "open" ); e.preventDefault(); }); - + libraryEditor = ace.edit('node-select-library-text'); libraryEditor.setTheme("ace/theme/tomorrow"); if (options.mode) { @@ -230,7 +230,7 @@ RED.library = (function() { }); libraryEditor.renderer.$cursorLayer.element.style.opacity=0; libraryEditor.$blockScrolling = Infinity; - + $( "#node-dialog-library-lookup" ).dialog({ title: RED._("library.typeLibrary", {type:options.type}), modal: true, @@ -270,7 +270,7 @@ RED.library = (function() { $(".form-row:last-child",form).children().height(form.height()-60); } }); - + function saveToLibrary(overwrite) { var name = $("#node-input-name").val().replace(/(^\s*)|(\s*$)/g,""); if (name === "") { @@ -319,7 +319,7 @@ RED.library = (function() { data[field] = $("#node-input-"+field).val(); } } - + data.text = options.editor.getValue(); $.ajax({ url:"library/"+options.url+'/'+fullpath, @@ -378,15 +378,16 @@ RED.library = (function() { }); } - + function exportFlow() { //TODO: don't rely on the main dialog var nns = RED.nodes.createExportableNodeSet(RED.view.selection().nodes); $("#dialog-form").html($("script[data-template-name='export-library-dialog']").html()); $("#node-input-filename").attr('nodes',JSON.stringify(nns)); - $( "#dialog" ).dialog("option","title",RED._("library.exportToLibrary")).dialog( "open" ); + $("#dialog").i18n(); + $("#dialog").dialog("option","title",RED._("library.exportToLibrary")).dialog( "open" ); } - + return { init: function() { RED.view.on("selection-changed",function(selection) { @@ -400,16 +401,14 @@ RED.library = (function() { RED.menu.setDisabled("menu-item-export-library",false); } }); - - if (RED.settings.theme("menu.menu-item-import-library") !== false) { + + if (RED.settings.theme("menu.menu-item-import-library") !== false) { loadFlowLibrary(); } }, create: createUI, loadFlowLibrary: loadFlowLibrary, - + export: exportFlow } })(); - - diff --git a/editor/templates/index.mst b/editor/templates/index.mst index 006d0df7b..4e9a34531 100644 --- a/editor/templates/index.mst +++ b/editor/templates/index.mst @@ -159,15 +159,15 @@