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 definition - the node definition
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input) * @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) { for (var d in definition.defaults) {
if (definition.defaults.hasOwnProperty(d)) { if (definition.defaults.hasOwnProperty(d)) {
if (definition.defaults[d].type) { if (definition.defaults[d].type) {
@ -474,6 +474,9 @@ RED.editor = (function() {
} }
} }
validateNodeEditor(node,prefix); validateNodeEditor(node,prefix);
if (done) {
done();
}
} }
if (definition.credentials) { if (definition.credentials) {
@ -791,7 +794,7 @@ RED.editor = (function() {
} }
} }
}, },
open: function(tray) { open: function(tray,done) {
if (editing_node) { if (editing_node) {
RED.sidebar.info.refresh(editing_node); RED.sidebar.info.refresh(editing_node);
} }
@ -802,8 +805,11 @@ RED.editor = (function() {
ns = node._def.set.id; ns = node._def.set.id;
} }
var dialogForm = buildEditForm(tray,"dialog-form",type,ns); var dialogForm = buildEditForm(tray,"dialog-form",type,ns);
prepareEditDialog(node,node._def,"node-input"); prepareEditDialog(node,node._def,"node-input", function() {
dialogForm.i18n(); dialogForm.i18n();
done();
});
}, },
close: function() { close: function() {
if (RED.view.state() != RED.state.IMPORT_DRAGGING) { if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
@ -888,11 +894,11 @@ RED.editor = (function() {
try { try {
editing_config_node._def.oneditresize.call(editing_config_node,{width:form.width(),height:form.height()}); editing_config_node._def.oneditresize.call(editing_config_node,{width:form.width(),height:form.height()});
} catch(err) { } 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 trayHeader = tray.find(".editor-tray-header");
var trayFooter = tray.find(".editor-tray-footer"); 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); 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) { if (editing_config_node._def.exclusive) {
$("#node-config-dialog-scope").hide(); $("#node-config-dialog-scope").hide();
} else { } else {
@ -955,6 +961,8 @@ RED.editor = (function() {
if (node_def.hasUsers !== false) { if (node_def.hasUsers !== false) {
$("#node-config-dialog-user-count").find("span").html(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show(); $("#node-config-dialog-user-count").find("span").html(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
} }
done();
});
}, },
close: function() { close: function() {
RED.workspaces.refresh(); RED.workspaces.refresh();

View File

@ -104,10 +104,7 @@ RED.tray = (function() {
} }
}); });
if (options.open) { function finishBuild() {
options.open(el);
}
$("#header-shade").show(); $("#header-shade").show();
$("#editor-shade").show(); $("#editor-shade").show();
$("#palette-shade").show(); $("#palette-shade").show();
@ -160,29 +157,17 @@ RED.tray = (function() {
},150); },150);
el.css({right:0}); el.css({right:0});
},0); },0);
}
// growButton.click(function(e) { if (options.open) {
// e.preventDefault(); if (options.open.length === 1) {
// tray.lastWidth = tray.width; options.open(el);
// tray.width = $("#editor-stack").position().left-8; finishBuild();
// el.width(tray.width); } else {
// if (options.resize) { options.open(el,finishBuild);
// options.resize({width:tray.width}); }
// } } else {
// }); finishBuild();
// 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});
// }
// });
} }
function handleWindowResize() { function handleWindowResize() {