2012-02-21 19:37:15 +01:00
|
|
|
/*
|
|
|
|
* Copyright [2011] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var designer = null;
|
|
|
|
|
|
|
|
function buildDesigner(options) {
|
|
|
|
|
|
|
|
var container = $(options.container);
|
|
|
|
$assert(container, 'container could not be null');
|
|
|
|
|
|
|
|
// Register load events ...
|
|
|
|
designer = new mindplot.Designer(options, container);
|
2012-07-01 22:21:02 +02:00
|
|
|
designer.addEvent('loadSuccess', function () {
|
2012-04-05 05:25:34 +02:00
|
|
|
window.waitDialog.close.delay(1000, window.waitDialog);
|
2012-04-02 19:11:28 +02:00
|
|
|
window.waitDialog = null;
|
2012-08-28 14:07:06 +02:00
|
|
|
window.mindmapLoadReady = true;
|
2012-02-21 19:37:15 +01:00
|
|
|
});
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
window.onerror = function (message, url, lineNo) {
|
2012-06-23 19:39:50 +02:00
|
|
|
// Log error message ...
|
|
|
|
|
2012-04-02 19:11:28 +02:00
|
|
|
if (window.waitDialog) {
|
2012-04-05 05:25:34 +02:00
|
|
|
window.waitDialog.close.delay(1000, window.waitDialog);
|
2012-04-02 19:11:28 +02:00
|
|
|
window.waitDialog = null;
|
|
|
|
}
|
2012-08-28 14:07:06 +02:00
|
|
|
|
2012-06-23 19:39:50 +02:00
|
|
|
var req = new Request({
|
2012-07-01 22:21:02 +02:00
|
|
|
method:'post',
|
|
|
|
url:"/service/logger/editor",
|
|
|
|
headers:{"Content-Type":"application/json", "Accept":"application/json"},
|
2012-06-23 19:39:50 +02:00
|
|
|
emulation:false,
|
|
|
|
urlEncoded:false
|
|
|
|
}).post(JSON.encode({
|
2012-09-20 01:01:22 +02:00
|
|
|
jsErrorMsg:"message: '" + message + "', line:'" + lineNo + "', :" + url,
|
2012-07-01 22:21:02 +02:00
|
|
|
jsStack:window.errorStack,
|
|
|
|
userAgent:navigator.userAgent,
|
|
|
|
mapId:options.mapId}));
|
2012-06-23 19:39:50 +02:00
|
|
|
|
2012-08-28 14:07:06 +02:00
|
|
|
// Open error dialog only in case of mindmap loading errors. The rest of the error are reported but not display the dialog.
|
|
|
|
// Remove this in the near future.
|
|
|
|
if (!window.mindmapLoadReady) {
|
|
|
|
errorDialog.show();
|
|
|
|
}
|
2012-03-08 04:11:54 +01:00
|
|
|
};
|
|
|
|
|
2012-02-21 19:37:15 +01:00
|
|
|
// Configure default persistence manager ...
|
|
|
|
var persistence;
|
|
|
|
if (options.persistenceManager) {
|
2012-03-08 01:17:19 +01:00
|
|
|
if (options.persistenceManager instanceof String) {
|
|
|
|
persistence = eval("new " + options.persistenceManager + "()");
|
2012-02-21 19:37:15 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-03-08 01:17:19 +01:00
|
|
|
persistence = options.persistenceManager;
|
2012-02-21 19:37:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
persistence = new mindplot.LocalStorageManager();
|
|
|
|
}
|
|
|
|
mindplot.PersistenceManager.init(persistence);
|
|
|
|
|
|
|
|
// Register toolbar event ...
|
|
|
|
if ($('toolbar')) {
|
2012-04-05 05:25:34 +02:00
|
|
|
var menu = new mindplot.widget.Menu(designer, 'toolbar', options.mapId, "");
|
2012-02-21 19:37:15 +01:00
|
|
|
|
|
|
|
// If a node has focus, focus can be move to another node using the keys.
|
2012-07-01 22:21:02 +02:00
|
|
|
designer._cleanScreen = function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
menu.clear()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return designer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadDesignerOptions(jsonConf) {
|
|
|
|
// Load map options ...
|
2012-04-02 00:41:19 +02:00
|
|
|
var result;
|
2012-02-21 19:37:15 +01:00
|
|
|
if (jsonConf) {
|
|
|
|
var request = new Request.JSON({
|
2012-07-01 22:21:02 +02:00
|
|
|
url:jsonConf,
|
2012-02-21 19:37:15 +01:00
|
|
|
async:false,
|
2012-07-01 22:21:02 +02:00
|
|
|
onSuccess:function (options) {
|
|
|
|
this.options = options;
|
2012-02-21 19:37:15 +01:00
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
}.bind(this)
|
2012-02-21 19:37:15 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
request.get();
|
|
|
|
result = this.options;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Set workspace screen size as default. In this way, resize issues are solved.
|
|
|
|
var containerSize = {
|
2012-07-01 22:21:02 +02:00
|
|
|
height:parseInt(screen.height),
|
|
|
|
width:parseInt(screen.width)
|
2012-02-21 19:37:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var viewPort = {
|
2012-07-01 22:21:02 +02:00
|
|
|
height:parseInt(window.innerHeight - 70), // Footer and Header
|
|
|
|
width:parseInt(window.innerWidth)
|
2012-02-21 19:37:15 +01:00
|
|
|
};
|
2012-07-01 22:54:46 +02:00
|
|
|
result = {readOnly:false, zoom:0.85, saveOnLoad:true, size:containerSize, viewPort:viewPort, container:'mindplot', locale:'en'};
|
2012-02-21 19:37:15 +01:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor = {};
|
|
|
|
editor.WaitDialog = new Class({
|
|
|
|
Extends:MooDialog,
|
2012-07-01 22:21:02 +02:00
|
|
|
initialize:function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
var panel = this._buildPanel();
|
|
|
|
this.parent({
|
|
|
|
closeButton:false,
|
|
|
|
destroyOnClose:true,
|
2012-04-02 00:41:19 +02:00
|
|
|
autoOpen:false,
|
2012-02-21 19:37:15 +01:00
|
|
|
useEscKey:false,
|
2012-07-01 22:56:31 +02:00
|
|
|
title:'',
|
2012-07-01 22:21:02 +02:00
|
|
|
onInitialize:function (wrapper) {
|
2012-03-08 01:17:19 +01:00
|
|
|
wrapper.setStyle('opacity', 0);
|
2012-04-02 03:06:49 +02:00
|
|
|
this.wrapper.setStyle('display', 'none');
|
2012-03-08 01:17:19 +01:00
|
|
|
this.fx = new Fx.Morph(wrapper, {
|
2012-07-01 22:21:02 +02:00
|
|
|
duration:100,
|
|
|
|
transition:Fx.Transitions.Bounce.easeOut
|
2012-03-08 01:17:19 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
onBeforeOpen:function () {
|
2012-04-02 19:11:28 +02:00
|
|
|
this.overlay = new Overlay(this.options.inject, {
|
2012-07-01 22:21:02 +02:00
|
|
|
duration:this.options.duration
|
2012-04-02 19:11:28 +02:00
|
|
|
});
|
2012-03-08 01:17:19 +01:00
|
|
|
this.overlay.open();
|
|
|
|
this.fx.start({
|
2012-07-01 22:21:02 +02:00
|
|
|
'margin-top':[-200, -100],
|
|
|
|
opacity:[0, 1]
|
|
|
|
}).chain(function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
this.fireEvent('show');
|
2012-04-02 00:41:19 +02:00
|
|
|
this.wrapper.setStyle('display', 'block');
|
|
|
|
|
2012-03-08 01:17:19 +01:00
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
onBeforeClose:function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
this.fx.start({
|
2012-07-01 22:21:02 +02:00
|
|
|
'margin-top':[-100, 0],
|
|
|
|
opacity:0,
|
|
|
|
duration:200
|
|
|
|
}).chain(function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
this.fireEvent('hide');
|
2012-04-02 00:41:19 +02:00
|
|
|
this.wrapper.setStyle('display', 'none');
|
|
|
|
|
2012-03-08 01:17:19 +01:00
|
|
|
}.bind(this));
|
|
|
|
}}
|
|
|
|
);
|
|
|
|
this.setContent(panel);
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
_buildPanel:function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
var result = new Element('div');
|
|
|
|
result.setStyles({
|
|
|
|
'text-align':'center',
|
2012-07-01 22:21:02 +02:00
|
|
|
width:'400px'
|
2012-03-08 01:17:19 +01:00
|
|
|
});
|
2012-07-01 22:21:02 +02:00
|
|
|
var img = new Element('img', {'src':'images/ajax-loader.gif'});
|
2012-06-20 23:01:02 +02:00
|
|
|
img.setStyle('margin-top', '15px');
|
2012-03-08 01:17:19 +01:00
|
|
|
img.inject(result);
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
show:function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
this.open();
|
2012-04-02 19:11:28 +02:00
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
destroy:function () {
|
2012-04-02 19:11:28 +02:00
|
|
|
this.parent();
|
|
|
|
this.overlay.destroy();
|
2012-03-08 01:17:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
editor.FatalErrorDialog = new Class({
|
|
|
|
Extends:MooDialog,
|
2012-07-01 22:21:02 +02:00
|
|
|
initialize:function () {
|
2012-03-08 01:17:19 +01:00
|
|
|
this.parent({
|
|
|
|
closeButton:false,
|
|
|
|
destroyOnClose:true,
|
|
|
|
autoOpen:true,
|
|
|
|
useEscKey:false,
|
|
|
|
title:'Outch!!. An unexpected error has occurred',
|
2012-07-01 22:21:02 +02:00
|
|
|
onInitialize:function (wrapper) {
|
2012-02-21 19:37:15 +01:00
|
|
|
wrapper.setStyle('opacity', 0);
|
2012-04-02 03:06:49 +02:00
|
|
|
this.wrapper.setStyle('display', 'none');
|
2012-02-21 19:37:15 +01:00
|
|
|
this.fx = new Fx.Morph(wrapper, {
|
2012-07-01 22:21:02 +02:00
|
|
|
duration:100,
|
|
|
|
transition:Fx.Transitions.Bounce.easeOut
|
2012-02-21 19:37:15 +01:00
|
|
|
});
|
2012-04-02 00:41:19 +02:00
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
onBeforeOpen:function () {
|
|
|
|
var panel = this._buildPanel();
|
|
|
|
this.setContent(panel);
|
|
|
|
|
2012-02-21 19:37:15 +01:00
|
|
|
this.overlay = new Overlay(this.options.inject, {
|
2012-07-01 22:21:02 +02:00
|
|
|
duration:this.options.duration
|
2012-02-21 19:37:15 +01:00
|
|
|
});
|
2012-04-02 00:41:19 +02:00
|
|
|
if (this.options.closeOnOverlayClick)
|
|
|
|
this.overlay.addEvent('click', this.close.bind(this));
|
2012-02-21 19:37:15 +01:00
|
|
|
this.overlay.open();
|
|
|
|
this.fx.start({
|
2012-07-01 22:21:02 +02:00
|
|
|
'margin-top':[-200, -100],
|
|
|
|
opacity:[0, 1]
|
|
|
|
}).chain(function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
this.fireEvent('show');
|
2012-04-02 03:06:49 +02:00
|
|
|
this.wrapper.setStyle('display', 'block');
|
2012-02-21 19:37:15 +01:00
|
|
|
}.bind(this));
|
2012-04-02 03:06:49 +02:00
|
|
|
},
|
2012-02-21 19:37:15 +01:00
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
onBeforeClose:function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
this.fx.start({
|
2012-07-01 22:21:02 +02:00
|
|
|
'margin-top':[-100, 0],
|
|
|
|
opacity:0,
|
|
|
|
duration:200
|
|
|
|
}).chain(function () {
|
2012-04-02 03:06:49 +02:00
|
|
|
this.wrapper.setStyle('display', 'none');
|
2012-02-21 19:37:15 +01:00
|
|
|
this.fireEvent('hide');
|
2012-04-02 03:06:49 +02:00
|
|
|
|
2012-02-21 19:37:15 +01:00
|
|
|
}.bind(this));
|
|
|
|
}}
|
2012-03-08 03:51:37 +01:00
|
|
|
);
|
2012-02-21 19:37:15 +01:00
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
destroy:function () {
|
2012-04-02 19:11:28 +02:00
|
|
|
this.parent();
|
|
|
|
this.overlay.destroy();
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
_buildPanel:function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
var result = new Element('div');
|
|
|
|
result.setStyles({
|
|
|
|
'text-align':'center',
|
2012-07-01 22:21:02 +02:00
|
|
|
width:'400px'
|
2012-02-21 19:37:15 +01:00
|
|
|
});
|
2012-07-01 22:21:02 +02:00
|
|
|
var p = new Element('p', {'text':$msg('UNEXPECTED_ERROR_LOADING')});
|
2012-03-08 01:17:19 +01:00
|
|
|
p.inject(result);
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
var img = new Element('img', {'src':'images/alert-sign.png'});
|
2012-02-21 19:37:15 +01:00
|
|
|
img.inject(result);
|
2012-03-08 01:17:19 +01:00
|
|
|
|
2012-02-21 19:37:15 +01:00
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
2012-07-01 22:21:02 +02:00
|
|
|
show:function () {
|
2012-02-21 19:37:15 +01:00
|
|
|
this.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// Show loading dialog ...
|
|
|
|
waitDialog = new editor.WaitDialog();
|
|
|
|
waitDialog.show();
|
2012-03-08 01:17:19 +01:00
|
|
|
errorDialog = new editor.FatalErrorDialog();
|
2012-02-21 19:37:15 +01:00
|
|
|
|
|
|
|
// Loading libraries ...
|
|
|
|
Asset.javascript("js/mindplot-min.js");
|