Defer resizing tray components until they have finished building

This commit is contained in:
Nick O'Leary 2017-02-16 21:41:20 +00:00
parent 89769fb0e5
commit e2a9be9cec
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 118 additions and 125 deletions

View File

@ -430,7 +430,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) {
@ -474,6 +474,9 @@ RED.editor = (function() {
}
}
validateNodeEditor(node,prefix);
if (done) {
done();
}
}
if (definition.credentials) {
@ -791,7 +794,7 @@ RED.editor = (function() {
}
}
},
open: function(tray) {
open: function(tray,done) {
if (editing_node) {
RED.sidebar.info.refresh(editing_node);
}
@ -802,8 +805,11 @@ RED.editor = (function() {
ns = node._def.set.id;
}
var dialogForm = buildEditForm(tray,"dialog-form",type,ns);
prepareEditDialog(node,node._def,"node-input");
prepareEditDialog(node,node._def,"node-input", function() {
dialogForm.i18n();
done();
});
},
close: function() {
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
@ -888,11 +894,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");
@ -903,7 +909,7 @@ RED.editor = (function() {
var dialogForm = buildEditForm(tray,"node-config-dialog-edit-form",type,ns);
prepareEditDialog(editing_config_node,node_def,"node-config-input");
prepareEditDialog(editing_config_node,node_def,"node-config-input", function() {
if (editing_config_node._def.exclusive) {
$("#node-config-dialog-scope").hide();
} else {
@ -955,6 +961,8 @@ RED.editor = (function() {
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();

View File

@ -104,10 +104,7 @@ RED.tray = (function() {
}
});
if (options.open) {
options.open(el);
}
function finishBuild() {
$("#header-shade").show();
$("#editor-shade").show();
$("#palette-shade").show();
@ -160,29 +157,17 @@ RED.tray = (function() {
},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.open) {
if (options.open.length === 1) {
options.open(el);
finishBuild();
} else {
options.open(el,finishBuild);
}
} else {
finishBuild();
}
}
function handleWindowResize() {