diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 556c715d339..20baae85d76 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -11,8 +11,8 @@ openerp.base.callback = function(obj, method) { for(var i = 0; i < callback.callback_chain.length; i++) { var c = callback.callback_chain[i]; if(c.unique) { - // al: obscure but shortening C-style hack, sorry - callback.callback_chain.pop(i--); + callback.callback_chain.splice(i, 1); + i -= 1; } r = c.callback.apply(c.self, c.args.concat(args)); // TODO special value to stop the chain @@ -284,13 +284,12 @@ openerp.base.generate_null_object_class = function(claz, add) { } if (prototype.prototype) copy_proto(prototype.prototype); - } + }; copy_proto(claz.prototype); - var init = openerp.base.BasicController.prototype.init; - newer.init = init; + newer.init = openerp.base.BasicController.prototype.init; var tmpclass = claz.extend(newer); return tmpclass.extend(add || {}); -} +}; openerp.base.Notification = openerp.base.BasicController.extend({ init: function(element_id) { @@ -580,7 +579,7 @@ openerp.base.Controller = openerp.base.BasicController.extend( /** @lends opener */ controller_get: function(key) { return this.controller_registry[key]; - // OR should contrustct it ? setting parent correctly ? + // OR should build it ? setting parent correctly ? // function construct(constructor, args) { // function F() { // return constructor.apply(this, args); @@ -640,7 +639,7 @@ openerp.base.Controller = openerp.base.BasicController.extend( /** @lends opener } // TODO if post prefix //this.element_id = _.uniqueId(_.toArray(arguments).join('_')); - }; + } }, /** * Performs a JSON-RPC call diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index e9774fe478c..6852e5595e4 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -135,7 +135,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ controller.set_embedded_view(view.embedded_view); } if (view_type === 'list' && this.flags.search_view === false && this.action && this.action['auto_search']) { - // In case the search view is not instanciated: manually call ListView#search + // In case the search view is not instantiated: manually call ListView#search var domains = !_(self.action.domain).isEmpty() ? [self.action.domain] : [], contexts = !_(self.action.context).isEmpty() @@ -356,16 +356,12 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({ }, do_refresh: function(new_view) { var view = this.view_manager.active_view; - the_condition = this.sections.length > 0 && _.detect(this.sections, + var the_condition = this.sections.length > 0 && _.detect(this.sections, function(x) {return x.elements.length > 0;}) != undefined && (!new_view || view != 'list'); - if (!the_condition) { - this.$element.addClass('closed-sidebar'); - this.$element.removeClass('open-sidebar'); - } else { - this.$element.addClass('open-sidebar'); - this.$element.removeClass('closed-sidebar'); - } + + this.$element.toggleClass('open-sidebar', the_condition) + .toggleClass('closed-sidebar', !the_condition); this.$element.html(QWeb.render("ViewManager.sidebar.internal", { sidebar: this, view: view }));