-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbase.js
More file actions
147 lines (128 loc) · 3.64 KB
/
base.js
File metadata and controls
147 lines (128 loc) · 3.64 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
$(document).ready(function($){
var fdtop = $('.foot').position().top;
$(window).scroll(function(){
var top = $(window).scrollTop();
var sub = top + $('.sidebar-fixed').height() - fdtop;
if( sub > 0){
$('.sidebar-fixed').css({'position':'fixed','top': '' + -sub + 'px'});
}else if(top > 215){
$('.sidebar-fixed').css({'position':'fixed','top':'20px'});
}
else{
top = 0;
$('.sidebar-fixed').css({'position':'absolute','top':'208px'});
}
});
});
$(document).ready(function($){
var fdtop = $('.foot').position().top;
$(window).scroll(function(){
var top = $(window).scrollTop();
var sub = top + $('.sidebar-guestbook-fixed').height() - fdtop;
if( sub > 0){
$('.sidebar-guestbook-fixed').css({'position':'fixed','top': '' + -sub + 'px'});
}else if(top > 360){
$('.sidebar-guestbook-fixed').css({'position':'fixed','top':'20px'});
}
else{
top = 0;
$('.sidebar-guestbook-fixed').css({'position':'absolute','top':'390px'});
}
});
});
/*
Author: mg12
Update: 2008/05/05
Author URI: http://www.neoease.com/
*/
(function() {
function $(id) {
return document.getElementById(id);
}
function setStyleDisplay(id, status) {
$(id).style.display = status;
}
function goTop(a, t) {
a = a || 0.1;
t = t || 16;
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
var x3 = 0;
var y3 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
var x3 = window.scrollX || 0;
var y3 = window.scrollY || 0;
var x = Math.max(x1, Math.max(x2, x3));
var y = Math.max(y1, Math.max(y2, y3));
var speed = 1 + a;
window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));
if(x > 0 || y > 0) {
var f = "MGJS.goTop(" + a + ", " + t + ")";
window.setTimeout(f, t);
}
}
function switchTab(showPanels, hidePanels, activeTab, activeClass, fadeTab, fadeClass) {
$(activeTab).className = activeClass;
$(fadeTab).className = fadeClass;
var panel, panelList;
panelList = showPanels.split(',');
for (var i = 0; i < panelList.length; i++) {
var panel = panelList[i];
if ($(panel)) {
setStyleDisplay(panel, 'block');
}
}
panelList = hidePanels.split(',');
for (var i = 0; i < panelList.length; i++) {
panel = panelList[i];
if ($(panel)) {
setStyleDisplay(panel, 'none');
}
}
}
function loadCommentShortcut() {
$('comment').onkeydown = function (moz_ev) {
var ev = null;
if (window.event){
ev = window.event;
} else {
ev = moz_ev;
}
if (ev != null && ev.ctrlKey && ev.keyCode == 13) {
$('submit').click();
}
}
$('submit').value += ' (Ctrl+Enter)';
}
function getElementsByClassName(className, tag, parent) {
parent = parent || document;
var allTags = (tag == '*' && parent.all) ? parent.all : parent.getElementsByTagName(tag);
var matchingElements = new Array();
className = className.replace(/\-/g, '\\-');
var regex = new RegExp('(^|\\s)' + className + '(\\s|$)');
var element;
for (var i = 0; i < allTags.length; i++) {
element = allTags[i];
if (regex.test(element.className)) {
matchingElements.push(element);
}
}
return matchingElements;
}
window['MGJS'] = {};
window['MGJS']['$'] = $;
window['MGJS']['setStyleDisplay'] = setStyleDisplay;
window['MGJS']['goTop'] = goTop;
window['MGJS']['switchTab'] = switchTab;
window['MGJS']['loadCommentShortcut'] = loadCommentShortcut;
window['MGJS']['getElementsByClassName'] = getElementsByClassName;
})();