Fix export problem when the windows is closed. Some code was moved to the iframeDialog.

This commit is contained in:
Paulo Gustavo Veiga 2012-08-31 20:51:55 -03:00
parent 6dce37d794
commit 052494a6a5
3 changed files with 27 additions and 16 deletions

View File

@ -16,14 +16,18 @@
$('submitBtn').addEvent('click', function () { $('submitBtn').addEvent('click', function () {
var iframeWindow = $('dialogContentIframe').contentWindow; var iframeWindow = $('dialogContentIframe').contentWindow;
if (iframeWindow && (typeof iframeWindow.submitDialogForm == 'function')) { if (iframeWindow && (typeof iframeWindow.submitDialogForm == 'function')) {
var delay = iframeWindow.submitDialogForm(); var context = iframeWindow.submitDialogForm(true);
if (MooDialog.Request.active) { if (context) {
if (!delay) { // This is a hack for the export function. If this is not done, the dialog is closed and the export fails.
var iframeForm = $('iframeExportForm');
iframeForm.setAttribute('method', context.method);
iframeForm.setAttribute('action', context.action);
$('svgXml').setAttribute('value', window.document.getElementById('workspaceContainer').innerHTML);
$('download').setAttribute('value', context.formatType);
iframeForm.submit();
}
MooDialog.Request.active.close(); MooDialog.Request.active.close();
} else {
MooDialog.Request.active.close.delay(3000, MooDialog.Request.active);
}
}
} }
}); });
@ -33,3 +37,8 @@
} }
}); });
</script> </script>
<form method="GET" class="form-horizontal" action="service/maps/${mindmap.id}"
enctype="application/x-www-form-urlencoded" id="iframeExportForm">
<input name="svgXml" id="svgXml" value="" type="hidden"/>
<input name="download" id="download" type="hidden" value="mm"/>
</form>

View File

@ -69,7 +69,7 @@
$('#pdf,#svg,#img').parent().hide(); $('#pdf,#svg,#img').parent().hide();
} }
function submitDialogForm() { function submitDialogForm(differ) {
// If the map is opened, use the latest model ... // If the map is opened, use the latest model ...
var formatType = $('#dialogMainForm input:checked').attr('value'); var formatType = $('#dialogMainForm input:checked').attr('value');
var form = $('#dialogMainForm'); var form = $('#dialogMainForm');
@ -88,17 +88,19 @@
form.attr('action', 'service/transform.' + formatType); form.attr('action', 'service/transform.' + formatType);
// Load page SVG ... // Load page SVG ...
var svg = window.parent.document.getElementById('workspaceContainer').innerHTML; var svgXml = window.parent.document.getElementById('workspaceContainer').innerHTML;
$('#svgXml').attr('value', svg); $('#svgXml').attr('value', svgXml);
} }
$('#dialogMainForm input[name=download]').attr('value', formatType); $('#dialogMainForm input[name=download]').attr('value', formatType);
if (!differ) {
form.submit(); form.submit();
}
// Close dialog ... // Close dialog ...
$('#export-dialog-modal').modal('hide'); $('#export-dialog-modal').modal('hide');
return true; return {"action":form.attr('action'), "method":form.attr('method'), formatType:formatType};
} }
</script> </script>

View File

@ -6,7 +6,7 @@
<html> <html>
<head> <head>
<base href="${baseURL}/"> <base href="${baseURL}/">
<title><spring:message code="SITE.TITLE"/></title> <title><spring:message code="SITE.TITLE"/> - <spring:message code="MY_WISEMAPS"/></title>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1"> <meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]--> <![endif]-->