summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-04-18 14:37:04 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-04-18 14:37:04 +0200
commitc0bdcbc77802d703fd76fce3fff77ef00eeb86aa (patch)
treea95d3b815ced4ecf4f33024f72f76f0be4d5ee13 /addons/web/static
parenta2ac0de1f2869e0bf6ad591b5263924bf1715559 (diff)
[imp] removed some more methods in abstract field
bzr revid: nicolas.vanhoren@openerp.com-20120418123704-gze8svdr76x9g1l7
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/view_form.js49
1 files changed, 28 insertions, 21 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 2daec2ee8bf..f6199fc2b38 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -1628,6 +1628,7 @@ instance.web.form.FieldInterface = {
is_valid: function() {},
is_syntax_valid: function() {},
is_false: function() {},
+ focus: function() {},
};
/**
@@ -1674,7 +1675,9 @@ instance.web.form.AbstractField = instance.web.form.Widget.extend(/** @lends ins
this._super.apply(this, arguments);
if (this.field.translate) {
this.$element.addClass('oe_form_field_translatable');
- this.$element.find('.oe_field_translate').click(this.on_translate);
+ this.$element.find('.oe_field_translate').click(_.bind(function() {
+ this.field_manager.open_translate_dialog(this);
+ }, this));
}
if (instance.connection.debug) {
this.do_attach_tooltip(this, this.$element);
@@ -1692,9 +1695,6 @@ instance.web.form.AbstractField = instance.web.form.Widget.extend(/** @lends ins
this.set({'value': value_});
this._inhibit_on_change = false;
},
- on_translate: function() {
- this.field_manager.open_translate_dialog(this);
- },
get_value: function() {
return this.get('value');
},
@@ -1717,13 +1717,19 @@ instance.web.form.AbstractField = instance.web.form.Widget.extend(/** @lends ins
}
}
},
- focus: function($element) {
- if ($element) {
- setTimeout(function() {
- $element.focus();
- }, 50);
- }
+ focus: function() {
+ },
+ /**
+ * Utility method to focus an element, but only after a small amount of time.
+ */
+ delay_focus: function($elem) {
+ setTimeout(function() {
+ $elem.focus();
+ }, 50);
},
+ /**
+ * Utility method to get the widget options defined in the field xml description.
+ */
get_definition_options: function() {
if (!this.definition_options) {
var str = this.node.attrs.options || '{}';
@@ -1814,8 +1820,8 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(_.extend({}
is_false: function() {
return this.get('value') === '';
},
- focus: function($element) {
- this._super($element || this.$element.find('input:first'));
+ focus: function() {
+ this.delay_focus(this.$element.find('input:first'));
}
}));
@@ -2022,8 +2028,9 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(_.exten
is_false: function() {
return this.get('value') === '';
},
- focus: function($element) {
- this._super($element || (this.datewidget && this.datewidget.$input));
+ focus: function() {
+ if (this.datewidget && this.datewidget.$input)
+ this.delay_focus(this.datewidget.$input);
}
}));
@@ -2076,7 +2083,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(_.extend({}
return this.get('value') === '';
},
focus: function($element) {
- this._super($element || this.$textarea);
+ this.delay_focus(this.$textarea);
},
do_resize: function(max_height) {
max_height = parseInt(max_height, 10);
@@ -2118,8 +2125,8 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({
this._super.apply(this, arguments);
this.$checkbox[0].checked = value_;
},
- focus: function($element) {
- this._super($element || this.$checkbox);
+ focus: function() {
+ this.delay_focus(this.$checkbox);
}
});
@@ -2212,8 +2219,8 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(_.exte
var value_ = this.values[this.$element.find('select')[0].selectedIndex];
return !! value_;
},
- focus: function($element) {
- this._super($element || this.$element.find('select:first'));
+ focus: function() {
+ this.delay_focus(this.$element.find('select:first'));
}
}));
@@ -2557,8 +2564,8 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(_.exten
is_false: function() {
return ! this.get("value");
},
- focus: function ($element) {
- this._super($element || this.$input);
+ focus: function () {
+ this.delay_focus(this.$input);
}
}));