jQuery(document).ready(function($) {
// Responsive Menu
$('.menu-toggle').click(function() {
$(this).toggleClass('active');
$(this).parent().find('ul.nav-menu').slideToggle();
$(this).parent().find('div.nav-menu > ul').slideToggle();
});
$('.dropdown-toggle').click(function() {
$(this).toggleClass('active');
$(this).parent().find('.sub-menu').first().slideToggle();
$(this).parent().find('.children').first().slideToggle();
});
if( $(window).width() < 1024 ) {
$('#site-navigation .nav-menu').find("li").last().bind( 'keydown', function(e) {
if( !e.shiftKey && e.which === 9 ) {
e.preventDefault();
$('.site-header').find('.menu-toggle').focus();
}
});
}
else {
$('#site-navigation .nav-menu').find("li").unbind('keydown');
}
$(window).resize(function() {
if( $(window).width() < 1024 ) {
$('#site-navigation .nav-menu').find("li").last().bind( 'keydown', function(e) {
if( !e.shiftKey && e.which === 9 ) {
e.preventDefault();
$('.site-header').find('.menu-toggle').focus();
}
});
}
else {
$('#site-navigation .nav-menu').find("li").unbind('keydown');
}
});
$('.menu-toggle').on('keydown', function (e) {
var tabKey = e.keyCode === 9;
var shiftKey = e.shiftKey;
if( $('.menu-toggle').hasClass('active') ) {
if ( shiftKey && tabKey ) {
e.preventDefault();
$('#site-navigation .nav-menu').find("li:last-child > a").focus();
$('#site-navigation .nav-menu').find("li").last().bind( 'keydown', function(e) {
if( !e.shiftKey && e.which === 9 ) {
e.preventDefault();
$('.site-header').find('.menu-toggle').focus();
}
});
}
}
});
// Adds a search icon.
$('.search-form input[type="submit"]').replaceWith('');
// Sets scroll to top.
var scroll = $(window).scrollTop();
var scrollup = $('.to-top');
$(window).scroll(function() {
if ($(this).scrollTop() > 1) {
scrollup.css({bottom:"25px"});
}
else {
scrollup.css({bottom:"-100px"});
}
});
scrollup.click(function() {
$('html, body').animate({scrollTop: '0px'}, 800);
return false;
});
});
jQuery( document ).ready(function() {
jQuery(".homepage-temp h2").each(function() {
var t = jQuery(this).text();
var splitT = t.split(" ");
var halfIndex = 2;
var newText = "";
for(var i = 0; i < splitT.length; i++) {
if(i == halfIndex) {
newText += "";
newText += splitT[i] + " ";
newText += "";
}else{
newText += splitT[i] + " ";
}
}
jQuery(this).html(newText);
});
});