split constructor function and place of instanciation for app.js objects: app[appname] = new app.classes[appname]();

This commit is contained in:
Ralf Becker 2013-11-04 20:54:23 +00:00
parent f41480a3f6
commit 6d226a7921
11 changed files with 178 additions and 160 deletions

View File

@ -6,7 +6,7 @@
* @author Hadi Nategh <hn-AT-stylite.de>
* @copyright (c) 2008-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $id
* @version $Id$
*/
/**
@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.addressbook = AppJS.extend(
app.classes.addressbook = AppJS.extend(
{
appname: 'addressbook',
/**

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.admin = AppJS.extend(
app.classes.admin = AppJS.extend(
{
appname: 'admin',
/**

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.calendar = AppJS.extend(
app.classes.calendar = AppJS.extend(
{
/**
* application name

View File

@ -214,7 +214,13 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
// Initialize application js
var app_callback = null;
// Only initialize once
if(typeof app[appname] == "function")
// new app class with constructor function in app.classes[appname]
if (typeof app[appname] !== 'object' && typeof app.classes[appname] == 'function')
{
app[appname] = new app.classes[appname]();
}
// old app class with constructor function in app[appname] (deprecated)
else if(typeof app[appname] == "function")
{
(function() { new app[appname]();}).call();
}

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.filemanager = AppJS.extend(
app.classes.filemanager = AppJS.extend(
{
appname: 'filemanager',
/**

View File

@ -27,7 +27,7 @@
* @see http://gridster.net
* @augments AppJS
*/
app.home = AppJS.extend(
app.classes.home = AppJS.extend(
{
/**
* AppJS requires overwriting this with the actual application name

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.importexport = AppJS.extend(
app.classes.importexport = AppJS.extend(
{
appname: 'importexport',

View File

@ -6,7 +6,7 @@
* @author Hadi Nategh <hn-AT-stylite.de>
* @copyright (c) 2008-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version
* @version $Id$
*/
/**
@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.infolog = AppJS.extend(
app.classes.infolog = AppJS.extend(
{
appname: 'infolog',
/**

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.mail = AppJS.extend(
app.classes.mail = AppJS.extend(
{
appname: 'mail',

View File

@ -15,7 +15,19 @@
egw_inheritance;
*/
window.app = {};
/**
* Object to collect instanciated appliction objects
*
* Attributes classes collects loaded application classes,
* which can get instanciated:
*
* app[appname] = new app.classes[appname]();
*
* On destruction only app[appname] gets deleted, app.classes[appname] need to be used again!
*
* @type object
*/
window.app = {classes: {}};
/**
* Common base class for application javascript
@ -47,8 +59,8 @@ window.app = {};
* }
* });
*/
var AppJS = Class.extend({
var AppJS = Class.extend(
{
/**
* Internal application name - override this
*/

View File

@ -14,7 +14,7 @@
*
* @augments AppJS
*/
app.timesheet = AppJS.extend(
app.classes.timesheet = AppJS.extend(
{
appname: 'timesheet',
/**