[IMP] add overridable dimension-setting method on form fields

bzr revid: xmo@openerp.com-20121018145712-am4y6bdnz2x14i2c
This commit is contained in:
Xavier Morel 2012-10-18 16:57:12 +02:00
parent 6782c33a32
commit 4223b1e786
2 changed files with 22 additions and 3 deletions

View File

@ -2143,6 +2143,20 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
self.do_action(r);
});
},
set_dimensions: function (height, width) {
// remove width css property
this.$el.css('width', '');
// extract style (without width)
var old_style = this.$el.attr('style');
// jQuery doesn't understand/use !important
var style = 'width:' + width + 'px !important;';
if (old_style) {
style += old_style
}
this.$el.attr('style', style);
this.$el.css('minHeight', height);
}
});
/**
@ -2521,6 +2535,13 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
focus: function($el) {
this.$textarea.focus();
},
set_dimensions: function (height, width) {
this._super();
this.$textarea.css({
width: width,
minHeight: height
});
},
});
/**

View File

@ -251,12 +251,10 @@ openerp.web.list_editable = function (instance) {
var $cell = $(cell);
var position = $cell.position();
// jquery does not understand !important
field.$el.attr('style', 'width: '+$cell.outerWidth()+'px !important');
field.set_dimensions($cell.outerHeight(), $cell.outerWidth());
field.$el.css({
top: position.top,
left: position.left,
minHeight: $cell.outerHeight()
});
},
/**