-
Notifications
You must be signed in to change notification settings - Fork 3
/
ToBottom.js
41 lines (33 loc) · 1.28 KB
/
ToBottom.js
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
37
38
39
40
41
/*** To Bottom ***/
// Adds a link in the right navigation menu to got to the bottom of the page
// Documentation at [[en:w:User:BrandonXLF/ToBottom]]
// By [[en:w:User:BrandonXLF]]
// window.arrow = 'never'; // To always see Bottom
// window.arrow = 'always; // To always see ↓ (down arrow)
// window.arrow = 'hybrid'; // To see ↓ (down arrow) normally and Bottom when in menu (default)
$(function() {
function scroll(e) {
e.preventDefault();
$('html').animate({scrollTop: $(document).height()});
}
var mode = 'hybrid';
if (window.arrow == 'never' || window.arrow == 'always') {
mode = window.arrow;
}
$(mw.util.addPortletLink('p-views', '#', mode == 'never' ? 'Bottom' : '↓', 'ca-to-bottom', null, null, '.mw-watchlink'))
.addClass('collapsible')
.click(scroll);
if (mode == 'hybrid') {
$(mw.util.addPortletLink('p-views', '#', 'Bottom', 'ca-to-bottom-text', null, null, '.mw-watchlink'))
.addClass('collapsible')
.click(scroll);
}
if (window.arrow != 'never' && window.arrow != 'always') {
mw.util.addCSS(
'#ca-to-bottom { display: initial !important; }' +
'#ca-to-bottom-text { display: none !important; }' +
'#p-cactions #ca-to-bottom { display: none !important; }' +
'#p-cactions #ca-to-bottom-text { display: initial !important; }'
);
}
});