Blame view

account/mods/test.js 2.23 KB
42868d70   andryeyev   Создал GIT
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
  var collapsingDiv = "";
  var activeHeight = 0;
  var divHeight = "";
  var collapseState = 0;
  var deltaTime = 10;
  var deltaHeight = 4;
  var titleOffset = 40;
  var docDivs = new Array();
  var collapsingSpeed = "";
  
  function initialize() {
  	docDivs = document.getElementsByTagName("div");
  	for (i=0;i<docDivs.length;i++) {
  		if (docDivs[i].className == "hidden") {
  			collapsingDiv = docDivs[i].id;
  		}
  	}
  	activeHeight = titleOffset;
  	divHeight = document.getElementById(collapsingDiv).offsetHeight;
  	collapsingSpeed = collapsingDiv.substring(collapsingDiv.lastIndexOf('-')+1);
  	document.getElementById(collapsingDiv).style.height = activeHeight+'px';
  	document.getElementById('toggle').style.display = 'inline';
  	
  	if (collapsingSpeed == 1) { deltaTime = 100; deltaHeight = 1; }
  	if (collapsingSpeed == 2) { deltaTime = 70; deltaHeight = 1; }
  	if (collapsingSpeed == 3) { deltaTime = 40; deltaHeight = 1; }
  	if (collapsingSpeed == 4) { deltaTime = 20; deltaHeight = 1; }
  	if (collapsingSpeed == 5) { deltaTime = 10; deltaHeight = 1; }
  	if (collapsingSpeed == 6) { deltaTime = 10; deltaHeight = 2; }
  	if (collapsingSpeed == 7) { deltaTime = 10; deltaHeight = 4; }
  	if (collapsingSpeed == 8) { deltaTime = 10; deltaHeight = 7; }
  	if (collapsingSpeed == 9) { deltaTime = 10; deltaHeight = 10; }
  }
  
  function toggle() {
  	if (collapseState === 0) {
  		// Going Down
  		document.getElementById(collapsingDiv).style.height = activeHeight+'px';
  		if ((((divHeight)-activeHeight) < deltaHeight) && (activeHeight !== divHeight)) {
  			activeHeight = divHeight;
  		} else {
  			activeHeight = activeHeight+deltaHeight;
  		}
  		if (activeHeight <= divHeight) {
  			setTimeout('toggle()',deltaTime);//Recursively calling this function again.
  		}
  		if (activeHeight > divHeight) {
  			activeHeight = divHeight;
  			collapseState = 1;
  		}
  	} else {
  		// Going Up
  		document.getElementById(collapsingDiv).style.height = activeHeight+'px';
  		activeHeight = activeHeight-deltaHeight;
  		if (((divHeight)-activeHeight) <= divHeight-titleOffset) {
  			setTimeout('toggle()',deltaTime);//Recursively calling this function again.
  		}
  		if (((divHeight)-activeHeight) > divHeight-titleOffset) {
  			activeHeight = titleOffset;
  			document.getElementById(collapsingDiv).style.height = activeHeight+'px';
  			collapseState = 0;
  		}
  	}
  }