jQuery(function($){ "use strict"; jQuery('.main-menu-navigation > ul').superfish({ delay: 500, animation: {opacity:'show',height:'show'}, speed: 'fast' }); }); function cafe_alley_resmenu() { /* First and last elements in the menu */ var cafe_alley_firstTab = jQuery('.main-menu-navigation ul:first li:first a'); var cafe_alley_lastTab = jQuery('.sidebar .closebtn'); /* Cancel button will always be last */ jQuery(".resToggle").click(function(e){ e.preventDefault(); e.stopPropagation(); jQuery('body').addClass("mobilemenu-open"); cafe_alley_firstTab.focus(); }); jQuery(".sidebar .closebtn").click(function(e){ e.preventDefault(); e.stopPropagation(); jQuery('body').removeClass("mobilemenu-open"); jQuery(".resToggle").focus(); }); /* Redirect last tab to first input */ cafe_alley_lastTab.on('keydown', function (e) { if (jQuery('body').hasClass('mobilemenu-open')) if ((e.which === 9 && !e.shiftKey)) { e.preventDefault(); cafe_alley_firstTab.focus(); } }); /* Redirect first shift+tab to last input*/ cafe_alley_firstTab.on('keydown', function (e) { if (jQuery('body').hasClass('mobilemenu-open')) if ((e.which === 9 && e.shiftKey)) { e.preventDefault(); cafe_alley_lastTab.focus(); } }); /* Allow escape key to close menu */ jQuery('.sidebar').on('keyup', function(e){ if (jQuery('body').hasClass('mobilemenu-open')) if (e.keyCode === 27 ) { jQuery('body').removeClass('mobilemenu-open'); cafe_alley_lastTab.focus(); }; }); } jQuery(document).ready(function () { cafe_alley_resmenu(); }); (function( $ ) { $(window).scroll(function(){ var sticky = $('.sticky-menubox'), scroll = $(window).scrollTop(); if (scroll >= 100) sticky.addClass('fixed-menubox'); else sticky.removeClass('fixed-menubox'); }); })( jQuery ); var resizeElements; jQuery(document).ready(function($) { // Set up common variables var bar = ".search_bar"; var input = bar + " input[type='text']"; var button = bar + " button[type='submit']"; var dropdown = bar + " .search_dropdown"; var dropdownLabel = dropdown + " > span"; var dropdownList = dropdown + " ul"; var dropdownListItems = dropdownList + " li"; // Set up common functions resizeElements = function() { var barWidth = $(bar).outerWidth(); var labelWidth = $(dropdownLabel).outerWidth(); $(dropdown).width(labelWidth); var dropdownWidth = $(dropdown).outerWidth(); var buttonWidth = $(button).outerWidth(); var inputWidth = barWidth - dropdownWidth - buttonWidth; var inputWidthPercent = inputWidth / barWidth * 100 + "%"; $(input).css({ 'margin-left': dropdownWidth, 'width': inputWidthPercent }); } function dropdownOn() { $(dropdownList).fadeIn(25); $(dropdown).addClass("active"); } function dropdownOff() { $(dropdownList).fadeOut(25); $(dropdown).removeClass("active"); } // Initialize resizeElements(); $(dropdown).click(function(event) { if ($(dropdown).hasClass("active")) { dropdownOff(); } else { dropdownOn(); } event.stopPropagation(); return false; }); $("html").click(dropdownOff); $(dropdownListItems).click(function() { $(this).siblings("li.selected").removeClass("selected"); $(this).addClass("selected"); $(this).parents("form.search_bar:first").find("input[type=text]").focus(); var labelText = $(this).text(); $(dropdownLabel).text(labelText); resizeElements(); }); $(window).resize(function() { resizeElements(); }); });