From 2f0e54db9d9419972d50ccfed94a46a35ed0f993 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 19 Aug 2013 14:24:59 +0200 Subject: [PATCH] Now has a good amd wrapper for qweb bzr revid: nicolas.vanhoren@openerp.com-20130819122459-45alsxp7m8zphc6v --- addons/im_livechat/loader.js | 9 ++++++++- addons/im_livechat/static/ext/static/js/to_jsonp.py | 12 ------------ .../im_livechat/static/ext/static/lib/qweb/qweb2.js | 7 +++++++ 3 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 addons/im_livechat/static/ext/static/js/to_jsonp.py diff --git a/addons/im_livechat/loader.js b/addons/im_livechat/loader.js index 4fe90110846..e5ea5b2c4f5 100644 --- a/addons/im_livechat/loader.js +++ b/addons/im_livechat/loader.js @@ -1,4 +1,8 @@ +(function() { + +var tmpQWeb2 = window.QWeb2; + require.config({ context: "oelivesupport", baseUrl: {{url | json}}, @@ -18,7 +22,8 @@ require.config({ }, qweb2: { init: function() { - // TODO: better solution to avoid contamination of global namespace + var QWeb2 = window.QWeb2; + window.QWeb2 = tmpQWeb2; return QWeb2; }, }, @@ -37,3 +42,5 @@ require.config({ userName: {{userName | json}} || undefined, }); }); + +})(); diff --git a/addons/im_livechat/static/ext/static/js/to_jsonp.py b/addons/im_livechat/static/ext/static/js/to_jsonp.py deleted file mode 100644 index 61f1a885768..00000000000 --- a/addons/im_livechat/static/ext/static/js/to_jsonp.py +++ /dev/null @@ -1,12 +0,0 @@ - -import sys -import json - -file_name = sys.argv[1] -function_name = sys.argv[2] - -with open(file_name) as file_: - content = file_.read() - -print "window.%s(%s);" % (function_name, json.dumps(content)) - diff --git a/addons/im_livechat/static/ext/static/lib/qweb/qweb2.js b/addons/im_livechat/static/ext/static/lib/qweb/qweb2.js index 52e975322e5..0c4b59cd377 100644 --- a/addons/im_livechat/static/ext/static/lib/qweb/qweb2.js +++ b/addons/im_livechat/static/ext/static/lib/qweb/qweb2.js @@ -25,6 +25,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // TODO: line number -> https://bugzilla.mozilla.org/show_bug.cgi?id=618650 // TODO: templates orverwritten could be called by t-call="__super__" ? // TODO: t-set + t-value + children node == scoped variable ? + +(function() { + var QWeb2 = { expressions_cache: {}, RESERVED_WORDS: 'true,false,NaN,null,undefined,debugger,console,window,in,instanceof,new,function,return,this,typeof,eval,void,Math,RegExp,Array,Object,Date'.split(','), @@ -727,3 +730,7 @@ QWeb2.Element = (function() { }); return Element; })(); + +window.QWeb2 = QWeb2; + +})();