Victor Tabuenca has proposed merging
lp:~openerp-dev/openerp-web/trunk-autosize-textarea-pso into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-autosize-textarea-pso/+merge/121996
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-autosize-textarea-pso/+merge/121996
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-autosize-textarea-pso.
=== modified file 'addons/web/__openerp__.py'
--- addons/web/__openerp__.py 2012-08-22 13:03:36 +0000
+++ addons/web/__openerp__.py 2012-08-30 07:09:18 +0000
@@ -12,6 +12,62 @@
'auto_install': True,
'post_load': 'wsgi_postload',
'js' : [
+ "static/lib/datejs/globalization/en-US.js",
+ "static/lib/datejs/core.js",
+ "static/lib/datejs/parser.js",
+ "static/lib/datejs/sugarpak.js",
+ "static/lib/datejs/extras.js",
+ "static/lib/jquery/jquery-1.7.2.js",
+ "static/lib/jquery.MD5/jquery.md5.js",
+ "static/lib/jquery.form/jquery.form.js",
+ "static/lib/jquery.validate/jquery.validate.js",
+ "static/lib/jquery.ba-bbq/jquery.ba-bbq.js",
+ "static/lib/spinjs/spin.js",
+ "static/lib/jquery.blockUI/jquery.blockUI.js",
+ "static/lib/jquery.ui/js/jquery-ui-1.8.17.custom.min.js",
+ "static/lib/jquery.ui.timepicker/js/jquery-ui-timepicker-addon.js",
+ "static/lib/jquery.ui.notify/js/jquery.notify.js",
+ "static/lib/jquery.deferred-queue/jquery.deferred-queue.js",
+ "static/lib/jquery.scrollTo/jquery.scrollTo-min.js",
+ "static/lib/jquery.tipsy/jquery.tipsy.js",
+ "static/lib/jquery.textext/jquery.textext.js",
+ "static/lib/jquery.timeago/jquery.timeago.js",
+ "static/lib/qweb/qweb2.js",
+ "static/lib/underscore/underscore.js",
+ "static/lib/underscore/underscore.string.js",
+ "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",
+ "static/src/js/dates.js",
+ "static/src/js/formats.js",
+ "static/src/js/chrome.js",
+ "static/src/js/views.js",
+ "static/src/js/data.js",
+ "static/src/js/data_export.js",
+ "static/src/js/data_import.js",
+ "static/src/js/search.js",
+ "static/src/js/view_form.js",
+ "static/src/js/view_list.js",
+ "static/src/js/view_list_editable.js",
+ "static/src/js/view_tree.js",
+ ],
+ 'css' : [
+ "static/lib/jquery.ui.bootstrap/css/custom-theme/jquery-ui-1.8.16.custom.css",
+ "static/lib/jquery.ui.timepicker/css/jquery-ui-timepicker-addon.css",
+ "static/lib/jquery.ui.notify/css/ui.notify.css",
+ "static/lib/jquery.tipsy/tipsy.css",
+ "static/lib/jquery.textext/jquery.textext.css",
+ "static/src/css/base.css",
+ "static/src/css/data_export.css",
+ "static/src/css/data_import.css",
+ "static/lib/cleditor/jquery.cleditor.css",
+ ],
+ 'qweb' : [
+ "static/src/xml/*.xml",
'static/lib/datejs/globalization/en-US.js',
'static/lib/datejs/core.js',
'static/lib/datejs/parser.js',
=== added directory 'addons/web/static/lib/jquery.autosize'
=== added file 'addons/web/static/lib/jquery.autosize/jquery.autosize.js'
--- addons/web/static/lib/jquery.autosize/jquery.autosize.js 1970-01-01 00:00:00 +0000
+++ addons/web/static/lib/jquery.autosize/jquery.autosize.js 2012-08-30 07:09:18 +0000
@@ -0,0 +1,160 @@
+// Autosize 1.10 - jQuery plugin for textareas
+// (c) 2012 Jack Moore - jacklmoore.com
+// license: www.opensource.org/licenses/mit-license.php
+
+(function ($) {
+ var
+ hidden = 'hidden',
+ borderBox = 'border-box',
+ lineHeight = 'lineHeight',
+ copy = '<textarea tabindex="-1" style="position:absolute; top:-9999px; left:-9999px; right:auto; bottom:auto; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden">',
+ // line-height is omitted because IE7/IE8 doesn't return the correct value.
+ copyStyle = [
+ 'fontFamily',
+ 'fontSize',
+ 'fontWeight',
+ 'fontStyle',
+ 'letterSpacing',
+ 'textTransform',
+ 'wordSpacing',
+ 'textIndent'
+ ],
+ oninput = 'oninput',
+ onpropertychange = 'onpropertychange',
+ test = $(copy)[0];
+
+ // For testing support in old FireFox
+ test.setAttribute(oninput, "return");
+
+ if ($.isFunction(test[oninput]) || onpropertychange in test) {
+
+ // test that line-height can be accurately copied to avoid
+ // incorrect value reporting in old IE and old Opera
+ $(test).css(lineHeight, '99px');
+ if ($(test).css(lineHeight) === '99px') {
+ copyStyle.push(lineHeight);
+ }
+
+ $.fn.autosize = function (className) {
+ return this.each(function () {
+ var
+ ta = this,
+ $ta = $(ta),
+ mirror,
+ minHeight = $ta.height(),
+ maxHeight = parseInt($ta.css('maxHeight'), 10),
+ active,
+ i = copyStyle.length,
+ resize,
+ boxOffset = 0;
+
+ if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox){
+ boxOffset = $ta.outerHeight() - $ta.height();
+ }
+
+ if ($ta.data('mirror') || $ta.data('ismirror')) {
+ // if autosize has already been applied, exit.
+ // if autosize is being applied to a mirror element, exit.
+ return;
+ } else {
+ mirror = $(copy).data('ismirror', true).addClass(className || 'autosizejs')[0];
+
+ resize = $ta.css('resize') === 'none' ? 'none' : 'horizontal';
+
+ $ta.data('mirror', $(mirror)).css({
+ overflow: hidden,
+ overflowY: hidden,
+ wordWrap: 'break-word',
+ resize: resize
+ });
+ }
+
+ // Opera returns '-1px' when max-height is set to 'none'.
+ maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4;
+
+ // Using mainly bare JS in this function because it is going
+ // to fire very often while typing, and needs to very efficient.
+ function adjust() {
+ var height, overflow;
+ // the active flag keeps IE from tripping all over itself. Otherwise
+ // actions in the adjust function will cause IE to call adjust again.
+ if (!active) {
+ active = true;
+
+ mirror.value = ta.value;
+
+ mirror.style.overflowY = ta.style.overflowY;
+
+ // Update the width in case the original textarea width has changed
+ mirror.style.width = $ta.css('width');
+
+ // Needed for IE to reliably return the correct scrollHeight
+ mirror.scrollTop = 0;
+
+ // Set a very high value for scrollTop to be sure the
+ // mirror is scrolled all the way to the bottom.
+ mirror.scrollTop = 9e4;
+
+ height = mirror.scrollTop;
+ overflow = hidden;
+ if (height > maxHeight) {
+ height = maxHeight;
+ overflow = 'scroll';
+ } else if (height < minHeight) {
+ height = minHeight;
+ }
+ ta.style.overflowY = overflow;
+
+ ta.style.height = height + boxOffset + 'px';
+
+ // This small timeout gives IE a chance to draw it's scrollbar
+ // before adjust can be run again (prevents an infinite loop).
+ setTimeout(function () {
+ active = false;
+ }, 1);
+ }
+ }
+
+ // mirror is a duplicate textarea located off-screen that
+ // is automatically updated to contain the same text as the
+ // original textarea. mirror always has a height of 0.
+ // This gives a cross-browser supported way getting the actual
+ // height of the text, through the scrollTop property.
+ while (i--) {
+ mirror.style[copyStyle[i]] = $ta.css(copyStyle[i]);
+ }
+
+ $('body').append(mirror);
+
+ if (onpropertychange in ta) {
+ if (oninput in ta) {
+ // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
+ // so binding to onkeyup to catch most of those occassions. There is no way that I
+ // know of to detect something like 'cut' in IE9.
+ ta[oninput] = ta.onkeyup = adjust;
+ } else {
+ // IE7 / IE8
+ ta[onpropertychange] = adjust;
+ }
+ } else {
+ // Modern Browsers
+ ta[oninput] = adjust;
+ }
+
+ $(window).resize(adjust);
+
+ // Allow for manual triggering if needed.
+ $ta.bind('autosize', adjust);
+
+ // Call adjust in case the textarea already contains text.
+ adjust();
+ });
+ };
+ } else {
+ // Makes no changes for older browsers (FireFox3- and Safari4-)
+ $.fn.autosize = function () {
+ return this;
+ };
+ }
+
+}(jQuery));
\ No newline at end of file
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-08-29 15:37:56 +0000
+++ addons/web/static/src/js/view_form.js 2012-08-30 07:09:18 +0000
@@ -2345,8 +2345,8 @@
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() {
@@ -2366,26 +2366,6 @@
focus: function($el) {
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);
- },
});
/**
@@ -2410,7 +2390,7 @@
self._updating_editor = false;
this.$textarea = this.$el.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
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp