Skip to content

Instantly share code, notes, and snippets.

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 steveosoule/2cb6d51d71b95b2238467d3c8a374b36 to your computer and use it in GitHub Desktop.
Save steveosoule/2cb6d51d71b95b2238467d3c8a374b36 to your computer and use it in GitHub Desktop.
Miva - Levels Menu Aim for Tablet Alternative
(function Mega_Menu(){
var init = function(){
var is_mobile = $('html').hasClass('mobile');
if( is_mobile ){
$('.nav-item-2').on('click', function(e){
var item = this,
$group = get_$group_from_item(item);
if( $group.is(':visible') ){
window.location = item.href;
} else {
e.preventDefault();
activate_item(item);
}
});
} else {
menu_aim();
}
};
var get_$group_from_item = function(item){
var $item = $(item),
id = $item.data('navigationitem-id'),
$group = $('.nav-group-4[data-navigationitem-id="' + id + '"]');
return $group;
};
var menu_aim = function(){
$.getScript(theme_path + '/js/jquery.menu-aim.js', function(data, textStatus) {
$('.nav-group-2').menuAim({
activate: activate_item,
deactivate: deactivate_item,
rowSelector: ".nav-item-2"
});
});
};
var activate_item = function(item){
var $group = get_$group_from_item(item);
$('.nav-group-4').hide();
if( $group.find('.nav-group-5').length ){
$group.show();
$('.nav-group-3').show();
}
};
var deactivate_item = function(){
$('.nav-group-4').hide();
$('.nav-group-3').hide();
};
init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment