Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scroll fields from added hetero-list entry into viewport #9488

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2242,14 +2242,13 @@ function getStyle(e, a) {
*/
// eslint-disable-next-line no-unused-vars
function ensureVisible(e) {
var viewport = YAHOO.util.Dom.getClientRegion();
var pos = YAHOO.util.Dom.getRegion(e);

var Y = viewport.top;
var H = viewport.height;
const scrollTop = document.documentElement.scrollTop;
let Y = scrollTop;
let H = window.innerHeight;
let c = 0;

function handleStickers(name, f) {
var e = document.getElementById(name);
const e = document.getElementById(name);
if (e) {
f(e);
}
Expand All @@ -2261,24 +2260,23 @@ function ensureVisible(e) {
t = t.clientHeight;
Y += t;
H -= t;
c += t;
});

handleStickers("bottom-sticker", function (b) {
b = b.clientHeight;
H -= b;
});

var y = pos.top;
var h = pos.height;
const box = e.getBoundingClientRect();
const y = Math.round(box.top + scrollTop);
const h = e.offsetHeight;
const d = y + h - (Y + H);

var d = y + h - (Y + H);
if (d > 0) {
document.body.scrollTop += d;
} else {
d = Y - y;
if (d > 0) {
document.body.scrollTop -= d;
}
if (h > H) {
document.documentElement.scrollTop = y - c;
} else if (d > 0) {
document.documentElement.scrollTop += d;
}
}

Expand Down
Loading