[IMP] Removed openerp's ineffective JavaScript module loader and added retro-compatibility layer
bzr revid: nicolas.vanhoren@openerp.com-20130726121514-ss0omrhed76ybv5a
This commit is contained in:
@@ -42,6 +42,7 @@ This module provides the core of the OpenERP Web Client.
|
||||
"static/lib/backbone/backbone.js",
|
||||
"static/lib/cleditor/jquery.cleditor.js",
|
||||
"static/lib/py.js/lib/py.js",
|
||||
"static/src/js/openerpframework.js",
|
||||
"static/src/js/boot.js",
|
||||
"static/src/js/testing.js",
|
||||
"static/src/js/pyeval.js",
|
||||
|
||||
@@ -7,15 +7,20 @@
|
||||
* @namespace openerp
|
||||
*/
|
||||
(function() {
|
||||
if (this.openerp)
|
||||
return;
|
||||
var session_counter = 0;
|
||||
var inited = false;
|
||||
|
||||
var openerp = this.openerp = {
|
||||
_.extend(openerp, {
|
||||
// Per session namespace
|
||||
// openerp.<module> will map to
|
||||
// openerp.instances.sessionname.<module> using a closure
|
||||
instances: {},
|
||||
instances: {instance0: openerp},
|
||||
// links to the global openerp
|
||||
_openerp: openerp,
|
||||
// this unique id will be replaced by hostname_databasename by
|
||||
// openerp.web.Session on the first connection
|
||||
_session_id: "instance0",
|
||||
_modules: ['web'],
|
||||
web_mobile: {},
|
||||
/**
|
||||
* OpenERP instance constructor
|
||||
*
|
||||
@@ -24,41 +29,43 @@
|
||||
init: function(modules) {
|
||||
if (modules === null) {
|
||||
modules = [];
|
||||
} else {
|
||||
modules = _.union(['web'], modules || []);
|
||||
}
|
||||
var new_instance = {
|
||||
// links to the global openerp
|
||||
_openerp: openerp,
|
||||
// this unique id will be replaced by hostname_databasename by
|
||||
// openerp.web.Session on the first connection
|
||||
_session_id: "instance" + session_counter++,
|
||||
_modules: modules,
|
||||
web: {},
|
||||
web_mobile: {}
|
||||
};
|
||||
openerp.instances[new_instance._session_id] = new_instance;
|
||||
if (inited)
|
||||
throw new Error("OpenERP was already inited");
|
||||
inited = true;
|
||||
init_web_modules();
|
||||
for(var i=0; i < modules.length; i++) {
|
||||
new_instance[modules[i]] = {};
|
||||
if (openerp[modules[i]]) {
|
||||
openerp[modules[i]](new_instance,new_instance[modules[i]]);
|
||||
if (modules[i] === "web")
|
||||
continue;
|
||||
var fct = openerp[modules[i]];
|
||||
if (typeof(fct) === "function") {
|
||||
openerp[modules[i]] = {};
|
||||
for (k in fct) {
|
||||
openerp[modules[i]][k] = fct[k];
|
||||
}
|
||||
fct(openerp, openerp[modules[i]]);
|
||||
}
|
||||
}
|
||||
return new_instance;
|
||||
openerp._modules = ['web'].concat(modules);
|
||||
return openerp;
|
||||
}
|
||||
};
|
||||
})();
|
||||
});
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* OpenERP Web web module split
|
||||
*---------------------------------------------------------*/
|
||||
openerp.web = function(session) {
|
||||
var files = ["pyeval", "corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import"];
|
||||
for(var i=0; i<files.length; i++) {
|
||||
if(openerp.web[files[i]]) {
|
||||
openerp.web[files[i]](session);
|
||||
/*---------------------------------------------------------
|
||||
* OpenERP Web web module split
|
||||
*---------------------------------------------------------*/
|
||||
function init_web_modules() {
|
||||
var files = ["pyeval", "corelib","coresetup","dates","formats","chrome","data","views","search","list","form","list_editable","web_mobile","view_tree","data_export","data_import"];
|
||||
for(var i=0; i<files.length; i++) {
|
||||
var fct = openerp.web[files[i]];
|
||||
if(typeof(fct) === "function") {
|
||||
openerp.web[files[i]] = {};
|
||||
for (k in fct) {
|
||||
openerp.web[files[i]][k] = fct[k];
|
||||
}
|
||||
fct(openerp, openerp.web[files[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||
|
||||
@@ -250,10 +250,15 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
||||
continue;
|
||||
instance[mod] = {};
|
||||
// init module mod
|
||||
if(instance._openerp[mod] !== undefined) {
|
||||
instance._openerp[mod](instance,instance[mod]);
|
||||
this.module_loaded[mod] = true;
|
||||
var fct = instance._openerp[mod];
|
||||
if(typeof(fct) === "function") {
|
||||
instance._openerp[mod] = {};
|
||||
for (k in fct) {
|
||||
instance._openerp[mod][k] = fct[k];
|
||||
}
|
||||
fct(instance, instance._openerp[mod]);
|
||||
}
|
||||
this.module_loaded[mod] = true;
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
(function() {
|
||||
|
||||
function declare($, _, QWeb) {
|
||||
var openerp = {};
|
||||
|
||||
openerp.web = {};
|
||||
|
||||
return openerp;
|
||||
};
|
||||
|
||||
if (typeof(define) !== "undefined") { // amd
|
||||
define(["jquery", "underscore", "qweb"], declare);
|
||||
} else {
|
||||
window.openerp = declare($, _, QWeb2);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user