-
-
Save mpj/285841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" Inherits="AbsolutCom.Navigation" CodeFile="AbsolutCom_Navigation.aspx.cs" %> | |
//<%= Request.QueryString.ToString() %> | |
function navFindSource(e) | |
{ | |
return e.target ? e.target : e.srcElement; | |
} | |
function navAddListener(obj, eventName, callback) | |
{ | |
if (obj.addEventListener) obj.addEventListener(eventName, callback, false); | |
else if (obj.attachEvent) obj.attachEvent('on' + eventName, callback); | |
} | |
function createNavImage(defaultImgPath, mouseOverImgPath) | |
{ | |
var img = document.createElement('img'); | |
img.style.border = 'none'; | |
img.src = defaultImgPath; | |
navAddListener(img, 'mouseover', function(e) {navFindSource(e).src = mouseOverImgPath;}); | |
navAddListener(img, 'mouseout', function(e) {navFindSource(e).src = defaultImgPath;}); | |
return img; | |
} | |
function createLink(linkTarget, defaultImgPath, mouseOverImgPath) | |
{ | |
//alert(linkTarget); | |
var link = document.createElement('a'); | |
link.setAttribute('href', linkTarget); | |
link.appendChild(createNavImage(defaultImgPath, mouseOverImgPath)); | |
return link; | |
} | |
function createSeparator() | |
{ | |
var img = document.createElement('img'); | |
img.style.border = 'none'; | |
img.src = '<asp:Literal ID="ctrlSeparator" RunAt="server" />'; | |
return img; | |
} | |
function buildAbsolutNav() | |
{ | |
var rootDiv = document.getElementById('absolutNav'); | |
rootDiv.style.backgroundImage = "url('<asp:Literal ID="ctrlBackgroundImage" RunAt="server" />')"; | |
rootDiv.style.backgroundColor = '<asp:Literal ID="ctrlBackgroundColor" RunAt="server" />'; | |
rootDiv.style.textAlign = 'center'; | |
rootDiv.style.padding = '0px'; | |
rootDiv.style.margin = '0px'; | |
rootDiv.style.height = '<asp:Literal ID="ctrlHeight" RunAt="server" />'; | |
rootDiv.appendChild(createSeparator()); | |
<asp:Repeater ID="rptNavItems" RunAt="server"> | |
<ItemTemplate> | |
rootDiv.appendChild(<%#(String)Container.DataItem%>); | |
rootDiv.appendChild(createSeparator()); | |
</ItemTemplate> | |
</asp:Repeater> | |
} | |
if (window.addEventListener) | |
{ | |
window.addEventListener('load', buildAbsolutNav, false); | |
} | |
else if (document.addEventListener) | |
{ | |
document.addEventListener('load', buildAbsolutNav, false); | |
} | |
else if (window.attachEvent) | |
{ | |
window.attachEvent('onload', buildAbsolutNav); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment