- #39674: Scroll fieldsets into view when expanding them

4.7.x
Steven Wittens 2006-02-07 02:29:06 +00:00
parent dbdca484c1
commit d67a050347
1 changed files with 16 additions and 0 deletions

View File

@ -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);
}
}
}