Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
42ed949a36
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
67 lines (56 sloc) 1.4 KB
/**
* navigation.js
*
*/
jQuery(document).ready(function($) {
function replaceAnchors(selector) {
$(selector).each(function(){
var atag = $(this).children('a');
var newhref = getFirstLink(this);
atag.attr('href',newhref);
});
}
function getFirstLink(element){
var href = $(element).children('a').attr('href');
if(href == '#'){
var firstChild = $(element).children('ul').children('li').first();
if(firstChild.length == 0){
return href;
}
else {
return getFirstLink(firstChild);
}
}
else {
return href;
}
}
replaceAnchors('.menu-item-has-children');
});
/*
* Handles toggling the navigation menu for small screens.
*
( function() {
var container, button, menu;
container = document.getElementById( 'site-navigation' );
if ( ! container )
return;
button = container.getElementsByTagName( 'button' )[0];
if ( 'undefined' === typeof button )
return;
menu = container.getElementsByTagName( 'ul' )[0];
// Hide menu toggle button if menu is empty and return early.
if ( 'undefined' === typeof menu ) {
button.style.display = 'none';
return;
}
if ( -1 === menu.className.indexOf( 'nav-menu' ) )
menu.className += ' nav-menu';
button.onclick = function() {
if ( -1 !== container.className.indexOf( 'toggled' ) )
container.className = container.className.replace( ' toggled', '' );
else
container.className += ' toggled';
};
} )();
*/