source: greenstone3/branches/customizingGreenstone3/web/ui/skins/oran/js/scripts.js@ 14712

Last change on this file since 14712 was 14712, checked in by dnk2, 17 years ago

dump of existing code

File size: 2.1 KB
Line 
1/**
2 * @author dnk2
3 */
4
5function showContents() {
6 var contents = document.getElementById("contents") ;
7 var contentsLink = document.getElementById("contentsLink") ;
8
9 contents.style.left = contentsLink.offsetLeft + "px" ;
10 contents.style.top = (contentsLink.offsetTop + contentsLink.offsetHeight) + "px" ;
11
12 contents.onmouseout = new Function("event", "if (isMouseLeaveOrEnter(event, this)) hideContents() ;") ;
13
14 var ul = getSublist(contents) ;
15
16 for(var i=0 ; i<ul.childNodes.length ; i++) {
17 collapseNode(ul.childNodes[i]) ;
18 }
19
20 var currNode = document.getElementById("currentSection") ;
21 if (currNode != null) {
22 //alert("current section found") ;
23 currNode = currNode.parentNode ;
24 expandAncestors(currNode) ;
25 } else {
26 //alert("no current section found") ;
27 }
28
29
30 contents.style.display = "block" ;
31}
32
33
34function expandAncestors(node) {
35
36 var parent = node.parentNode.parentNode ;
37
38 if (parent.id != "contents") {
39 parent.className = "expanded" ;
40 expandAncestors(parent) ;
41 }
42}
43
44function collapseNode(node) {
45 if (node.className == "expanded")
46 node.className = "collapsed" ;
47}
48
49function toggleNode(nodeId) {
50
51 var node = document.getElementById(nodeId) ;
52
53 var ul = getSublist(node) ;
54
55 if (node.className == "expanded")
56 node.className = "collapsed" ;
57 else
58 node.className = "expanded" ;
59
60 for(var i=0 ; i<ul.childNodes.length ; i++) {
61 //alert(ul.childNodes[i].innerHTML)
62 collapseNode(ul.childNodes[i]) ;
63 }
64}
65
66function hideContents() {
67 var contents = document.getElementById("contents") ;
68 contents.style.display = "none" ;
69}
70
71
72 // this function determines whether the event is the equivalent of the microsoft // mouseleave or mouseenter events.
73function isMouseLeaveOrEnter(e, handler) {
74
75 if (e.type != 'mouseout' && e.type != 'mouseover')
76 return false;
77
78 var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
79 while (reltg && reltg != handler)
80 reltg = reltg.parentNode;
81
82 return (reltg != handler);
83}
84
85function getSublist(node) {
86
87 for (var x=0 ; x<node.childNodes.length ; x++){
88
89 if (node.childNodes[x].tagName == "UL")
90 return node.childNodes[x] ;
91 }
92
93 return null ;
94}
Note: See TracBrowser for help on using the repository browser.