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 () {
var iframeWindow = $('dialogContentIframe').contentWindow;
if (iframeWindow && (typeof iframeWindow.submitDialogForm == 'function')) {
var delay = iframeWindow.submitDialogForm();
if (MooDialog.Request.active) {
if (!delay) {
var context = iframeWindow.submitDialogForm(true);
if (context) {
// 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();
} else {
MooDialog.Request.active.close.delay(3000, MooDialog.Request.active);
}
}
}
});
@ -33,3 +37,8 @@
}
});
</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

@ -58,18 +58,18 @@
// No way to obtain map svg. Hide panels..
if (window.location.pathname.indexOf('exportf') != -1) {
$('#exportInfo').hide();
$('#freemind,#pdf,#svg').click('click', function(event) {
$('#freemind,#pdf,#svg').click('click', function (event) {
$('#imgFormat').hide();
});
$('#img').click('click', function(event) {
$('#img').click('click', function (event) {
$('#imgFormat').show();
});
} else {
$('#pdf,#svg,#img').parent().hide();
}
function submitDialogForm() {
function submitDialogForm(differ) {
// If the map is opened, use the latest model ...
var formatType = $('#dialogMainForm input:checked').attr('value');
var form = $('#dialogMainForm');
@ -88,17 +88,19 @@
form.attr('action', 'service/transform.' + formatType);
// Load page SVG ...
var svg = window.parent.document.getElementById('workspaceContainer').innerHTML;
$('#svgXml').attr('value', svg);
var svgXml = window.parent.document.getElementById('workspaceContainer').innerHTML;
$('#svgXml').attr('value', svgXml);
}
$('#dialogMainForm input[name=download]').attr('value', formatType);
if (!differ) {
form.submit();
}
// Close dialog ...
$('#export-dialog-modal').modal('hide');
return true;
return {"action":form.attr('action'), "method":form.attr('method'), formatType:formatType};
}
</script>

View File

@ -6,7 +6,7 @@
<html>
<head>
<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]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->