From 2d7817bbe57ae4e7c701279af2d595ad5501f09d Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Tue, 21 Aug 2012 15:46:32 +0530 Subject: [PATCH] [ADD] Added autosize functionality for textarea bzr revid: bde@tinyerp.com-20120821101632-gx3nu1xpfv3si1la --- addons/web/__openerp__.py | 1 + addons/web/static/src/js/view_form.js | 26 +++----------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/addons/web/__openerp__.py b/addons/web/__openerp__.py index 822d2fa3cbf..8c2a8fa0909 100644 --- a/addons/web/__openerp__.py +++ b/addons/web/__openerp__.py @@ -38,6 +38,7 @@ This module provides the core of the OpenERP Web Client. "static/lib/backbone/backbone.js", "static/lib/cleditor/jquery.cleditor.js", "static/lib/py.js/lib/py.js", + "static/lib/jquery.autosize/jquery.autosize.js", "static/src/js/boot.js", "static/src/js/corelib.js", "static/src/js/coresetup.js", diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4f3f1c62f13..3efee9a140f 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2342,8 +2342,8 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we render_value: function() { var show_value = instance.web.format_value(this.get('value'), this, ''); this.$textarea.val(show_value); - if (show_value && this.view.options.resize_textareas) { - this.do_resize(this.view.options.resize_textareas); + if (show_value) { + this.$textarea.autosize(); } }, is_syntax_valid: function() { @@ -2363,26 +2363,6 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we focus: function($element) { this.$textarea.focus(); }, - do_resize: function(max_height) { - max_height = parseInt(max_height, 10); - var $input = this.$textarea, - $div = $('
').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; this.$textarea = this.$element.find('textarea'); 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({ width: width, // width not including margins, borders or padding height: height, // height not including margins, borders or padding