Skip to content

Commit db853fa

Browse files
notriddleJoshua Nelson
authored and
Joshua Nelson
committed
Scope page up and page down to a particular menu section
1 parent f118771 commit db853fa

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

static/menu.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,22 @@
188188
// page up: jump five items up, stopping at the top
189189
// the number 5 is used so that we go one page in the
190190
// inner-scrolled Dependencies and Versions fields
191-
switchTo = currentLink;
192-
for (var n = 0; n < 5 && switchTo; ++n) {
193-
switchTo = previous(allItems, switchTo);
194-
}
195-
if (!switchTo) {
196-
switchTo = allItems[0];
191+
switchTo = currentItem || allItems[0];
192+
for (var n = 0; n < 5; ++n) {
193+
if (switchTo.previousElementSibling && switchTo.previousElementSibling.className == 'pure-menu-item') {
194+
switchTo = switchTo.previousElementSibling;
195+
}
197196
}
198197
break;
199198
case "pagedown":
200199
// page down: jump five items down, stopping at the bottom
201200
// the number 5 is used so that we go one page in the
202-
// inner-scrolled Depedencies and Versions fields
203-
switchTo = currentLink;
204-
for (var n = 0; n < 5 && switchTo; ++n) {
205-
switchTo = next(allItems, switchTo);
206-
}
207-
if (!switchTo) {
208-
switchTo = last(allItems);
201+
// inner-scrolled Dependencies and Versions fields
202+
switchTo = currentItem || last(allItems);
203+
for (var n = 0; n < 5; ++n) {
204+
if (switchTo.nextElementSibling && switchTo.nextElementSibling.className == 'pure-menu-item') {
205+
switchTo = switchTo.nextElementSibling;
206+
}
209207
}
210208
break;
211209
}

0 commit comments

Comments
 (0)