From 12ce7180882bb6aedc97ff6f1f17b0b5ea4c1929 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 12 Dec 2011 17:44:55 +0100 Subject: [IMP] limit the hash managment to the actionmanager of the webclient (and its viewmanager and views) bzr revid: chs@openerp.com-20111212164455-44l31w1jr1sm2mg0 --- addons/web/static/src/js/chrome.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'addons/web/static/src/js/chrome.js') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index cf7b9d305c1..0e332252341 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1047,54 +1047,50 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie if(this.action_manager) this.action_manager.stop(); this.action_manager = new openerp.web.ActionManager(this); + this.action_manager.do_push_state.add(this.do_push_state); this.action_manager.appendTo($("#oe_app")); if (openerp._modules_loaded) { // TODO: find better option than this - this.bind_statechange(); + this.bind_hashchange(); } else { this.session.on_modules_loaded.add({ // XXX what about a $.Deferred ? - callback: $.proxy(this, 'bind_statechange'), + callback: $.proxy(this, 'bind_hashchange'), unique: true, position: 'last' }) } }, - state_change_event: 'hashchange', - - bind_statechange: function() { - $(window).bind(this.state_change_event, this.on_state_change); + bind_hashchange: function() { + $(window).bind('hashchange', this.on_hashchange); var state = $.bbq.getState(true); if (! _.isEmpty(state)) { - $(window).trigger(this.state_change_event); + $(window).trigger('hashchange'); } else { this.action_manager.do_action({type: 'ir.actions.client', tag: 'default_home'}); } }, on_logged_out: function() { + $(window).unbind('hashchange', this.on_hashchange); if(this.action_manager) this.action_manager.stop(); this.action_manager = null; - $(window).unbind(this.state_change_event, this.on_state_change); }, - on_state_change: function(event) { - // as this method is bound to a event via jQuery, the argument is the jQuery Event.. we need to get the current state - var state = event.getState(true); // = bbq.getState, in fact only deparam the hash - return this._super(state); + on_hashchange: function(event) { + var state = event.getState(true); + this.action_manager.do_load_state(state); }, - - - do_push_state: function(state, extend) { - if (extend) { + do_push_state: function(state, overwrite) { + if (!overwrite) { var hash = $.deparam.fragment(true); state = _.extend({}, hash, state); } var url = '#' + $.param(state); - $.bbq.pushState(url); // will set the hash, so will call on_state_change + $.bbq.pushState(url); }, default_home: function () { -- cgit v1.2.3