-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.js
More file actions
132 lines (116 loc) · 3.84 KB
/
page.js
File metadata and controls
132 lines (116 loc) · 3.84 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
(function($){
function init(){
$('.fancybox').fancybox();
initScrollHandler();
initSearchBox();
initPaginationCtrl();
// $('div.post-content header h1').on('click', function(){
// console.log('youclickme');
// toggleFull();
// });
}
var initScrollHandler = function(){
function goTop() {
$(window).scroll(function(e) {
// If the distance between scrollbar and top border is more than 100 pix
if($(window).scrollTop() > 100)
$("#go-pg-top").fadeIn().css({ opacity: 0.6 });
else
$("#go-pg-top").fadeOut();
});
};
$("#go-pg-top").click(function(e) {
$('body,html').animate({scrollTop:0}, 200);
});
$("#go-pg-top").mouseover(function(e) {
$(this).css({ opacity: 1 });
});
$("#go-pg-top").mouseout(function(e) {
$(this).css({ opacity: 0.6 });
});
// Scroll to top
goTop();
};
var initSearchBox = function(){
$('#sidebar i.icon-search').on({
'click': function(){
$('#sidebar form')[0].submit();
},
'mouseover': function(){
$(this).addClass('search-hover');
},
'mouseout':function(){
$(this).removeClass('search-hover');
}
});
};
var initPaginationCtrl = function(){
var $prev = $('#pagination .prev'),
$next = $('#pagination .next'),
$pgPrev = $('#page-direction .page-prev'),
$pgNext = $('#page-direction .page-next');
if($prev.length){
$pgPrev.show().attr('href', $prev.attr('href'));
$prev.hide();
}else{
$pgPrev.hide();
}
if($next.length){
$pgNext.show().attr('href', $next.attr('href'));
$next.hide();
}else{
$pgNext.hide();
}
$pgPrev.on({
'mouseover': function(){
$(this).addClass('page-prev-hover');
},
'mouseout': function(){
$(this).removeClass('page-prev-hover');
}
});
$pgNext.on({
'mouseover': function(){
$(this).addClass('page-next-hover');
},
'mouseout': function(){
$(this).removeClass('page-next-hover');
}
});
};
var cancelFullScreen = function(el){
var requestMethod = el.cancelFullScreen||el.webkitCancelFullScreen||el.mozCancelFullScreen||el.exitFullscreen;
if (requestMethod) { // cancel full screen.
requestMethod.call(el);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
};
var requestFullScreen = function(el){
// Supports most browsers and their versions.
var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
if (requestMethod) { // Native full screen.
requestMethod.call(el);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
return false
};
var toggleFull = function(){
var elem = $('#content article.post')[0]; // Make the body go full screen.
var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || (document.mozFullScreen || document.webkitIsFullScreen);
if (isInFullScreen) {
cancelFullScreen(document);
} else {
requestFullScreen(elem);
}
return false;
};
init();
})(jQuery);