Skip to content

Instantly share code, notes, and snippets.

@mpj
Created January 25, 2010 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpj/285841 to your computer and use it in GitHub Desktop.
Save mpj/285841 to your computer and use it in GitHub Desktop.
<%@ 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