Merge commit 'refs/merge-requests/2' of repo.wisemapping.org:wisemapping/wiseorg into merge-requests/2

This commit is contained in:
Paulo Gustavo Veiga 2012-02-17 11:04:02 -03:00
commit c1469f1da0
3 changed files with 139 additions and 0 deletions

46
ConfigParameters.md Normal file
View File

@ -0,0 +1,46 @@
# Configuration parameters for embedded minmaps
The mindmap designer object takse a set of configuration options.
An example config may look like this::
{
"readOnly":false,
"zoom":1.3,
"size":{
"width":800,
"height":400
},
"viewPort":
{
"width":800,
"height":400
},
"persistenceManager": "mindplot.LocalStorageManager",
"mapId": "welcome",
"container":"mindplot"
}
The options are:
* readOnly: Set to true if the viewer should not be able to edit the map.
* zoom: how much the map should be zoomed.
* size: size of the map area.
* viewPort: set this to the same as the size
* persistenceManager: Classname of a class that extends mindplot.PersistenceManager (see ImplementingPersistence for more info.)
* mapId: The id of the map
* container: The id of the containing div.
Viewport and size should be set like this::
var containerSize = {
height: parseInt(screen.height),
width: parseInt(screen.width)
};
var viewPort = {
height: parseInt(window.innerHeight - 70), // Footer and Header
width: parseInt(window.innerWidth)
};

View File

@ -0,0 +1,86 @@
# Implementing custom storage
To implement a custom backend, you need to create your own implementation of the mindplot.PersistenceManager class.
Here is an example skeleton::
function createStorageManager(mindplot) {
mindplot.RestStorageManager = new Class({
Extends:mindplot.PersistenceManager,
initialize: function(url) {
this.parent();
this.backendUrl = url;
},
saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
var url = this.backendUrl + mapId;
var xmlRequest = new Request({
url: url,
method: 'post',
async: false,
onSuccess: function(responseText) {
events.onSuccess();
},
onError: function (text, error) {
console.log("Error saving mindmap to: " + url, text, error);
events.onError();
}
});
xmlRequest.send();
},
loadMapDom : function(mapId) {
var xmlRequest = new Request({
url: this.backendUrl + mapId,
method: 'get',
async: false,
onSuccess: function(responseText) {
xml = responseText;
}
});
xmlRequest.send();
// If I could not load it from a file, hard code one.
if (xml == null) {
throw "Map could not be loaded";
}
return core.Utils.createDocumentFromText(xml);
}
}
);
return new mindplot.RestStorageManager(url);
}
In your script for loading the mindmap you add a call to the callback into the loadcomplete method::
$(document).addEvent('loadcomplete', function(resource) {
//Asset.javascript("{{ asset('bundles/fpgadmin/js/FpgMindmapPersistence.js')}}");
// Options has been defined in by a external ile ?
var options = {
'persistenceManager' : createStorageManager(mindplot, "http://localhost/my/rest/interface");
viewPort: {
height: parseInt(window.innerHeight - 70), // Footer and Header
width: parseInt(window.innerWidth)
},
size : {
height: parseInt(screen.height),
width: parseInt(screen.width)
},
"readOnly":false,
"zoom":1.3,
"container":"mindplot"
"mapId" : "myMapId"
};
var designer = buildDesigner(options);
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap;
try {
mindmap = persistence.load(mapId);
} catch(e) {
// If the map could not be loaded, create a new empty map...
mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
}
designer.loadMap(mindmap);
});

View File

@ -36,6 +36,13 @@ This will start the application on the URL: http://localhost:8080/wise-webapp/.
User: test@wisemapping.org
## Running the JS only version
Start by creating the .zip file:
`mvn assembly:assembly -Dmaven.test.skip=true`
## Author
* Pablo Luna