summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorDenis Vermylen (dve) <dve@odoo.com>2016-08-24 17:14:41 +0200
committerDenis Vermylen (dve) <dve@odoo.com>2016-08-31 17:17:37 +0200
commitfbe3608c7e9ceeaeb4d1204ec8193ad6aaa4d0f0 (patch)
treebc38fcd75fb7c50806c3fe497710a1c7002dcc36 /addons/web/static/src/js/framework
parent275ee5825d38841a3eb21bb195722f3ceed09005 (diff)
[FIX] web: avoid autoresize duplicates
In web_planner, changing pages would take more and more time after a few clicks if autoresize was called on textareas. Every time we would change page, autoresize was called on all textareas and added an additional textarea for each one, doubling the amount on each page change. The autoresize function in dom_utils was checking too shallowly for duplicates and created a new textarea where autoresize would again be called upon on a later stage. This commit fixes both problems.
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/dom_utils.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/addons/web/static/src/js/framework/dom_utils.js b/addons/web/static/src/js/framework/dom_utils.js
index 63a5c25a3d2..d0beff2988b 100644
--- a/addons/web/static/src/js/framework/dom_utils.js
+++ b/addons/web/static/src/js/framework/dom_utils.js
@@ -11,6 +11,9 @@ var core = require('web.core');
* not in the dom when the autoresize is declared.
*/
function autoresize ($textarea, options) {
+ if ($textarea.data("auto_resize")) {
+ return;
+ }
options = options || {};
var $fixed_text_area;
@@ -25,6 +28,7 @@ function autoresize ($textarea, options) {
});
$fixed_text_area.addClass($textarea[0].className);
$fixed_text_area.insertAfter($textarea);
+ $fixed_text_area.data("auto_resize", true);
}
var style = window.getComputedStyle($textarea[0], null);
@@ -34,10 +38,7 @@ function autoresize ($textarea, options) {
$textarea[0].style.resize = 'horizontal';
}
resize();
- if ($textarea.__auto_resized) {
- return;
- }
- $textarea.__auto_resized = true;
+ $textarea.data("auto_resize", true);
$textarea.on('input focus', resize);
if (options.parent) {