mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Resync with master
This commit is contained in:
@@ -164,10 +164,12 @@ RED.clipboard = (function() {
|
||||
dialogContainer.empty();
|
||||
dialogContainer.append($(exportNodesDialog));
|
||||
dialogContainer.i18n();
|
||||
var format = RED.settings.flowFilePretty ? "export-format-full" : "export-format-mini";
|
||||
|
||||
$("#export-format-group > a").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
|
||||
$("#clipboard-export").focus();
|
||||
return;
|
||||
}
|
||||
$(this).parent().children().removeClass('selected');
|
||||
@@ -177,18 +179,21 @@ RED.clipboard = (function() {
|
||||
if (flow.length > 0) {
|
||||
var nodes = JSON.parse(flow);
|
||||
|
||||
var format = $(this).attr('id');
|
||||
format = $(this).attr('id');
|
||||
if (format === 'export-format-full') {
|
||||
flow = JSON.stringify(nodes,null,4);
|
||||
} else {
|
||||
flow = JSON.stringify(nodes);
|
||||
}
|
||||
$("#clipboard-export").val(flow);
|
||||
$("#clipboard-export").focus();
|
||||
}
|
||||
});
|
||||
|
||||
$("#export-range-group > a").click(function(evt) {
|
||||
evt.preventDefault();
|
||||
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
|
||||
$("#clipboard-export").focus();
|
||||
return;
|
||||
}
|
||||
$(this).parent().children().removeClass('selected');
|
||||
@@ -209,7 +214,7 @@ RED.clipboard = (function() {
|
||||
nodes = RED.nodes.createCompleteNodeSet(false);
|
||||
}
|
||||
if (nodes !== null) {
|
||||
if (RED.settings.flowFilePretty) {
|
||||
if (format === "export-format-full") {
|
||||
flow = JSON.stringify(nodes,null,4);
|
||||
} else {
|
||||
flow = JSON.stringify(nodes);
|
||||
@@ -221,6 +226,7 @@ RED.clipboard = (function() {
|
||||
$("#export-copy").addClass('disabled');
|
||||
}
|
||||
$("#clipboard-export").val(flow);
|
||||
$("#clipboard-export").focus();
|
||||
})
|
||||
|
||||
$("#clipboard-dialog-ok").hide();
|
||||
@@ -234,7 +240,7 @@ RED.clipboard = (function() {
|
||||
$("#export-range-selected").addClass('disabled').removeClass('selected');
|
||||
$("#export-range-flow").click();
|
||||
}
|
||||
if (RED.settings.flowFilePretty) {
|
||||
if (format === "export-format-full") {
|
||||
$("#export-format-full").click();
|
||||
} else {
|
||||
$("#export-format-mini").click();
|
||||
|
@@ -421,7 +421,7 @@ RED.editor = (function() {
|
||||
* @param definition - the node definition
|
||||
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
|
||||
*/
|
||||
function prepareEditDialog(node,definition,prefix) {
|
||||
function prepareEditDialog(node,definition,prefix,done) {
|
||||
for (var d in definition.defaults) {
|
||||
if (definition.defaults.hasOwnProperty(d)) {
|
||||
if (definition.defaults[d].type) {
|
||||
@@ -465,6 +465,9 @@ RED.editor = (function() {
|
||||
}
|
||||
}
|
||||
validateNodeEditor(node,prefix);
|
||||
if (done) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
if (definition.credentials) {
|
||||
@@ -945,7 +948,7 @@ RED.editor = (function() {
|
||||
}
|
||||
}
|
||||
},
|
||||
open: function(tray) {
|
||||
open: function(tray, done) {
|
||||
var trayFooter = tray.find(".editor-tray-footer");
|
||||
var trayBody = tray.find('.editor-tray-body');
|
||||
trayBody.parent().css('overflow','hidden');
|
||||
@@ -977,8 +980,10 @@ RED.editor = (function() {
|
||||
buildEditForm(nodeProperties.content,"dialog-form",type,ns);
|
||||
buildLabelForm(portLabels.content,node);
|
||||
|
||||
prepareEditDialog(node,node._def,"node-input");
|
||||
trayBody.i18n();
|
||||
prepareEditDialog(node,node._def,"node-input", function() {
|
||||
trayBody.i18n();
|
||||
done();
|
||||
});
|
||||
},
|
||||
close: function() {
|
||||
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
||||
@@ -1063,11 +1068,11 @@ RED.editor = (function() {
|
||||
try {
|
||||
editing_config_node._def.oneditresize.call(editing_config_node,{width:form.width(),height:form.height()});
|
||||
} catch(err) {
|
||||
console.log("oneditresize",editing_node.id,editing_node.type,err.toString());
|
||||
console.log("oneditresize",editing_config_node.id,editing_config_node.type,err.toString());
|
||||
}
|
||||
}
|
||||
},
|
||||
open: function(tray) {
|
||||
open: function(tray, done) {
|
||||
var trayHeader = tray.find(".editor-tray-header");
|
||||
var trayFooter = tray.find(".editor-tray-footer");
|
||||
|
||||
@@ -1078,58 +1083,60 @@ RED.editor = (function() {
|
||||
|
||||
var dialogForm = buildEditForm(tray.find('.editor-tray-body'),"node-config-dialog-edit-form",type,ns);
|
||||
|
||||
prepareEditDialog(editing_config_node,node_def,"node-config-input");
|
||||
if (editing_config_node._def.exclusive) {
|
||||
$("#node-config-dialog-scope").hide();
|
||||
} else {
|
||||
$("#node-config-dialog-scope").show();
|
||||
}
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
prepareEditDialog(editing_config_node,node_def,"node-config-input", function() {
|
||||
if (editing_config_node._def.exclusive) {
|
||||
$("#node-config-dialog-scope").hide();
|
||||
} else {
|
||||
$("#node-config-dialog-scope").show();
|
||||
}
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
|
||||
var nodeUserFlows = {};
|
||||
editing_config_node.users.forEach(function(n) {
|
||||
nodeUserFlows[n.z] = true;
|
||||
});
|
||||
var flowCount = Object.keys(nodeUserFlows).length;
|
||||
var tabSelect = $("#node-config-dialog-scope").empty();
|
||||
tabSelect.off("change");
|
||||
tabSelect.append('<option value=""'+(!editing_config_node.z?" selected":"")+' data-i18n="sidebar.config.global"></option>');
|
||||
tabSelect.append('<option disabled data-i18n="sidebar.config.flows"></option>');
|
||||
RED.nodes.eachWorkspace(function(ws) {
|
||||
var workspaceLabel = ws.label;
|
||||
if (nodeUserFlows[ws.id]) {
|
||||
workspaceLabel = "* "+workspaceLabel;
|
||||
}
|
||||
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
||||
});
|
||||
tabSelect.append('<option disabled data-i18n="sidebar.config.subflows"></option>');
|
||||
RED.nodes.eachSubflow(function(ws) {
|
||||
var workspaceLabel = ws.name;
|
||||
if (nodeUserFlows[ws.id]) {
|
||||
workspaceLabel = "* "+workspaceLabel;
|
||||
}
|
||||
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
||||
});
|
||||
if (flowCount > 0) {
|
||||
tabSelect.on('change',function() {
|
||||
var newScope = $(this).val();
|
||||
if (newScope === '') {
|
||||
// global scope - everyone can use it
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
} else if (!nodeUserFlows[newScope] || flowCount > 1) {
|
||||
// a user will loose access to it
|
||||
$("#node-config-dialog-scope-warning").show();
|
||||
} else {
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
}
|
||||
var nodeUserFlows = {};
|
||||
editing_config_node.users.forEach(function(n) {
|
||||
nodeUserFlows[n.z] = true;
|
||||
});
|
||||
}
|
||||
tabSelect.i18n();
|
||||
var flowCount = Object.keys(nodeUserFlows).length;
|
||||
var tabSelect = $("#node-config-dialog-scope").empty();
|
||||
tabSelect.off("change");
|
||||
tabSelect.append('<option value=""'+(!editing_config_node.z?" selected":"")+' data-i18n="sidebar.config.global"></option>');
|
||||
tabSelect.append('<option disabled data-i18n="sidebar.config.flows"></option>');
|
||||
RED.nodes.eachWorkspace(function(ws) {
|
||||
var workspaceLabel = ws.label;
|
||||
if (nodeUserFlows[ws.id]) {
|
||||
workspaceLabel = "* "+workspaceLabel;
|
||||
}
|
||||
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
||||
});
|
||||
tabSelect.append('<option disabled data-i18n="sidebar.config.subflows"></option>');
|
||||
RED.nodes.eachSubflow(function(ws) {
|
||||
var workspaceLabel = ws.name;
|
||||
if (nodeUserFlows[ws.id]) {
|
||||
workspaceLabel = "* "+workspaceLabel;
|
||||
}
|
||||
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
||||
});
|
||||
if (flowCount > 0) {
|
||||
tabSelect.on('change',function() {
|
||||
var newScope = $(this).val();
|
||||
if (newScope === '') {
|
||||
// global scope - everyone can use it
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
} else if (!nodeUserFlows[newScope] || flowCount > 1) {
|
||||
// a user will loose access to it
|
||||
$("#node-config-dialog-scope-warning").show();
|
||||
} else {
|
||||
$("#node-config-dialog-scope-warning").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
tabSelect.i18n();
|
||||
|
||||
dialogForm.i18n();
|
||||
if (node_def.hasUsers !== false) {
|
||||
$("#node-config-dialog-user-count").find("span").html(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
|
||||
}
|
||||
dialogForm.i18n();
|
||||
if (node_def.hasUsers !== false) {
|
||||
$("#node-config-dialog-user-count").find("span").html(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
|
||||
}
|
||||
done();
|
||||
});
|
||||
},
|
||||
close: function() {
|
||||
RED.workspaces.refresh();
|
||||
|
@@ -66,6 +66,15 @@ RED.sidebar.info = (function() {
|
||||
return value;
|
||||
}
|
||||
|
||||
function addTargetToExternalLinks(el) {
|
||||
$(el).find("a").each(function(el) {
|
||||
var href = $(this).attr('href');
|
||||
if (/^https?:/.test(href)) {
|
||||
$(this).attr('target','_blank');
|
||||
}
|
||||
});
|
||||
return el;
|
||||
}
|
||||
function refresh(node) {
|
||||
tips.stop();
|
||||
$(content).empty();
|
||||
@@ -117,14 +126,14 @@ RED.sidebar.info = (function() {
|
||||
$("<hr/>").appendTo(content);
|
||||
if (!subflowNode && node.type != "comment") {
|
||||
var helpText = $("script[data-help-name$='"+node.type+"']").html()||"";
|
||||
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>').appendTo(content);
|
||||
addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>').appendTo(content));
|
||||
}
|
||||
if (subflowNode) {
|
||||
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>').appendTo(content);
|
||||
addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>').appendTo(content));
|
||||
} else if (node._def && node._def.info) {
|
||||
var info = node._def.info;
|
||||
var textInfo = (typeof info === "function" ? info.call(node) : info);
|
||||
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(textInfo)+'">'+marked(textInfo)+'</span></div>').appendTo(content);
|
||||
addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(textInfo)+'">'+marked(textInfo)+'</span></div>').appendTo(content));
|
||||
//$('<div class="node-help">'+(typeof info === "function" ? info.call(node) : info)+'</div>';
|
||||
}
|
||||
|
||||
|
@@ -104,85 +104,70 @@ RED.tray = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
if (options.open) {
|
||||
options.open(el);
|
||||
}
|
||||
function finishBuild() {
|
||||
$("#header-shade").show();
|
||||
$("#editor-shade").show();
|
||||
$("#palette-shade").show();
|
||||
$(".sidebar-shade").show();
|
||||
|
||||
$("#header-shade").show();
|
||||
$("#editor-shade").show();
|
||||
$("#palette-shade").show();
|
||||
$(".sidebar-shade").show();
|
||||
tray.preferredWidth = Math.max(el.width(),500);
|
||||
body.css({"minWidth":tray.preferredWidth-40});
|
||||
|
||||
tray.preferredWidth = Math.max(el.width(),500);
|
||||
body.css({"minWidth":tray.preferredWidth-40});
|
||||
|
||||
if (options.width) {
|
||||
if (options.width > $("#editor-stack").position().left-8) {
|
||||
options.width = $("#editor-stack").position().left-8;
|
||||
if (options.width) {
|
||||
if (options.width > $("#editor-stack").position().left-8) {
|
||||
options.width = $("#editor-stack").position().left-8;
|
||||
}
|
||||
el.width(options.width);
|
||||
} else {
|
||||
el.width(tray.preferredWidth);
|
||||
}
|
||||
el.width(options.width);
|
||||
} else {
|
||||
el.width(tray.preferredWidth);
|
||||
}
|
||||
|
||||
tray.width = el.width();
|
||||
if (tray.width > $("#editor-stack").position().left-8) {
|
||||
tray.width = Math.max(0/*tray.preferredWidth*/,$("#editor-stack").position().left-8);
|
||||
el.width(tray.width);
|
||||
}
|
||||
tray.width = el.width();
|
||||
if (tray.width > $("#editor-stack").position().left-8) {
|
||||
tray.width = Math.max(0/*tray.preferredWidth*/,$("#editor-stack").position().left-8);
|
||||
el.width(tray.width);
|
||||
}
|
||||
|
||||
// tray.body.parent().width(Math.min($("#editor-stack").position().left-8,tray.width));
|
||||
// tray.body.parent().width(Math.min($("#editor-stack").position().left-8,tray.width));
|
||||
|
||||
el.css({
|
||||
right: -(el.width()+10)+"px",
|
||||
transition: "right 0.25s ease"
|
||||
});
|
||||
$("#workspace").scrollLeft(0);
|
||||
handleWindowResize();
|
||||
openingTray = true;
|
||||
setTimeout(function() {
|
||||
el.css({
|
||||
right: -(el.width()+10)+"px",
|
||||
transition: "right 0.25s ease"
|
||||
});
|
||||
$("#workspace").scrollLeft(0);
|
||||
handleWindowResize();
|
||||
openingTray = true;
|
||||
setTimeout(function() {
|
||||
if (!options.width) {
|
||||
el.width(Math.min(tray.preferredWidth,$("#editor-stack").position().left-8));
|
||||
}
|
||||
if (options.resize) {
|
||||
options.resize({width:el.width()});
|
||||
}
|
||||
if (options.show) {
|
||||
options.show();
|
||||
}
|
||||
setTimeout(function() {
|
||||
// Delay resetting the flag, so we don't close prematurely
|
||||
openingTray = false;
|
||||
},200);
|
||||
body.find(":focusable:first").focus();
|
||||
|
||||
},150);
|
||||
el.css({right:0});
|
||||
},0);
|
||||
|
||||
// growButton.click(function(e) {
|
||||
// e.preventDefault();
|
||||
// tray.lastWidth = tray.width;
|
||||
// tray.width = $("#editor-stack").position().left-8;
|
||||
// el.width(tray.width);
|
||||
// if (options.resize) {
|
||||
// options.resize({width:tray.width});
|
||||
// }
|
||||
// });
|
||||
// shrinkButton.click(function(e) {
|
||||
// e.preventDefault();
|
||||
// if (tray.lastWidth && tray.width > tray.lastWidth) {
|
||||
// tray.width = tray.lastWidth;
|
||||
// } else if (tray.width > tray.preferredWidth) {
|
||||
// tray.width = tray.preferredWidth;
|
||||
// }
|
||||
// el.width(tray.width);
|
||||
// if (options.resize) {
|
||||
// options.resize({width:tray.width});
|
||||
// }
|
||||
// });
|
||||
if (!options.width) {
|
||||
el.width(Math.min(tray.preferredWidth,$("#editor-stack").position().left-8));
|
||||
}
|
||||
if (options.resize) {
|
||||
options.resize({width:el.width()});
|
||||
}
|
||||
if (options.show) {
|
||||
options.show();
|
||||
}
|
||||
setTimeout(function() {
|
||||
// Delay resetting the flag, so we don't close prematurely
|
||||
openingTray = false;
|
||||
},200);
|
||||
body.find(":focusable:first").focus();
|
||||
|
||||
},150);
|
||||
el.css({right:0});
|
||||
},0);
|
||||
}
|
||||
if (options.open) {
|
||||
if (options.open.length === 1) {
|
||||
options.open(el);
|
||||
finishBuild();
|
||||
} else {
|
||||
options.open(el,finishBuild);
|
||||
}
|
||||
} else {
|
||||
finishBuild();
|
||||
}
|
||||
}
|
||||
|
||||
function handleWindowResize() {
|
||||
|
@@ -1311,7 +1311,7 @@ RED.view = (function() {
|
||||
sp.className = className;
|
||||
sp.style.position = "absolute";
|
||||
sp.style.top = "-1000px";
|
||||
sp.innerHTML = (str||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
sp.textContent = (str||"");
|
||||
document.body.appendChild(sp);
|
||||
var w = sp.offsetWidth;
|
||||
var h = sp.offsetHeight;
|
||||
@@ -2323,10 +2323,10 @@ RED.view = (function() {
|
||||
d.x2 = d.target.x-d.target.w/2;
|
||||
d.y2 = d.target.y;
|
||||
|
||||
return "M "+(d.source.x+d.source.w/2)+" "+(d.source.y+y)+
|
||||
" C "+(d.source.x+d.source.w/2+scale*node_width)+" "+(d.source.y+y+scaleY*node_height)+" "+
|
||||
(d.target.x-d.target.w/2-scale*node_width)+" "+(d.target.y-scaleY*node_height)+" "+
|
||||
(d.target.x-d.target.w/2)+" "+d.target.y;
|
||||
return "M "+d.x1+" "+d.y1+
|
||||
" C "+(d.x1+scale*node_width)+" "+(d.y1+scaleY*node_height)+" "+
|
||||
(d.x2-scale*node_width)+" "+(d.y2-scaleY*node_height)+" "+
|
||||
d.x2+" "+d.y2;
|
||||
});
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user