Author: ndkhoiits
Date: 2011-08-14 00:52:21 -0400 (Sun, 14 Aug 2011)
New Revision: 7092
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo.js
Log:
GTNPORTAL-1964 Improve Javascript lazy loading machanism
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo.js
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo.js 2011-08-14 04:49:01
UTC (rev 7091)
+++ portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo.js 2011-08-14 04:52:21
UTC (rev 7092)
@@ -69,34 +69,37 @@
* 3) Cache the script on the client
*
*/
-eXo.require = function(module, jsLocation) {
+eXo.require = function(module, jsLocation, callback, context, params) {
try {
- if(eval(module + ' != null')) return ;
+ if(eval(module + ' != null')) {
+ if (callback) {
+ var ctx = context ? context : {};
+ if(params && typeof(params) != "string" &&
params.length) callback.apply(ctx, params);
+ else callback.call(ctx, params) ;
+ }
+ return ;
+ }
} catch(err) {
//alert(err + " : " + module);
}
window.status = "Loading Javascript Module " + module ;
if(jsLocation == null) jsLocation = '/eXoResources/javascript/' ;
var path = jsLocation + module.replace(/\./g, '/') + '.js' ;
- eXo.loadJS(path);
+ eXo.loadJS(path, module, callback, context, params);
} ;
-eXo.loadJS = function(path) {
- var request = eXo.core.Browser.createHttpRequest() ;
- request.open('GET', path, false) ;
- request.setRequestHeader("Cache-Control", "max-age=86400") ;
-
- request.send(null) ;
+eXo.loadJS = function(path, module, callback, context, params) {
+ if (!module) module = path;
+
+ eXo.core.Loader.register(module, path);
+ eXo.core.Loader.init(module, callback, context, params);
+
eXo.session.itvDestroy() ;
if(eXo.session.canKeepState && eXo.session.isOpen &&
eXo.env.portal.accessMode == 'private') {
eXo.session.itvInit() ;
}
- try {
- eval(request.responseText) ;
- } catch(err) {
- alert(err + " : " + request.responseText) ;
- }
} ;
+
/**
* Make url portal request with parameters
*
Show replies by date