2012-05-21 20:32:26 +00:00
|
|
|
/*
|
2013-04-04 11:51:15 +00:00
|
|
|
* $Id: mxApplication.js,v 1.21 2010/11/08 20:09:40 gaudenz Exp $
|
2012-05-21 20:32:26 +00:00
|
|
|
* Copyright (c) 2006-2010, JGraph Ltd
|
|
|
|
*
|
|
|
|
* Defines the startup sequence of the application.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new application (note that this returns an mxEditor
|
|
|
|
* instance).
|
|
|
|
*/
|
|
|
|
function mxApplication(config)
|
|
|
|
{
|
|
|
|
var hideSplash = function()
|
|
|
|
{
|
|
|
|
// Fades-out the splash screen
|
|
|
|
var splash = document.getElementById('splash');
|
|
|
|
|
|
|
|
if (splash != null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
mxEvent.release(splash);
|
|
|
|
mxEffects.fadeOut(splash, 100, true);
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
splash.parentNode.removeChild(splash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!mxClient.isBrowserSupported())
|
|
|
|
{
|
|
|
|
mxUtils.error('Browser is not supported!', 200, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var node = mxUtils.load(config).getDocumentElement();
|
|
|
|
var editor = new mxEditor(node);
|
|
|
|
|
|
|
|
// Updates the window title after opening new files
|
|
|
|
var title = document.title;
|
|
|
|
var funct = function(sender)
|
|
|
|
{
|
|
|
|
document.title = title + ' - ' + sender.getTitle();
|
|
|
|
};
|
|
|
|
|
|
|
|
editor.addListener(mxEvent.OPEN, funct);
|
|
|
|
|
|
|
|
// Prints the current root in the window title if the
|
|
|
|
// current root of the graph changes (drilling).
|
|
|
|
editor.addListener(mxEvent.ROOT, funct);
|
|
|
|
funct(editor);
|
|
|
|
|
|
|
|
// Displays version in statusbar
|
|
|
|
editor.setStatus('mxGraph '+mxClient.VERSION);
|
|
|
|
|
|
|
|
// Shows the application
|
|
|
|
hideSplash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
hideSplash();
|
|
|
|
|
|
|
|
// Shows an error message if the editor cannot start
|
|
|
|
mxUtils.alert('Cannot start application: '+e.message);
|
|
|
|
throw e; // for debugging
|
|
|
|
}
|
|
|
|
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|