From aa887ed02ce864cd1036f39f7bc6b984b60578d0 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 29 Jul 2015 09:11:53 +0200 Subject: [FIX] web,mail: widgets: replace $el.toggle() by do_toggle() Since rev. 16eb36ff, do_show() and do_hide() on widgets toggle the classname o_hidden on which the rule 'display: none' is defined, instead of calling jQuery's show() and hide(). The method do_toggle(), sharing the same logic, has been introduced in rev. 74c5f772. From now on, every widgets should call do_toggle() instead of $el.toggle() as it will have undesiderable effects (they should call do_show() and do_hide() instead of $el.show() and $el.hide() as well, this as been done in 16eb36ff). This rev. replaces all calls to $el.toggle() by do_toggle(). It also adds an optional argument to do_toggle() to force hidding or showing the widget. --- addons/web/static/src/js/framework/widget.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/framework') diff --git a/addons/web/static/src/js/framework/widget.js b/addons/web/static/src/js/framework/widget.js index 6dbb1294ee7..3a90e432000 100644 --- a/addons/web/static/src/js/framework/widget.js +++ b/addons/web/static/src/js/framework/widget.js @@ -346,17 +346,27 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, { return this.$el; return this.$el.find(selector); }, + /** + * Displays the widget + */ do_show: function () { this.$el.removeClass('o_hidden'); }, + /** + * Hides the widget + */ do_hide: function () { this.$el.addClass('o_hidden'); }, - do_toggle: function () { - if (this.$el.hasClass('o_hidden')) { - this.do_show(); + /** + * Displays or hides the widget + * @param {Boolean} [display] use true to show the widget or false to hide it + */ + do_toggle: function (display) { + if (_.isBoolean(display)) { + display ? this.do_show() : this.do_hide(); } else { - this.do_hide(); + this.$el.hasClass('o_hidden') ? this.do_show() : this.do_hide(); } }, /** -- cgit v1.2.3