source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.GeneratedDocumentation/Help/Scripts/Dropdown.js@ 1153

Last change on this file since 1153 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 2.7 KB
Line 
1
2// Dropdown menu control
3
4function Dropdown(activatorId, dropdownId) {
5
6 // store activator and dropdown elements
7 this.activator = document.getElementById(activatorId);
8 this.dropdown = document.getElementById(dropdownId);
9 this.activatorImage = document.getElementById(activatorId + "Image");
10
11 // wire up show/hide events
12 registerEventHandler(this.activator,'mouseover', getInstanceDelegate(this, "show"));
13 registerEventHandler(this.activator,'mouseout', getInstanceDelegate(this, "requestHide"));
14 registerEventHandler(this.dropdown,'mouseover', getInstanceDelegate(this, "show"));
15 registerEventHandler(this.dropdown,'mouseout', getInstanceDelegate(this, "requestHide"));
16
17 // fix visibility and position
18 this.dropdown.style.visibility = 'hidden';
19 this.dropdown.style.position = 'absolute';
20 this.reposition(null);
21
22 // wire up repositioning event
23 registerEventHandler(window, 'resize', getInstanceDelegate(this, "reposition"));
24
25
26}
27
28Dropdown.prototype.show = function(e) {
29 clearTimeout(this.timer);
30 this.dropdown.style.visibility = 'visible';
31 if (this.activatorImage != null)
32 this.activatorImage.src = dropDownHoverImage.src;
33 if (this.activator != null)
34 this.activator.className = "filterOnHover";
35}
36
37Dropdown.prototype.hide = function(e) {
38 this.dropdown.style.visibility = 'hidden';
39 if (this.activatorImage != null)
40 this.activatorImage.src = dropDownImage.src;
41 if (this.activator != null)
42 this.activator.className = "filter";
43}
44
45Dropdown.prototype.requestHide = function(e) {
46 this.timer = setTimeout( getInstanceDelegate(this, "hide"), 250);
47}
48
49Dropdown.prototype.reposition = function(e) {
50
51 // get position of activator
52 var offsetLeft = 0;
53 var offsetTop = 0;
54 var offsetElement = this.activator;
55
56 while (offsetElement) {
57 offsetLeft += offsetElement.offsetLeft;
58 offsetTop += offsetElement.offsetTop;
59 offsetElement = offsetElement.offsetParent;
60 }
61
62 // set position of dropdown relative to it
63 this.dropdown.style.left = offsetLeft;
64 this.dropdown.style.top = offsetTop + this.activator.offsetHeight;
65}
66
67Dropdown.prototype.SetActivatorLabel = function(labelId)
68{
69 // get the children of the activator node, which includes the label nodes
70 var labelNodes = this.activator.childNodes;
71
72
73 for(var labelCount=0; labelCount < labelNodes.length; labelCount++)
74 {
75 if(labelNodes[labelCount].tagName == 'LABEL')
76 {
77 var labelNodeId = labelNodes[labelCount].getAttribute('id');
78 if (labelNodeId == labelId)
79 {
80 labelNodes[labelCount].style.display = "inline";
81 }
82 else
83 {
84 labelNodes[labelCount].style.display = "none";
85 }
86 }
87 }
88}
89
Note: See TracBrowser for help on using the repository browser.