[ADD] Added autosize functionality for textarea
bzr revid: bde@tinyerp.com-20120821101632-gx3nu1xpfv3si1la
This commit is contained in:
parent
0404db7742
commit
2d7817bbe5
|
@ -38,6 +38,7 @@ This module provides the core of the OpenERP Web Client.
|
||||||
"static/lib/backbone/backbone.js",
|
"static/lib/backbone/backbone.js",
|
||||||
"static/lib/cleditor/jquery.cleditor.js",
|
"static/lib/cleditor/jquery.cleditor.js",
|
||||||
"static/lib/py.js/lib/py.js",
|
"static/lib/py.js/lib/py.js",
|
||||||
|
"static/lib/jquery.autosize/jquery.autosize.js",
|
||||||
"static/src/js/boot.js",
|
"static/src/js/boot.js",
|
||||||
"static/src/js/corelib.js",
|
"static/src/js/corelib.js",
|
||||||
"static/src/js/coresetup.js",
|
"static/src/js/coresetup.js",
|
||||||
|
|
|
@ -2342,8 +2342,8 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
var show_value = instance.web.format_value(this.get('value'), this, '');
|
var show_value = instance.web.format_value(this.get('value'), this, '');
|
||||||
this.$textarea.val(show_value);
|
this.$textarea.val(show_value);
|
||||||
if (show_value && this.view.options.resize_textareas) {
|
if (show_value) {
|
||||||
this.do_resize(this.view.options.resize_textareas);
|
this.$textarea.autosize();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
is_syntax_valid: function() {
|
is_syntax_valid: function() {
|
||||||
|
@ -2363,26 +2363,6 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
|
||||||
focus: function($element) {
|
focus: function($element) {
|
||||||
this.$textarea.focus();
|
this.$textarea.focus();
|
||||||
},
|
},
|
||||||
do_resize: function(max_height) {
|
|
||||||
max_height = parseInt(max_height, 10);
|
|
||||||
var $input = this.$textarea,
|
|
||||||
$div = $('<div style="position: absolute; z-index: 1000; top: 0"/>').width($input.width()),
|
|
||||||
new_height;
|
|
||||||
$div.text($input.val());
|
|
||||||
_.each('font-family,font-size,white-space'.split(','), function(style) {
|
|
||||||
$div.css(style, $input.css(style));
|
|
||||||
});
|
|
||||||
$div.appendTo($('body'));
|
|
||||||
new_height = $div.height();
|
|
||||||
if (new_height < 90) {
|
|
||||||
new_height = 90;
|
|
||||||
}
|
|
||||||
if (!isNaN(max_height) && new_height > max_height) {
|
|
||||||
new_height = max_height;
|
|
||||||
}
|
|
||||||
$div.remove();
|
|
||||||
$input.height(new_height);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2407,7 +2387,7 @@ instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instanc
|
||||||
self._updating_editor = false;
|
self._updating_editor = false;
|
||||||
this.$textarea = this.$element.find('textarea');
|
this.$textarea = this.$element.find('textarea');
|
||||||
var width = ((this.node.attrs || {}).editor_width || 468);
|
var width = ((this.node.attrs || {}).editor_width || 468);
|
||||||
var height = ((this.node.attrs || {}).editor_height || 100);
|
var height = ((this.node.attrs || {}).editor_height || 250);
|
||||||
this.$textarea.cleditor({
|
this.$textarea.cleditor({
|
||||||
width: width, // width not including margins, borders or padding
|
width: width, // width not including margins, borders or padding
|
||||||
height: height, // height not including margins, borders or padding
|
height: height, // height not including margins, borders or padding
|
||||||
|
|
Loading…
Reference in New Issue