blob: 503b13596e5b94e98ebba4ff398145f5e00a17b4 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
(function($) {
var fadeOption = {duration: 150};
function toggleLeft() {
$('#sidebar_bg').show('fade', fadeOption);
$('#dokuwiki__aside').show();
}
function toggleRight() {
$('#sidebar_bg').show('fade', fadeOption);
$('#dokuwiki__tools').show();
}
function preventParentWheel(e) {
var curScrollPos = $(this).scrollTop();
var scrollableDist = $(this).prop('scrollHeight') - $(this).outerHeight();
var wheelEvent = e.originalEvent;
var dY = wheelEvent.deltaY;
if (dY < 0 && curScrollPos <= 0) {
return false;
}
if (dY > 0 && curScrollPos >= scrollableDist) {
return false;
}
}
function showSearch() {
$('div.search').toggle();
$('div.search').find('input.edit').select();
}
function bindEvents() {
$('.sidebar').on('wheel scroll', preventParentWheel);
$('.btn_left').click(function() {
toggleLeft();
});
$('.btn_right').click(function() {
toggleRight();
});
$('#sidebar_bg').click(function() {
$(this).hide('fade', fadeOption);
$('#dokuwiki__aside').hide();
$('#dokuwiki__tools').hide();
});
$('.btn_search').click(function() {
showSearch();
});
$(document).keydown(function(e) {
if (e.which == 70 && e.altKey) {
showSearch();
e.preventDefault();
}
});
}
function initUI() {
// Move TOC
if ($('.page h2').length > 0) {
$('.toc_wikipedia').find('#dw__toc').insertBefore($('.page h2:first'));
} else {
$('.toc_wikipedia').find('#dw__toc').insertAfter($('.page h1:first').next('.level1'));
}
if ($('.page > .level1 > blockquote').length > 0) {
$('.toc_dokuwiki').find('#dw__toc').insertAfter($('.page > .level1 > blockquote'));
} else {
$('.toc_dokuwiki').find('#dw__toc').insertAfter($('.page h1:first'));
}
// $('.toc_dokuwiki').find('blockquote:first').insertAfter($('.page h1:first'));
// Anchor link should be shifted by header pixel
$(window).on("hashchange", function () {
window.scrollTo(window.scrollX, window.scrollY - 48);
});
}
$(function() {
initUI();
bindEvents();
});
})(jQuery);
|