Working on samples.

This commit is contained in:
Paulo Veiga 2012-02-02 12:28:54 -03:00
parent b6dd7712f9
commit 8db3e88ad9
6 changed files with 62 additions and 24 deletions

View File

@ -27,7 +27,7 @@ mindplot.Designer = new Class({
// Dispatcher manager ...
var commandContext = new mindplot.CommandContext(this);
if (options.collab == 'standalone') {
if (!$defined(options.collab) || options.collab == 'standalone') {
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
} else {
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);

View File

@ -14,10 +14,8 @@
<h1>Embedded editor sample</h1>
<h2></h2>
<div style="text-align:center">
<iframe src="editor.html?width=800&height=600" width="800" height="600"></iframe>
<div style="text-align:right">
<iframe src="editor.html?confUrl=../html/container.json" width="800" height="600"></iframe>
</div>
</body>
</html>

View File

@ -0,0 +1,9 @@
{
"readOnly":"false",
"zoom":0.85,
"saveOnLoad":false,
"size":{
"width":800,
"height":600
}
}

View File

@ -20,10 +20,9 @@
<script type="text/javascript">
var mapId = 'welcome';
var viewMode = false;
$(document).addEvent('loadcomplete', function(resource) {
var designer = buildDesigner(viewMode);
var options = loadDesignerOptions();
var designer = buildDesigner(options);
// Configure default persistence manager ...
mindplot.PersistenceManager.init(new mindplot.LocalStorageManager());
@ -45,6 +44,7 @@
}
});
</script>
</head>
<body>

View File

@ -1,6 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=html/editor.html">
</head>
<body>
<a href="html/container.html">Embedding the mindmap in a page</a>
<a href="html/editor.html">Full page</a>
<a href="html/viewmode.html">Read Only version</a>
</body>
</html>

View File

@ -18,30 +18,20 @@
var designer = null;
function buildDesigner(viewMode, containerSize) {
function buildDesigner(options) {
var container = $('mindplot');
container.setStyles(options.size);
// Set workspace size ...
if (!containerSize) {
containerSize = {
// Set workspace screen size as default. In this way, resize issues are solved.
height: parseInt(screen.height),
width: parseInt(screen.width)
}
}
container.setStyles(containerSize);
var editorProperties = {zoom:0.85,saveOnLoad:true,collab:'standalone',readOnly:viewMode};
designer = new mindplot.Designer(editorProperties, container);
designer = new mindplot.Designer(options, container);
designer.setViewPort({
height: parseInt(window.innerHeight - 70), // Footer and Header
width: parseInt(window.innerWidth)
});
if (!viewMode) {
if (!options.readOnly) {
if ($('toolbar')) {
var menu = new mindplot.widget.Menu(designer, 'toolbar', mapId);
var menu = new mindplot.widget.Menu(designer, 'toolbar');
// If a node has focus, focus can be move to another node using the keys.
designer._cleanScreen = function() {
@ -52,4 +42,38 @@ function buildDesigner(viewMode, containerSize) {
return designer;
}
function loadDesignerOptions() {
// Load map options ...
var uri = new URI(window.location);
var query = String.parseQueryString(uri.get('query'));
var jsonConf = query.confUrl;
var result;
if (jsonConf) {
var request = new Request.JSON({
url: jsonConf,
async:false,
onSuccess:
function(options) {
this.options = options;
}.bind(this)
}
);
request.get();
result = this.options;
}
else {
// Set workspace screen size as default. In this way, resize issues are solved.
var containerSize = {
height: parseInt(screen.height),
width: parseInt(screen.width)
};
result = {readOnly:true,zoom:0.85,saveOnLoad:true,size:containerSize};
}
return result;
}
Asset.javascript("../js/mindplot-min.js");