diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 5a27356a3..f46fd03b3 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -218,39 +218,22 @@ RED.editor = (function() { var newWidth; if (existingWidthCSS !== '') { if (/%/.test(existingWidthCSS)) { - newWidth = (input.width()-20)+"%"; + newWidth = (input.width()-10)+"%"; } else { - newWidth = input.width()-80; + newWidth = input.width()-50; } } else { - newWidth = "55%"; + newWidth = "60%"; } - var select = $('').width(newWidth); + var select = $(''); + select.width(newWidth); input.replaceWith(select); updateConfigNodeSelect(property,type,node[property],prefix); - var addButton = $('').insertAfter(select); - var editButton = $('').insertAfter(select); - - editButton.click(function(e) { - if (!$(this).hasClass('disabled')) { - showEditConfigNodeDialog(property,type,select.find(":selected").val(),prefix); - } + select.after(' '); + $('#'+prefix+'-lookup-'+property).click(function(e) { + showEditConfigNodeDialog(property,type,select.find(":selected").val(),prefix); e.preventDefault(); }); - addButton.click(function(e) { - showEditConfigNodeDialog(property,type,"_ADD_",prefix); - e.preventDefault(); - }); - - select.change(function() { - var options = select.children(); - if (options.length > 1 || $(options[0]).val() !== "_ADD_") { - editButton.removeClass("disabled"); - } else { - editButton.addClass("disabled"); - } - }); - var label = ""; var configNode = RED.nodes.node(node[property]); var node_def = RED.nodes.getType(type); @@ -265,64 +248,6 @@ RED.editor = (function() { input.val(label); } - function updateConfigNodeSelect(name,type,value,prefix) { - // if prefix is null, there is no config select to update - if (prefix) { - var button = $("#"+prefix+"-edit-"+name); - if (button.length) { - if (value) { - button.text(RED._("editor.configEdit")); - } else { - button.text(RED._("editor.configAdd")); - } - $("#"+prefix+"-"+name).val(value); - } else { - - var select = $("#"+prefix+"-"+name); - var node_def = RED.nodes.getType(type); - select.children().remove(); - - var activeWorkspace = RED.nodes.workspace(RED.workspaces.active()); - if (!activeWorkspace) { - activeWorkspace = RED.nodes.subflow(RED.workspaces.active()); - } - - var configNodes = []; - - RED.nodes.eachConfig(function(config) { - if (config.type == type && (!config.z || config.z === activeWorkspace.id)) { - var label = ""; - if (typeof node_def.label == "function") { - label = node_def.label.call(config); - } else { - label = node_def.label; - } - configNodes.push({id:config.id,label:label}); - } - }); - - configNodes.sort(function(A,B) { - if (A.label < B.label) { - return -1; - } else if (A.label > B.label) { - return 1; - } - return 0; - }); - - configNodes.forEach(function(cn) { - select.append(''); - }); - - if (configNodes.length === 0) { - select.append(''); - } - - window.setTimeout(function() { select.change();},50); - } - } - } - /** * Create a config-node button for this property * @param node - the node being edited @@ -1125,6 +1050,62 @@ RED.editor = (function() { RED.tray.show(trayOptions); } + + function updateConfigNodeSelect(name,type,value,prefix) { + // if prefix is null, there is no config select to update + if (prefix) { + var button = $("#"+prefix+"-edit-"+name); + if (button.length) { + if (value) { + button.text(RED._("editor.configEdit")); + } else { + button.text(RED._("editor.configAdd")); + } + $("#"+prefix+"-"+name).val(value); + } else { + + var select = $("#"+prefix+"-"+name); + var node_def = RED.nodes.getType(type); + select.children().remove(); + + var activeWorkspace = RED.nodes.workspace(RED.workspaces.active()); + if (!activeWorkspace) { + activeWorkspace = RED.nodes.subflow(RED.workspaces.active()); + } + + var configNodes = []; + + RED.nodes.eachConfig(function(config) { + if (config.type == type && (!config.z || config.z === activeWorkspace.id)) { + var label = ""; + if (typeof node_def.label == "function") { + label = node_def.label.call(config); + } else { + label = node_def.label; + } + configNodes.push({id:config.id,label:label}); + } + }); + + configNodes.sort(function(A,B) { + if (A.label < B.label) { + return -1; + } else if (A.label > B.label) { + return 1; + } + return 0; + }); + + configNodes.forEach(function(cn) { + select.append(''); + }); + + select.append(''); + window.setTimeout(function() { select.change();},50); + } + } + } + function showEditSubflowDialog(subflow) { var editing_node = subflow; if (editStack.length === 0) {