- #39674: Scroll fieldsets into view when expanding them
parent
dbdca484c1
commit
d67a050347
|
|
@ -20,6 +20,9 @@ function collapseAutoAttach() {
|
||||||
a.href = '#';
|
a.href = '#';
|
||||||
a.onclick = function() {
|
a.onclick = function() {
|
||||||
toggleClass(this.parentNode.parentNode, 'collapsed');
|
toggleClass(this.parentNode.parentNode, 'collapsed');
|
||||||
|
if (!hasClass(this.parentNode.parentNode, 'collapsed')) {
|
||||||
|
collapseScrollIntoView(this.parentNode.parentNode);
|
||||||
|
}
|
||||||
this.blur();
|
this.blur();
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue