mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
Finish moving mindmap loading to rest.
This commit is contained in:
parent
829655f253
commit
92849b02eb
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
mindplot.LocalStorageManager = new Class({
|
mindplot.LocalStorageManager = new Class({
|
||||||
Extends:mindplot.PersistenceManager,
|
Extends:mindplot.PersistenceManager,
|
||||||
initialize:function () {
|
initialize:function (documentUrl) {
|
||||||
this.parent();
|
this.parent();
|
||||||
|
this.documentUrl = documentUrl;
|
||||||
},
|
},
|
||||||
|
|
||||||
saveMapXml:function (mapId, mapXml, pref, saveHistory, events) {
|
saveMapXml:function (mapId, mapXml, pref, saveHistory, events) {
|
||||||
@ -33,9 +34,9 @@ mindplot.LocalStorageManager = new Class({
|
|||||||
loadMapDom:function (mapId) {
|
loadMapDom:function (mapId) {
|
||||||
var xml = localStorage.getItem(mapId + "-xml");
|
var xml = localStorage.getItem(mapId + "-xml");
|
||||||
if (xml == null) {
|
if (xml == null) {
|
||||||
// Let's try to open one from the local directory ...
|
|
||||||
var xmlRequest = new Request({
|
var xmlRequest = new Request({
|
||||||
url:'samples/' + mapId + '.xml',
|
url:this.documentUrl.replace("{id}", mapId),
|
||||||
|
headers:{"Content-Type":"text/plain","Accept":"application/xml"},
|
||||||
method:'get',
|
method:'get',
|
||||||
async:false,
|
async:false,
|
||||||
onSuccess:function (responseText) {
|
onSuccess:function (responseText) {
|
||||||
|
@ -87,7 +87,7 @@ function buildDesigner(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
persistence = new mindplot.LocalStorageManager();
|
persistence = new mindplot.LocalStorageManager("samples/{id}.xml");
|
||||||
}
|
}
|
||||||
mindplot.PersistenceManager.init(persistence);
|
mindplot.PersistenceManager.init(persistence);
|
||||||
|
|
||||||
|
@ -33,18 +33,21 @@
|
|||||||
// Configure designer options ...
|
// Configure designer options ...
|
||||||
var options = loadDesignerOptions();
|
var options = loadDesignerOptions();
|
||||||
|
|
||||||
<c:if test="${!memoryPersistence}">
|
<c:if test="${!memoryPersistence && !readOnlyMode}">
|
||||||
options.persistenceManager = new mindplot.RESTPersistenceManager(
|
options.persistenceManager = new mindplot.RESTPersistenceManager(
|
||||||
{
|
{
|
||||||
documentUrl:"c/restful/maps/{id}/document",
|
documentUrl:"c/restful/maps/{id}/document",
|
||||||
revertUrl:"c/restful/maps/{id}/history/latest",
|
revertUrl:"c/restful/maps/{id}/history/latest",
|
||||||
lockUrl:"c/restful/maps/{id}/lock",
|
lockUrl:"c/restful/maps/{id}/lock",
|
||||||
timestamp: "${lockTimestamp}?${lockTimestamp}:0",
|
timestamp: "${lockTimestamp}",
|
||||||
session: "${lockSession}?${lockSession}:0"
|
session: "${lockSession}"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
</c:if>
|
</c:if>
|
||||||
|
<c:if test="${memoryPersistence || readOnlyMode}">
|
||||||
|
options.persistenceManager = new mindplot.LocalStorageManager("c/restful/maps/{id}/document/xml");
|
||||||
|
</c:if>
|
||||||
|
|
||||||
var userOptions = ${mindmap.properties};
|
var userOptions = ${mindmap.properties};
|
||||||
options.zoom = userOptions.zoom;
|
options.zoom = userOptions.zoom;
|
||||||
options.readOnly = ${!!readOnlyMode};
|
options.readOnly = ${!!readOnlyMode};
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
|
<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
|
||||||
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
||||||
<%--@elvariable id="editorTryMode" type="java.lang.String"--%>
|
<%--@elvariable id="editorTryMode" type="java.lang.String"--%>
|
||||||
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
|
|
||||||
|
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
@ -27,7 +26,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var mapId = '${mindmap.id}';
|
var mapId = '${mindmap.id}';
|
||||||
var mapXml = '${mindmap.xmlAsJsLiteral}';
|
|
||||||
$(document).addEvent('loadcomplete', function (resource) {
|
$(document).addEvent('loadcomplete', function (resource) {
|
||||||
|
|
||||||
// Configure designer options ...
|
// Configure designer options ...
|
||||||
@ -45,14 +44,15 @@
|
|||||||
// Print is read only ...
|
// Print is read only ...
|
||||||
options.readOnly = true;
|
options.readOnly = true;
|
||||||
|
|
||||||
|
// Configure persistence ...
|
||||||
|
options.persistenceManager = new mindplot.LocalStorageManager("c/restful/maps/{id}/document/xml");
|
||||||
|
|
||||||
// Build designer ...
|
// Build designer ...
|
||||||
var designer = buildDesigner(options);
|
var designer = buildDesigner(options);
|
||||||
|
|
||||||
// Load map from XML ...
|
// Load map ...
|
||||||
var parser = new DOMParser();
|
var persistence = mindplot.PersistenceManager.getInstance();
|
||||||
var domDocument = parser.parseFromString(mapXml, "text/xml");
|
var mindmap = mindmap = persistence.load(mapId);
|
||||||
|
|
||||||
var mindmap = mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
|
|
||||||
designer.loadMap(mindmap);
|
designer.loadMap(mindmap);
|
||||||
|
|
||||||
$('zoomIn').addEvent('click', function () {
|
$('zoomIn').addEvent('click', function () {
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
|
<%--@elvariable id="mindmap" type="com.wisemapping.model.Mindmap"--%>
|
||||||
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
||||||
<%--@elvariable id="editorTryMode" type="java.lang.String"--%>
|
<%--@elvariable id="editorTryMode" type="java.lang.String"--%>
|
||||||
<%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%>
|
|
||||||
|
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
|
|
||||||
@ -60,7 +59,6 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var mapId = '${mindmap.id}';
|
var mapId = '${mindmap.id}';
|
||||||
var mapXml = '${mindmap.xmlAsJsLiteral}';
|
|
||||||
|
|
||||||
$(document).addEvent('loadcomplete', function (resource) {
|
$(document).addEvent('loadcomplete', function (resource) {
|
||||||
|
|
||||||
@ -78,14 +76,15 @@
|
|||||||
// Print is read only ...
|
// Print is read only ...
|
||||||
options.readOnly = true;
|
options.readOnly = true;
|
||||||
|
|
||||||
|
// Configure loader ...
|
||||||
|
options.persistenceManager = new mindplot.LocalStorageManager("c/restful/maps/{id}/document/xml.xml");
|
||||||
|
|
||||||
// Build designer ...
|
// Build designer ...
|
||||||
var designer = buildDesigner(options);
|
var designer = buildDesigner(options);
|
||||||
|
|
||||||
// Load map from XML ...
|
// Load map ...
|
||||||
var parser = new DOMParser();
|
var persistence = mindplot.PersistenceManager.getInstance();
|
||||||
var domDocument = parser.parseFromString(mapXml, "text/xml");
|
var mindmap = mindmap = persistence.load(mapId);
|
||||||
|
|
||||||
var mindmap = mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
|
|
||||||
designer.loadMap(mindmap);
|
designer.loadMap(mindmap);
|
||||||
|
|
||||||
$('zoomIn').addEvent('click', function () {
|
$('zoomIn').addEvent('click', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user