jQuery(document).ready(function($){
moveNavigation();
$(window).on('resize', function(){
(!window.requestAnimationFrame) ? setTimeout(moveNavigation, 300) : window.requestAnimationFrame(moveNavigation);
});
$('.webmaster-nav-trigger').on('click', function(event){
event.preventDefault();
if($('header').hasClass('webmaster-is-visible')) $('.webmaster-moves-out').removeClass('webmaster-moves-out');
$('header').toggleClass('webmaster-is-visible');
$('.webmaster-main-nav').toggleClass('webmaster-is-visible');
$('.webmaster-main-content').toggleClass('webmaster-is-visible');
});
$('.webmaster-main-back').on('click', function(event){
event.preventDefault();
$('.webmaster-main-nav').removeClass('webmaster-moves-out');
});
$('.webmaster-subnav-trigger').on('click', function(event){
event.preventDefault();
$('.webmaster-main-nav').toggleClass('webmaster-moves-out');
});
function moveNavigation(){
var navigation = $('.webmaster-main-nav-wrapper');
var screenSize = checkWindowWidth();
if ( screenSize ) {
navigation.detach();
navigation.insertBefore('.webmaster-nav-trigger');
} else {
navigation.detach();
navigation.insertAfter('.webmaster-main-content');
}
}
function checkWindowWidth() {
var mq = window.getComputedStyle(document.querySelector('header'), '::before').getPropertyValue('content').replace(/"/g, '').replace(/'/g, "");
return ( mq == 'mobile' ) ? false : true;
}
});