Restream / redmine_simple

Simplify redmine interface
Apache License 2.0
13 stars 6 forks source link

min value of adaptiveHeight of description is not actual used #4

Closed jcppkkk closed 9 years ago

jcppkkk commented 9 years ago

hi @nodecarter https://github.com/Undev/redmine_simple/blob/master/assets/javascripts/simplify_description.js#L1 When adjusting description text area, the min parameter in adaptiveHeight seems not actually setting minimal height. What's the intention of function adaptiveHeight ?

nodecarter commented 9 years ago

Hi @jcppkkk Without this adjustment the height of description textarea in simple mode can be too big or too small. http://goo.gl/lHGl1L

jcppkkk commented 9 years ago

However it resizes my description's height to one line height: image I think the flow in original code will

So i decide to modify code. The result is following image image

diff --git a/assets/javascripts/simplify_description.js b/assets/javascripts/simplify_description.js
index d4e15c2..a6e416e 100644
--- a/assets/javascripts/simplify_description.js
+++ b/assets/javascripts/simplify_description.js
@@ -1,11 +1,11 @@
 function adaptiveHeight(a, min, max) {
-  if ($(a).height() > min) {
-    $(a).height(0);
-    var newHeight = Math.min($(a)[0].scrollHeight, max);
-    $(a).height(newHeight);
-    if (parseInt(a.style.height) > $(window).height() - 30) {
-      $(document).scrollTop(parseInt(a.style.height));
-    }
+  scrollHeight = $(a)[0].scrollHeight
+  if (scrollHeight < min) {
+    $(a).height(min);
+  } else if(scrollHeight > max) {
+    $(a).height(max);
+  } else {
+    $(a).height(scrollHeight);
   }
 }
nodecarter commented 9 years ago

Thanks @jcppkkk. I have fixed too small height bug.