-
-
Save farmerbradllc/2884278 to your computer and use it in GitHub Desktop.
navigation-tab-thing
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
<style type="text/css" media="screen"> | |
.content-area { | |
display: none; | |
} | |
.content-area.selected { | |
display: block; | |
} | |
</style> | |
<header class="content-head content-head-liferay-portal"> | |
<hgroup> | |
<h1>$page-title.data</h1> | |
<div class="hr"> | |
<div> </div> | |
</div> | |
</hgroup> | |
<nav> | |
<ul id="test"> | |
#foreach($link in $links.siblings) | |
#if($velocityCount == 1) | |
<li class="selected"><a href="#div$velocityCount">$link.data</a></li> | |
#else | |
<li><a href="#div$velocityCount">$link.data</a></li> | |
#end | |
#end | |
</ul> | |
</nav> | |
</header> | |
#foreach($link in $links.siblings) | |
$velocityCount | |
#if($velocityCount == 1) | |
<style> | |
.content-area { | |
background: url($link.bg-image.data) 100% 0 no-repeat; | |
} | |
</style> | |
<div class="content-area selected" data-bannerImage="$link.bg-image.data" id="div$velocityCount">$link.data</div> | |
#else | |
<div class="content-area " data-bannerImage="$link.bg-image.data" id="div$velocityCount">$link.data</div> | |
#end | |
#end | |
<script type="text/javascript" charset="utf-8"> | |
AUI().ready( | |
'aui-base', | |
function(A) { | |
function selectTab(href){ | |
var div = A.one(href); | |
if (div) { | |
div.radioClass('selected'); | |
div.setStyle('background', 'url(' + div.attr('data-bannerImage')+') 100% 0 no-repeat'); | |
hash = href; | |
A.one('#test a[href$="'+ hash +'"]').ancestor().radioClass('selected'); | |
} | |
} | |
var hash = null; | |
if (location.hash) { | |
selectTab(location.hash); | |
A.one('#test a[href$="'+ location.hash +'"]').ancestor().addClass('selected'); | |
} | |
setInterval(function(){ | |
if(location.hash != hash){ | |
selectTab(location.hash); | |
} | |
}, 200); | |
A.one('#test').delegate( | |
'click', | |
function(event) { | |
var a = event.currentTarget; | |
var href = a.get('hash'); | |
a.ancestor().radioClass('selected'); | |
selectTab(href); | |
}, | |
'a' | |
); | |
} | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment