-
Notifications
You must be signed in to change notification settings - Fork 0
/
motionpackjs.php
105 lines (83 loc) · 3 KB
/
motionpackjs.php
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
<?php ob_start('ob_gzhandler'); ?>
var timerlen = 5;
var slideAniLen = 300;
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();
var noComs = new Array();
function slidedown(objname) {
if (moving[objname]) return; // It's currently sliding
theElement = (noComs[objname]) ? 'com' + objname + '_open' : objname;
if (document.getElementById(theElement).style.display != 'none') return; // cannot slide down something that is already visible
moving[objname] = true;
dir[objname] = 'down';
startslide(objname);
}
function slideup(objname) {
if (moving[objname]) return; // It's currently sliding
theElement = (noComs[objname]) ? 'com' + objname + '_open' : objname;
if (document.getElementById(theElement).style.display == 'none') return; // cannot slide up something that is already hidden
moving[objname] = true;
dir[objname] = 'up';
startslide(objname);
}
function startslide(objname) {
theElement = (noComs[objname]) ? 'com' + objname + '_open' : objname;
obj[objname] = document.getElementById(theElement);
startTime[objname] = (new Date()).getTime();
if (dir[objname] == 'down') {
obj[objname].style.height = '1px';
}
obj[objname].style.display = 'block';
endHeight[objname] = parseInt(obj[objname].scrollHeight);
if(endHeight[objname] > 150) {
endHeight[objname] = 150;
obj[objname].style.overflow = 'auto';
}
timerID[objname] = setInterval('slidetick(\'' + objname + '\');', timerlen);
}
function slidetick(objname) {
var elapsed = (new Date()).getTime() - startTime[objname];
if (elapsed > slideAniLen) endSlide(objname)
else {
var d = Math.round(elapsed / slideAniLen * endHeight[objname]);
if (dir[objname] == 'up') d = endHeight[objname] - d;
obj[objname].style.height = d + 'px';
}
return;
}
function endSlide(objname) {
clearInterval(timerID[objname]);
if (dir[objname] == 'up') obj[objname].style.display = 'none';
obj[objname].style.height = endHeight[objname] + 'px';
delete(moving[objname]);
delete(timerID[objname]);
delete(startTime[objname]);
delete(endHeight[objname]);
delete(obj[objname]);
delete(dir[objname]);
if(noComs[objname])
{
if (document.getElementById('com' + objname + '_open').style.display == 'none') {
document.getElementById('comtext_' + objname).innerHTML = showComs + ' (' + noComs[objname] + ')';
} else {
document.getElementById('comtext_' + objname).innerHTML = hideComs + ' (' + noComs[objname] + ')';
}
}
return;
}
function toggleSlide(objname, coms) {
theElement = (coms) ? 'com' + objname + '_open' : objname;
noComs[objname] = coms;
if (document.getElementById(theElement).style.display == 'none') {
// div is hidden, so let's slide down
slidedown(objname);
} else {
// div is not hidden, so slide up
slideup(objname);
}
}
<?php ob_end_flush(); ?>