summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-08-30 17:09:22 -0700
committerAndrew <andrewarnott@gmail.com>2008-08-30 17:09:22 -0700
commit4a94bcfb7963abcbf602dfa1e1ea9b894985668f (patch)
tree95ef3746ecf0f87abb658db36f113c3baf680be5 /tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js
downloadDotNetOpenAuth-4a94bcfb7963abcbf602dfa1e1ea9b894985668f.zip
DotNetOpenAuth-4a94bcfb7963abcbf602dfa1e1ea9b894985668f.tar.gz
DotNetOpenAuth-4a94bcfb7963abcbf602dfa1e1ea9b894985668f.tar.bz2
Initial build system version.
Diffstat (limited to 'tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js')
-rw-r--r--tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js b/tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js
new file mode 100644
index 0000000..aa3d6f4
--- /dev/null
+++ b/tools/Sandcastle/Presentation/vs2005/Scripts/Dropdown.js
@@ -0,0 +1,89 @@
+
+// Dropdown menu control
+
+function Dropdown(activatorId, dropdownId) {
+
+ // store activator and dropdown elements
+ this.activator = document.getElementById(activatorId);
+ this.dropdown = document.getElementById(dropdownId);
+ this.activatorImage = document.getElementById(activatorId + "Image");
+
+ // wire up show/hide events
+ registerEventHandler(this.activator,'mouseover', getInstanceDelegate(this, "show"));
+ registerEventHandler(this.activator,'mouseout', getInstanceDelegate(this, "requestHide"));
+ registerEventHandler(this.dropdown,'mouseover', getInstanceDelegate(this, "show"));
+ registerEventHandler(this.dropdown,'mouseout', getInstanceDelegate(this, "requestHide"));
+
+ // fix visibility and position
+ this.dropdown.style.visibility = 'hidden';
+ this.dropdown.style.position = 'absolute';
+ this.reposition(null);
+
+ // wire up repositioning event
+ registerEventHandler(window, 'resize', getInstanceDelegate(this, "reposition"));
+
+
+}
+
+Dropdown.prototype.show = function(e) {
+ clearTimeout(this.timer);
+ this.dropdown.style.visibility = 'visible';
+ if (this.activatorImage != null)
+ this.activatorImage.src = dropDownHoverImage.src;
+ if (this.activator != null)
+ this.activator.className = "filterOnHover";
+}
+
+Dropdown.prototype.hide = function(e) {
+ this.dropdown.style.visibility = 'hidden';
+ if (this.activatorImage != null)
+ this.activatorImage.src = dropDownImage.src;
+ if (this.activator != null)
+ this.activator.className = "filter";
+}
+
+Dropdown.prototype.requestHide = function(e) {
+ this.timer = setTimeout( getInstanceDelegate(this, "hide"), 250);
+}
+
+Dropdown.prototype.reposition = function(e) {
+
+ // get position of activator
+ var offsetLeft = 0;
+ var offsetTop = 0;
+ var offsetElement = this.activator;
+
+ while (offsetElement) {
+ offsetLeft += offsetElement.offsetLeft;
+ offsetTop += offsetElement.offsetTop;
+ offsetElement = offsetElement.offsetParent;
+ }
+
+ // set position of dropdown relative to it
+ this.dropdown.style.left = offsetLeft;
+ this.dropdown.style.top = offsetTop + this.activator.offsetHeight;
+}
+
+Dropdown.prototype.SetActivatorLabel = function(labelId)
+{
+ // get the children of the activator node, which includes the label nodes
+ var labelNodes = this.activator.childNodes;
+
+
+ for(var labelCount=0; labelCount < labelNodes.length; labelCount++)
+ {
+ if(labelNodes[labelCount].tagName == 'LABEL')
+ {
+ var labelNodeId = labelNodes[labelCount].getAttribute('id');
+ if (labelNodeId == labelId)
+ {
+ labelNodes[labelCount].style.display = "inline";
+ }
+ else
+ {
+ labelNodes[labelCount].style.display = "none";
+ }
+ }
+ }
+}
+ \ No newline at end of file