summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/collapse.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/misc/collapse.js b/misc/collapse.js
index 2f5c8dc06..387bf376f 100644
--- a/misc/collapse.js
+++ b/misc/collapse.js
@@ -20,6 +20,9 @@ function collapseAutoAttach() {
a.href = '#';
a.onclick = function() {
toggleClass(this.parentNode.parentNode, 'collapsed');
+ if (!hasClass(this.parentNode.parentNode, 'collapsed')) {
+ collapseScrollIntoView(this.parentNode.parentNode);
+ }
this.blur();
return false;
};
@@ -48,3 +51,16 @@ function collapseEnsureErrorsVisible(fieldset) {
}
}
}
+
+function collapseScrollIntoView(node) {
+ var h = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
+ var offset = self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
+ var pos = absolutePosition(node);
+ if (pos.y + node.scrollHeight > h + offset) {
+ if (node.scrollHeight > h) {
+ window.scrollTo(0, pos.y);
+ } else {
+ window.scrollTo(0, pos.y + node.scrollHeight - h);
+ }
+ }
+}