Module: check_mk
Branch: master
Commit: 6f26f98e10deb807c29f6678ba8c21eab41c4304
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6f26f98e10deb8…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jun 11 13:15:58 2014 +0200
fixed autoresize function of textarea valuespec
---
web/htdocs/js/checkmk.js | 43 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 213d4e5..8ce2e7e 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1662,11 +1662,46 @@ function valuespec_cascading_change(oSelect, varprefix, count) {
}
}
+function getEffectiveStyle(e, attr) {
+ if(e.style[attr]) {
+ // Object local
+ return e.style[attr];
+ } else if(document.defaultView && document.defaultView.getComputedStyle) {
+ // DOM
+ return document.defaultView.getComputedStyle(e, null).getPropertyValue(attr);
+ } else if(e.currentStyle){
+ // IE
+ var ie_attr = attr.replace(/\-(\w)/g, function (strMatch, p1){
+ return p1.toUpperCase();
+ });
+ var f = e.currentStyle[ie_attr];
+ if(f.length > 0) {
+ return f;
+ }
+ }
+ return null;
+}
+
function valuespec_textarea_resize(oArea) {
- oArea.style.height = (oArea.scrollHeight
- - (/Chrome/i.test(navigator.userAgent) ? 6 : 0)
- - (/Firefox.29.0/i.test(navigator.userAgent) ? 6 : 0)
- ) + "px";
+ var padding_top_txt = getEffectiveStyle(oArea, "padding-top");
+ var padding_bottom_txt = getEffectiveStyle(oArea, "padding-bottom");
+ var padding_top = 0;
+ var padding_bottom = 0;
+
+ if (padding_top_txt == null) {
+ // Fallback for Firefox and Chrome
+ if ((/Firefox./i.test(navigator.userAgent)) ||
(/Chrome/i.test(navigator.userAgent))) {
+ padding_top = 3;
+ padding_bottom = 3;
+ }
+ } else {
+ if (padding_top_txt.length > 2)
+ padding_top = padding_top_txt.substring(0, padding_top_txt.length - 2);
+ if (padding_bottom_txt.length > 2)
+ padding_bottom = padding_bottom_txt.substring(0, padding_bottom_txt.length -
2);
+ }
+
+ oArea.style.height = (oArea.scrollHeight - padding_top - padding_bottom) +
"px";
}