[IMP] Improved focus. Removed delay_focus
bzr revid: fme@openerp.com-20120801164933-4nwphx7rt4l4n6ys
This commit is contained in:
parent
22cc5e45e7
commit
52de6e12a2
|
@ -669,8 +669,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
|
|||
for (var i = 0; i < fields_order.length; i += 1) {
|
||||
var field = this.fields[fields_order[i]];
|
||||
if (!field.get('effective_invisible') && !field.get('effective_readonly')) {
|
||||
console.log("trying to focus ", field.name, field);
|
||||
if (field.focus() !== false) {
|
||||
console.log("----------------- YIPEEEEEEEE");
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1976,14 +1979,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
|||
}
|
||||
},
|
||||
focus: function() {
|
||||
},
|
||||
/**
|
||||
* Utility method to focus an element, but only after a small amount of time.
|
||||
*/
|
||||
delay_focus: function($elem) {
|
||||
setTimeout(function() {
|
||||
$elem[0].focus();
|
||||
}, 50);
|
||||
return false;
|
||||
},
|
||||
/**
|
||||
* Utility method to get the widget options defined in the field xml description.
|
||||
|
@ -2082,7 +2078,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we
|
|||
return this.get('value') === '' || this._super();
|
||||
},
|
||||
focus: function() {
|
||||
this.$element.find('input:first')[0].focus();
|
||||
this.$element.find('input:first').focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2302,8 +2298,9 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc
|
|||
return this.get('value') === '' || this._super();
|
||||
},
|
||||
focus: function() {
|
||||
if (this.datewidget && this.datewidget.$input)
|
||||
this.delay_focus(this.datewidget.$input);
|
||||
if (this.datewidget && this.datewidget.$input) {
|
||||
this.datewidget.$input.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2358,7 +2355,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
|||
return this.get('value') === '' || this._super();
|
||||
},
|
||||
focus: function($element) {
|
||||
this.delay_focus(this.$textarea);
|
||||
this.$textarea.focus();
|
||||
},
|
||||
do_resize: function(max_height) {
|
||||
max_height = parseInt(max_height, 10);
|
||||
|
@ -2451,7 +2448,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({
|
|||
this.$checkbox[0].checked = value_;
|
||||
},
|
||||
focus: function() {
|
||||
this.delay_focus(this.$checkbox);
|
||||
this.$checkbox.focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2543,7 +2540,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan
|
|||
return !! value_;
|
||||
},
|
||||
focus: function() {
|
||||
this.delay_focus(this.$element.find('select:first'));
|
||||
this.$element.find('select:first').focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2933,7 +2930,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
|||
return ! this.get("value");
|
||||
},
|
||||
focus: function () {
|
||||
this.delay_focus(this.$input);
|
||||
this.$input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -4691,9 +4688,6 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
|
|||
elem.css("color", color);
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue