-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpageShortcuts.js
More file actions
36 lines (34 loc) · 1.15 KB
/
pageShortcuts.js
File metadata and controls
36 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
wrap(function pageShortcuts() {
const disable = settings.register({
name: 'Disable First/Last Page Shortcut',
key: 'underscript.disable.quickpages',
page: 'Library',
});
if (onPage('Crafting') || onPage('Decks')) {
function ignore(e) {
const ignore = disable.value() || !e.ctrlKey;
if (ignore && [0, global('getMaxPage')()].includes(global('currentPage'))) hover.hide();
return ignore;
}
function firstPage(e) {
if (ignore(e)) return;
e.preventDefault();
hover.hide();
global('showPage')(0);
$('#btnPrevious').prop('disabled', true);
$('#btnNext').prop('disabled', false);
}
function lastPage(e) {
if (ignore(e)) return;
e.preventDefault();
hover.hide();
global('showPage')(global('getMaxPage')());
$('#btnNext').prop('disabled', true);
$('#btnPrevious').prop('disabled', false);
}
eventManager.on('jQuery', function () {
$('#btnNext').on('click.script', lastPage).hover(hover.show('CTRL Click: Go to last page'));
$('#btnPrevious').on('click.script', firstPage).hover(hover.show('CTRL Click: Go to first page'));
});
}
});