From a12a83995b977aa769640746a6d576751cdbed24 Mon Sep 17 00:00:00 2001 From: briandunnigan Date: Wed, 24 Feb 2016 13:26:05 -0500 Subject: [PATCH] Fix for navigation # issue --- functions.php | 134 ++++++++++++++++++++++++++------------------------ navigation.js | 67 +++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 64 deletions(-) create mode 100644 navigation.js diff --git a/functions.php b/functions.php index a4cb382..082783d 100644 --- a/functions.php +++ b/functions.php @@ -1,65 +1,71 @@ - - - - - - - - - - - - - - - -'; - -} - + + + + + + + + + + + + + + + +'; + +} + ?> \ No newline at end of file diff --git a/navigation.js b/navigation.js new file mode 100644 index 0000000..46db71c --- /dev/null +++ b/navigation.js @@ -0,0 +1,67 @@ +/** + * 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('.dropdown-menu .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'; + }; +} )(); +*/ \ No newline at end of file