jQuery(document).ready(function($) {
var top_button_menu_toggle = $('#top-navigation .button-menu-toggle');
var top_nav_menu = $('#top-navigation .main-navigation');
var primary_menu_toggle = $('#masthead .menu-toggle');
var primary_nav_menu = $('#masthead .main-navigation');
var thumbnail_wrapper = $('.thumbnail-wrapper');
var editor_wrapper = $('.editor-wrapper');
top_button_menu_toggle.click(function(){
top_nav_menu.slideToggle();
$(this).toggleClass('active');
$('.menu-overlay').toggleClass('active');
$('#top-navigation .main-navigation').toggleClass('menu-open');
$('#top-navigation').css({ 'z-index' : '30000' });
});
thumbnail_wrapper.slick({
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2
}
},
{
breakpoint: 900,
settings: {
slidesToShow: 1,
arrows: false
}
}
]
});
editor_wrapper.slick({
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2
}
},
{
breakpoint: 900,
settings: {
slidesToShow: 1
}
}
]
});
/*--------------------------------------------------------------
Keyboard Navigation
----------------------------------------------------------------*/
if( $(window).width() < 1024 ) {
$('#primary-menu').find("li").last().bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
$('#secondary-menu').find("li").last().bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#top-navigation').find('.button-menu-toggle').focus();
}
});
$('#primary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
$('#secondary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#top-navigation').find('.button-menu-toggle').focus();
}
});
}
else {
$('#primary-menu').find("li").unbind('keydown');
$('#secondary-menu').find("li").unbind('keydown');
}
$(window).resize(function() {
if( $(window).width() < 1024 ) {
$('#primary-menu').find("li").last().bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
$('#secondary-menu').find("li").last().bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#top-navigation').find('.button-menu-toggle').focus();
}
});
$('#primary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
$('#secondary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
if( e.which === 9 ) {
e.preventDefault();
$('#top-navigation').find('.button-menu-toggle').focus();
}
});
}
else {
$('#primary-menu').find("li").unbind('keydown');
$('#secondary-menu').find("li").unbind('keydown');
}
});
primary_menu_toggle.on('keydown', function (e) {
var tabKey = e.keyCode === 9;
var shiftKey = e.shiftKey;
if( primary_menu_toggle.hasClass('active') ) {
if ( shiftKey && tabKey ) {
e.preventDefault();
primary_nav_menu.slideUp();
$('.main-navigation').removeClass('menu-open');
$('.menu-overlay').removeClass('active');
primary_menu_toggle.removeClass('active');
};
}
});
top_button_menu_toggle.on('keydown', function (e) {
var tabKey = e.keyCode === 9;
var shiftKey = e.shiftKey;
if( top_button_menu_toggle.hasClass('active') ) {
if ( shiftKey && tabKey ) {
e.preventDefault();
top_nav_menu.slideUp();
$('.main-navigation').removeClass('menu-open');
$('.menu-overlay').removeClass('active');
top_button_menu_toggle.removeClass('active');
};
}
});
/*------------------------------------------------
END JQUERY
------------------------------------------------*/
});
( function( $ ) {
var container, button, menu, links, i, len;
// Add svg icon to submenu item.
var svg = '';
var dropdownToggle = $( '', { 'class': 'dropdown-toggle', 'aria-expanded': false });
dropdownToggle.append( svg );
$( '#secondary-navigation' ).find( '.menu-item-has-children > a, .page_item_has_children > a' ).after( dropdownToggle );
$( '#secondary-navigation .menu-item-has-children > a' ).append( svg );
container = document.getElementById( 'secondary-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;
}
menu.setAttribute( 'aria-expanded', 'false' );
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', '' );
button.setAttribute( 'aria-expanded', 'false' );
menu.setAttribute( 'aria-expanded', 'false' );
} else {
container.className += ' toggled';
button.setAttribute( 'aria-expanded', 'true' );
menu.setAttribute( 'aria-expanded', 'true' );
}
};
// Get all the link elements within the menu.
links = menu.getElementsByTagName( 'a' );
// Each time a menu link is focused or blurred, toggle focus.
for ( i = 0, len = links.length; i < len; i++ ) {
links[i].addEventListener( 'focus', toggleFocus, true );
links[i].addEventListener( 'blur', toggleFocus, true );
}
/**
* Sets or removes .focus class on an element.
*/
function toggleFocus() {
var self = this;
// Move up through the ancestors of the current link until we hit .nav-menu.
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
// On li elements toggle the class .focus.
if ( 'li' === self.tagName.toLowerCase() ) {
if ( -1 !== self.className.indexOf( 'focus' ) ) {
self.className = self.className.replace( ' focus', '' );
} else {
self.className += ' focus';
}
}
self = self.parentElement;
}
}
} )( jQuery );