[IMP] web_preload js part
authorAntony Lesuisse <al@openerp.com>
Tue, 27 Sep 2011 11:14:02 +0000 (13:14 +0200)
committerAntony Lesuisse <al@openerp.com>
Tue, 27 Sep 2011 11:14:02 +0000 (13:14 +0200)
bzr revid: al@openerp.com-20110927111402-teb8bpavj4atghle

addons/web/controllers/main.py
addons/web/static/src/js/boot.js
addons/web_hello/__openerp__.py
addons/web_hello/static/openerp/base_hello.js

index c45bf99..ead27b2 100644 (file)
@@ -119,7 +119,7 @@ home_template = textwrap.dedent("""<!DOCTYPE html>
         %(javascript)s
         <script type="text/javascript">
             $(function() {
-                var c = new openerp.init();
+                var c = new openerp.init(%(modules)s);
                 var wc = new c.web.WebClient("oe");
                 wc.start();
             });
@@ -166,9 +166,11 @@ class WebClient(openerpweb.Controller):
         if req.debug:
             csslist = [i + '?debug=' + str(time.time()) for i in manifest_glob(None, 'css')]
         css = "\n        ".join(['<link rel="stylesheet" href="%s">'%i for i in csslist])
+
         r = home_template % {
             'javascript': js,
-            'css': css
+            'css': css,
+            'modules': simplejson.dumps(manifest_preload()),
         }
         return r
 
index 10c8de0..f41185b 100644 (file)
@@ -19,9 +19,9 @@
         /**
          * OpenERP instance constructor
          *
-         * @param {Boolean} skip_init if true, skips the built-in initialization
+         * @param {Array} modules list of modules to initialize
          */
-        init: function(skip_init) {
+        init: function(modules) {
             var new_instance = {
                 // links to the global openerp
                 _openerp: openerp,
@@ -35,8 +35,9 @@
                 web_mobile: {}
             };
             openerp.sessions[new_instance._session_id] = new_instance;
-            if (!skip_init){
-                openerp.web(new_instance);
+            modules = modules || ["web"];
+            for(var i=0; i < modules.length; i++) {
+                openerp[modules[i]](new_instance);
             }
             return new_instance;
         }
index 7a80645..40e84db 100644 (file)
@@ -5,4 +5,5 @@
     "js": ["static/*/*.js", "static/*/js/*.js"],
     "css": [],
     'active': False,
+    'web_preload': True,
 }
index 99c9700..91caf26 100644 (file)
@@ -13,6 +13,13 @@ openerp.web.SearchView = openerp.web.SearchView.extend({
 
 // here you may tweak globals object, if any, and play with on_* or do_* callbacks on them
 
+openerp.web.Login = openerp.web.Login.extend({
+    start: function() {
+        console.log('Hello there');
+        this._super.apply(this,arguments);
+    }
+});
+
 };
 
 // vim:et fdc=0 fdl=0: