Skip to content

Instantly share code, notes, and snippets.

@johnny5th
Created January 9, 2013 20:36
Show Gist options
  • Save johnny5th/4496703 to your computer and use it in GitHub Desktop.
Save johnny5th/4496703 to your computer and use it in GitHub Desktop.
Functions to remove the sub nav out of a superfish menu on mobile screen widths to disable the onhover tap on iOS.
function hideSubNav(menu) {
if($(menu).attr('data-sub-removed') == 1)
return false;
var hiddennav = $(menu).parent().children('.removednav').eq(0);
if(hiddennav.length == 0)
var hiddennav = $('<div class="removednav" style="display: none">').appendTo($(menu).parent());
$(menu).find('.menuparent').each(function(){
var parent = $(this);
var subnav = parent.find('ul').eq(0);
subnav.attr('data-parent', parent.attr('id')).appendTo(hiddennav);
});
$(menu).attr('data-sub-removed',1);
}
function showSubNav(menu) {
if(!$(menu).attr('data-sub-removed') || $(menu).attr('data-sub-removed') == 0)
return false;
var hiddennav = $(menu).parent().children('.removednav').eq(0);
if(hiddennav.length == 0) {
console.log('Hidden Navigation Container Does Not Exist');
return false;
}
hiddennav.children('ul').each(function(){
$(this).appendTo('#'+$(this).attr('data-parent'));
});
$(menu).attr('data-sub-removed',0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment