/** Author : FBolaji **/
/** Created : 19.05.2014 **/
/** EP2 Navigation * */
var EP2 = EP2 || {};
!(function(window, document, undefined) {
'use strict';
EP2.topNavigation = function() {
var dataAttr = "", searchbox = $('.searchBox'), underlayer = $('#underLayer'), hpCarouselEle = $('#hpCarousel'), activeLi = $(
'.doormat').find('li.active').index();
// insert underlayer element
$('#wrapper').append('
');
// remove unwanted selected or active state. from element
$('.doormat').find('li.active, li.selected').removeAttr('class');
var otherSbeMenu = $('.levelOne.otherSBEs');
otherSbeMenu.find('> a').eq(0).append('');
var menu = {
menuEvent : function() {
var $el = $('#sections .levelOne');
$el.on({
'mouseover' : function(e) {
e.stopPropagation();
var $this = $(this);
var findchild = $this.find('.doormat');
dataAttr = $this.attr('data-nav');
$this.addClass('focused');
if (findchild.length) {
$this.find('> a').css('height', '27px');
if (hpCarouselEle.length) {
hpCarouselEle.cycle('pause'); // pause homepage carousel
}
}
if (dataAttr == "cv" || dataAttr == "pv") {
$('#underLayer').css({
display : 'block',
opacity : 0.6
});
}
searchbox.css('zIndex', 0);
// menu.underLayer();
},
'mouseleave' : function(e) {
e.stopPropagation();
var $this = $(this);
var findchild = $this.find('.doormat');
$this.removeClass('focused');
if (findchild.length) {
$this.find('> a').removeAttr('style');
if (hpCarouselEle.length) {
hpCarouselEle.cycle('resume'); // resume
// homepage
// carousel
}
}
$('#underLayer').css({
display : 'none',
opacity : 0
});
searchbox.removeAttr('style');
// underlayer.stop(true).fadeOut();
}
});
},
cvmenu : function() {
var navSelector = $('.primary-nav-items');
var childListElement = $('.navigation-grid-items');
menu.menuEvent();
navSelector.wrap('');
navSelector.after('');
childListElement
.each(function(i, v) {
$('.navigation-grid-wrapper .list-content').append(
$(this));
});
$('.cvInnerWrap').tabbifiedContent(
{
navEle : '.primary-nav-items li a',
tabPanelSelector : '.navigation-grid-items',
selectedTabLink : activeLi,
tabNavEvent : 'mouseenter',
afterTabSelected : function() { // callback after
// tabbified
// initialized and
// prevent default
// left links urls.
var $this = $('.cvInnerWrap').find(
'.primary-nav-items li a');
$this.on('click', function(e) {
e.preventDefault();
});
}
});
},
pvmenu : function() {
if ($('.innerWrap').length) {
$('.innerWrap').tabbifiedContent({
tabPanelSelector : '.tabContent',
tabNavEvent : 'mouseenter'
});
}
},
underLayer : function() {
underlayer.css({
opacity : 0.3,
display : 'block',
height : $(window).height()
});
underlayer.stop(true).fadeIn();
}
};
menu.pvmenu();
menu.cvmenu();
menu.menuEvent();
};
return EP2.topNavigation();
})(jQuery, window, document);