From 68bb8252af0c72c642c3ae35c06c465be7a05c5d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 May 2015 15:28:35 +0100 Subject: [PATCH] Ensure i18n func available to new config nodes --- editor/js/ui/editor.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 8d254bf47..c495871d5 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -602,8 +602,16 @@ RED.editor = (function() { function showEditConfigNodeDialog(name,type,id) { var adding = (id == "_ADD_"); var node_def = RED.nodes.getType(type); - var configNode = RED.nodes.node(id); + + var ns; + if (node_def.set.module === "node-red") { + ns = "node-red"; + } else { + ns = node_def.set.id; + } + + if (configNode == null) { configNode = { id: (1+Math.random()*4294967295).toString(16), @@ -615,16 +623,19 @@ RED.editor = (function() { configNode[d] = node_def.defaults[d].value; } } + configNode["_"] = function() { + var args = Array.prototype.slice.call(arguments, 0); + if (args[0].indexOf(":") === -1) { + args[0] = ns+":"+args[0]; + } + return RED._.apply(null,args); + } + + } $("#dialog-config-form").html($("script[data-template-name='"+type+"']").html()); - var ns; - if (node_def.set.module === "node-red") { - ns = "node-red"; - } else { - ns = node_def.set.id; - } $("#dialog-config-form").find('[data-i18n]').each(function() { var current = $(this).attr("data-i18n"); if (current.indexOf(":") === -1) {