[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.
This commit is contained in:
Aaron Bohy
2015-07-29 14:36:03 +02:00
parent 51952f3033
commit aa887ed02c
8 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ var TimelineRecordThread = form_common.AbstractField.extend ({
},
_check_visibility: function () {
this.$el.toggle(this.view.get("actual_mode") !== "create");
this.do_toggle(this.view.get("actual_mode") !== "create");
},
render_value: function () {
-1
View File
@@ -1111,7 +1111,6 @@
.openerp .oe_searchview {
cursor: text;
position: relative;
display: none;
height: auto;
padding-top: 1px;
padding-bottom: 1px;
-1
View File
@@ -963,7 +963,6 @@ $sheet-padding: 16px
.oe_searchview
cursor: text
position: relative
display: none
height: auto
padding-top: 1px
padding-bottom: 1px
+1 -1
View File
@@ -131,7 +131,7 @@ var ControlPanel = Widget.extend({
* @param {Boolean} [visible] true to show the control panel, false to hide it
*/
_toggle_visibility: function(visible) {
this.$el.toggle(visible);
this.do_toggle(visible);
if (!visible && !this.$content) {
this.$content = this.$el.contents().detach();
} else if (this.$content) {
+14 -4
View File
@@ -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();
}
},
/**
+1 -2
View File
@@ -270,9 +270,8 @@ var FormView = View.extend(common.FieldManagerMixin, {
* Show or hide the sidebar according to the actual_mode
*/
toggle_sidebar: function() {
var view_mode = this.get("actual_mode") === "view";
if (this.sidebar) {
this.sidebar.$el.toggle(view_mode);
this.sidebar.do_toggle(this.get("actual_mode") === "view");
}
},
widgetFocused: function() {
@@ -1069,7 +1069,7 @@ var FieldReference = common.AbstractField.extend(common.ReinitializeFieldMixin,
}
this.m2o.field.relation = this.get('value')[0];
this.m2o.set_value(this.get('value')[1]);
this.m2o.$el.toggle(!!this.get('value')[0]);
this.m2o.do_toggle(!!this.get('value')[0]);
this.reference_ready = true;
},
});
@@ -510,7 +510,7 @@ var SearchView = Widget.extend(/** @lends instance.web.SearchView# */{
};
},
toggle_visibility: function (is_visible) {
this.$el.toggle(!this.headless && is_visible);
this.do_toggle(!this.headless && is_visible);
if (this.$buttons) {
this.$buttons.toggle(!this.headless && is_visible && this.visible_filters);
}