[IMP] use widget events instead of jquery events for form widget focus/blur management
bzr revid: xmo@openerp.com-20120625144013-0brsx0s4unar6cvg
This commit is contained in:
parent
6787048b80
commit
f821dd158a
|
@ -85,11 +85,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
_.each(this.get_widgets(), function(w) {
|
_.each(this.get_widgets(), function(w) {
|
||||||
// FIXME: use widget events
|
w.off('focused blurred');
|
||||||
$(w).unbind('.formBlur');
|
|
||||||
w.destroy();
|
w.destroy();
|
||||||
});
|
});
|
||||||
this.$element.unbind('.formBlur');
|
this.$element.off('.formBlur');
|
||||||
this._super();
|
this._super();
|
||||||
},
|
},
|
||||||
on_loaded: function(data) {
|
on_loaded: function(data) {
|
||||||
|
@ -111,7 +110,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
this.rendering_engine.render_to($dest);
|
this.rendering_engine.render_to($dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$element.bind('mousedown.formBlur', function () {
|
this.$element.on('mousedown.formBlur', function () {
|
||||||
self.__clicked_inside = true;
|
self.__clicked_inside = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -225,7 +224,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
// clear timeout, if any
|
// clear timeout, if any
|
||||||
this.widgetFocused();
|
this.widgetFocused();
|
||||||
this.__blur_timeout = setTimeout(function () {
|
this.__blur_timeout = setTimeout(function () {
|
||||||
$(self).trigger('form-blur');
|
self.trigger('blurred');
|
||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -914,8 +913,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
||||||
this.fields[name] = field;
|
this.fields[name] = field;
|
||||||
this.fields_order.push(name);
|
this.fields_order.push(name);
|
||||||
|
|
||||||
$(field).bind('widget-focus.formBlur', this.proxy('widgetFocused'))
|
field.on('focused', null, this.proxy('widgetFocused'))
|
||||||
.bind('widget-blur.formBlur', this.proxy('widgetBlurred'));
|
.on('blurred', null, this.proxy('widgetBlurred'));
|
||||||
if (this.get_field(name).translate) {
|
if (this.get_field(name).translate) {
|
||||||
this.translatable_fields.push(field);
|
this.translatable_fields.push(field);
|
||||||
}
|
}
|
||||||
|
@ -1523,9 +1522,9 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
|
||||||
*/
|
*/
|
||||||
setupFocus: function ($e) {
|
setupFocus: function ($e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
$e.bind({
|
$e.on({
|
||||||
focus: function () { $(self).trigger('widget-focus'); },
|
focus: function () { self.trigger('focused'); },
|
||||||
blur: function () { $(self).trigger('widget-blur'); }
|
blur: function () { self.trigger('blurred'); }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
process_modifiers: function() {
|
process_modifiers: function() {
|
||||||
|
@ -3272,7 +3271,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$(self.edition_form).bind('form-blur', function () {
|
self.edition_form.on('blurred', function () {
|
||||||
if (self.__return_blur) {
|
if (self.__return_blur) {
|
||||||
delete self.__return_blur;
|
delete self.__return_blur;
|
||||||
return;
|
return;
|
||||||
|
@ -4092,6 +4091,9 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan
|
||||||
this.selection.$element = $(".oe_form_view_reference_selection", this.$element);
|
this.selection.$element = $(".oe_form_view_reference_selection", this.$element);
|
||||||
this.selection.renderElement();
|
this.selection.renderElement();
|
||||||
this.selection.start();
|
this.selection.start();
|
||||||
|
this.selection
|
||||||
|
.on('focused', null, function () {self.trigger('focused')})
|
||||||
|
.on('blurred', null, function () {self.trigger('blurred')});
|
||||||
|
|
||||||
this.m2o = new instance.web.form.FieldMany2One(this, { attrs: {
|
this.m2o = new instance.web.form.FieldMany2One(this, { attrs: {
|
||||||
name: 'm2o'
|
name: 'm2o'
|
||||||
|
@ -4102,10 +4104,9 @@ instance.web.form.FieldReference = instance.web.form.AbstractField.extend(instan
|
||||||
this.m2o.$element = $(".oe_form_view_reference_m2o", this.$element);
|
this.m2o.$element = $(".oe_form_view_reference_m2o", this.$element);
|
||||||
this.m2o.renderElement();
|
this.m2o.renderElement();
|
||||||
this.m2o.start();
|
this.m2o.start();
|
||||||
$(this.selection).add($(this.m2o)).bind({
|
this.m2o
|
||||||
'focus': function () { $(self).trigger('widget-focus'); },
|
.on('focused', null, function () {self.trigger('focused')})
|
||||||
'blur': function () { $(self).trigger('widget-blur'); }
|
.on('blurred', null, function () {self.trigger('blurred')});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
is_false: function() {
|
is_false: function() {
|
||||||
return typeof(this.get_value()) !== 'string';
|
return typeof(this.get_value()) !== 'string';
|
||||||
|
|
Loading…
Reference in New Issue