2012-06-30 02:26:21 -03:00
|
|
|
<%@page pageEncoding="UTF-8" %>
|
|
|
|
<%@include file="/jsp/init.jsp" %>
|
2012-05-24 00:35:17 -03:00
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
<div>
|
2012-06-03 19:19:48 -03:00
|
|
|
|
2012-06-06 01:19:55 -03:00
|
|
|
<p class="alert alert-info"><spring:message code="IMPORT_MINDMAP_INFO"/></p>
|
2012-05-24 00:35:17 -03:00
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
<form method="POST" enctype="multipart/form-data" action="#" id="dialogMainForm" class="form-horizontal">
|
2012-06-06 01:19:55 -03:00
|
|
|
<div class="errorMessage"></div>
|
2012-06-06 00:48:46 -03:00
|
|
|
<fieldset>
|
|
|
|
<div class="control-group">
|
|
|
|
<label for="mapFile" class="control-label"><spring:message code="MIND_FILE"/>: </label>
|
2012-06-06 01:42:24 -03:00
|
|
|
<input type="file" name="file" id="mapFile" required="required" class="control"/>
|
2012-06-06 00:48:46 -03:00
|
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
|
|
<label for="title" class="control-label"><spring:message code="NAME"/>: </label>
|
2012-06-06 01:19:55 -03:00
|
|
|
<input type="text" id="title" name="title" required="required"
|
|
|
|
placeholder="Name of the new map to create"
|
2012-06-06 00:48:46 -03:00
|
|
|
class="control"/>
|
|
|
|
</div>
|
|
|
|
<div class="control-group">
|
2012-05-24 00:35:17 -03:00
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
<label for="description" class="control-label"><spring:message code="DESCRIPTION"/>: </label>
|
|
|
|
<textarea type="text" name="description" id="description"
|
|
|
|
placeholder="Some description for your map" class="control"></textarea>
|
|
|
|
</div>
|
2012-05-24 00:35:17 -03:00
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
</fieldset>
|
2012-06-03 19:19:48 -03:00
|
|
|
</form>
|
2009-06-07 18:59:43 +00:00
|
|
|
</div>
|
2012-06-03 19:19:48 -03:00
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
// Save status on click ...
|
2012-06-06 00:48:46 -03:00
|
|
|
var contentType = null;
|
|
|
|
var fileContent = null;
|
|
|
|
|
2012-06-30 15:25:24 -03:00
|
|
|
$('#cancelButton').click(function () {
|
2012-07-01 22:42:18 -03:00
|
|
|
window.location = 'c/maps/';
|
2012-06-03 19:19:48 -03:00
|
|
|
});
|
|
|
|
|
2012-06-30 15:25:24 -03:00
|
|
|
$('#dialogMainForm').submit(function (event) {
|
2012-06-06 00:48:46 -03:00
|
|
|
// Load form parameters ...
|
|
|
|
var title = $('#dialogMainForm #title').attr('value');
|
|
|
|
title = title == undefined ? "" : title;
|
|
|
|
|
|
|
|
var description = $('#dialogMainForm #description').attr('value');
|
|
|
|
description = description == undefined ? "" : description;
|
|
|
|
|
|
|
|
// Save status on click ...
|
|
|
|
jQuery.ajax("service/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
|
|
|
|
{
|
|
|
|
async:false,
|
2012-06-30 15:25:24 -03:00
|
|
|
data:fileContent,
|
|
|
|
type:'POST',
|
|
|
|
dataType:'json',
|
2012-06-06 00:48:46 -03:00
|
|
|
contentType:contentType,
|
2012-06-30 15:25:24 -03:00
|
|
|
success:function (data, textStatus, jqXHR) {
|
2012-06-06 00:48:46 -03:00
|
|
|
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
|
|
|
window.location = "c/maps/" + resourceId + "/edit";
|
|
|
|
},
|
2012-06-30 15:25:24 -03:00
|
|
|
error:function (jqXHR, textStatus, errorThrown) {
|
2012-06-06 01:19:55 -03:00
|
|
|
if (jqXHR.status == 400) {
|
|
|
|
var errors = JSON.parse(jqXHR.responseText);
|
|
|
|
// Mark fields with errors ...
|
|
|
|
var fieldErrors = errors.fieldErrors;
|
|
|
|
if (fieldErrors) {
|
|
|
|
for (var fieldName in fieldErrors) {
|
|
|
|
// Mark the field with errors ...
|
|
|
|
var message = fieldErrors[fieldName];
|
|
|
|
var inputField = $("#dialogMainForm input[name='" + fieldName + "']");
|
|
|
|
$("#dialogMainForm").find(".errorMessage").text(message).addClass("alert alert-error");
|
|
|
|
inputField.parent().addClass('error');
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 19:45:22 -03:00
|
|
|
var globalErrors = errors.globalErrors;
|
|
|
|
if (globalErrors) {
|
|
|
|
for (var error in globalErrors) {
|
|
|
|
// Mark the field with errors ...
|
|
|
|
$("#dialogMainForm").find(".errorMessage").text(error).addClass("alert alert-error");
|
|
|
|
inputField.parent().addClass('error');
|
|
|
|
}
|
|
|
|
}
|
2012-06-06 01:19:55 -03:00
|
|
|
} else {
|
|
|
|
console.log(errorThrown);
|
|
|
|
console.log(jqXHR);
|
|
|
|
$('#messagesPanel div').text(errorThrown).parent().show();
|
|
|
|
}
|
2012-06-06 00:48:46 -03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
|
2012-06-30 15:25:24 -03:00
|
|
|
$('#dialogMainForm #mapFile').change(function (event) {
|
2012-06-06 00:48:46 -03:00
|
|
|
var file = event.target.files[0];
|
|
|
|
var reader = new FileReader();
|
|
|
|
|
|
|
|
var title = file.name;
|
|
|
|
title = title.substring(0, title.lastIndexOf("."));
|
|
|
|
$('#dialogMainForm #title').attr('value', jQuery.camelCase(title));
|
2012-06-03 19:19:48 -03:00
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
// Closure to capture the file information.
|
2012-06-30 15:25:24 -03:00
|
|
|
reader.onload = (function (event) {
|
2012-06-06 00:48:46 -03:00
|
|
|
fileContent = event.target.result;
|
|
|
|
contentType = file.name.lastIndexOf(".wxml") != -1 ? "application/xml" : "application/freemind";
|
2012-06-03 19:19:48 -03:00
|
|
|
});
|
2012-06-06 00:48:46 -03:00
|
|
|
|
|
|
|
// Read in the image file as a data URL.
|
|
|
|
reader.readAsBinaryString(file);
|
2012-06-03 19:19:48 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
// Hook for interaction with the main parent window ...
|
2012-06-30 15:25:24 -03:00
|
|
|
var submitDialogForm = function () {
|
2012-06-03 19:19:48 -03:00
|
|
|
$('#dialogMainForm').submit();
|
|
|
|
}
|
2012-06-06 00:48:46 -03:00
|
|
|
|
2012-06-03 19:19:48 -03:00
|
|
|
</script>
|