From 278955b20741283746914d9633075a831db890f1 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 20 Oct 2011 11:16:19 +0200 Subject: [ADD] Web client now support template translations bzr revid: fme@openerp.com-20111020091619-1i2nhopdgszsy48q --- addons/web/static/src/js/core.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 8dfbd68e6de..21a4ca21931 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -10,8 +10,6 @@ if (!console.debug) { } openerp.web.core = function(openerp) { -openerp.web.qweb = new QWeb2.Engine(); -openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); /** * John Resig Class with factory improvement */ @@ -1040,6 +1038,21 @@ openerp.web.TranslationDataBase = openerp.web.Class.extend(/** @lends openerp.we }); openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function(); +openerp.web.qweb = new QWeb2.Engine(); +openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); +openerp.web.qweb.format_text_node = function(s) { + // Note that 'this' is the Qweb Node of the text + var translation = this.node.parentElement.attributes['t-translation']; + if (translation && translation.value === 'off') { + return s; + } + var ts = _.trim(s); + if (ts.length === 0) { + return s; + } + var tr = openerp.web._t(ts); + return tr === ts ? s : tr; +} }; -- cgit v1.2.3 From e1e7cadedecb59fb3855ce3b1ee9c85526e3b51e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 20 Oct 2011 17:05:40 +0200 Subject: [FIX] cookies handling in openerp Session, js-side bzr revid: xmo@openerp.com-20111020150540-ms0sdzd5qi6pz38o --- addons/web/static/src/js/core.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 21a4ca21931..4ed33341ea6 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -361,6 +361,9 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web this.context = {}; this.shortcuts = []; this.active_id = null; + // TODO: session should have an optional name indicating that they'll + // be saved to (and revived from) cookies + this.name = 'session'; }, start: function() { this.session_restore(); @@ -525,7 +528,8 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web * @param name the cookie's name */ get_cookie: function (name) { - var nameEQ = this.element_id + '|' + name + '='; + if (!this.name) { return null; } + var nameEQ = this.name + '|' + name + '='; var cookies = document.cookie.split(';'); for(var i=0; i Date: Mon, 24 Oct 2011 11:21:40 +0200 Subject: [FIX] Do not use node.parentElement (sorry all) lp bug: https://launchpad.net/bugs/879797 fixed bzr revid: fme@openerp.com-20111024092140-zvrtzmy9cppjyaj2 --- addons/web/static/src/js/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 4ed33341ea6..39a1ba7ef64 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -1048,7 +1048,7 @@ openerp.web.qweb = new QWeb2.Engine(); openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); openerp.web.qweb.format_text_node = function(s) { // Note that 'this' is the Qweb Node of the text - var translation = this.node.parentElement.attributes['t-translation']; + var translation = this.node.parentNode.attributes['t-translation']; if (translation && translation.value === 'off') { return s; } -- cgit v1.2.3