Skip to content

Instantly share code, notes, and snippets.

@AllieRays
Created August 3, 2014 21:51
Show Gist options
  • Save AllieRays/1cd0387ddc8b991d16af to your computer and use it in GitHub Desktop.
Save AllieRays/1cd0387ddc8b991d16af to your computer and use it in GitHub Desktop.
EPT journery mega drawer menu can be seen when clicked on any navigation item
// EPT journery mega drawer menu can be seen when clicked on any navigation item
//http://eptfamily.com/
//Initiate Journey Nav Control
Drupal.behaviors.ept_menu_journey_behavior = {
attach: function(context, settings) {
$('#block-system-main-menu', context).once('journey-nav', function() {
$(this).find('a.mega-drawer').each(function() {
$(this).click(function() {
var $navItem = $(this);
var targetView;
var bgColorClass;
var navViewId = $navItem.attr('id'); //nav item to view itself
switch (navViewId)
{
case 'journey-nav-item':
targetView = 'block-views-journey-detail-nav-block';
bgColorClass = 1;
break;
case 'products-nav-item':
targetView = 'block-views-products-block-1';
bgColorClass = 0;
break;
case 'read-test-nav-item':
targetView = 'block-views-products-block-3';
bgColorClass = 0;
break;
default:
targetView = 'null';
}
$('.l-menu-expansion').slideUp(200, 'linear', function() {
if ($(this).find('.block--views.active').attr('id') == targetView) {
var close = true;
} else {
var close = false;
}
//console.log('close = ' + close);
//close active
$(this).find('.block--views.active').removeClass('active').hide(0);
// open new drawer
if (bgColorClass == 1) {
$(this).addClass('journey-background');
} else {
$(this).removeClass('journey-background');
}
if (close == false) {
$(this).find('#' + targetView).addClass('active').show(0);
$(this).slideDown(200, 'linear');
}
});
return false;
});
});
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment