1/*! Gamajo Accessible Menu - v1.0.0 - 2014-09-08 2* https://github.com/GaryJones/accessible-menu 3* Copyright (c) 2014 Gary Jones; Licensed MIT */ 4;(function( $, window, document, undefined ) { 5 'use strict'; 6 7 var pluginName = 'gamajoAccessibleMenu', 8 hoverTimeout = []; 9 10 // The actual plugin constructor 11 function Plugin( element, options ) { 12 this.element = element; 13 // jQuery has an extend method which merges the contents of two or 14 // more objects, storing the result in the first object. The first object 15 // is generally empty as we don't want to alter the default options for 16 // future instances of the plugin 17 this.opts = $.extend({}, $.fn[ pluginName ].options, options ); 18 this.init(); 19 } 20 21 // Avoid Plugin.prototype conflicts 22 $.extend( Plugin.prototype, { 23 init: function() { 24 $( this.element ) 25 .on( 'mouseenter.' + pluginName, this.opts.menuItemSelector, this.opts, this.menuItemEnter ) 26 .on( 'mouseleave.' + pluginName, this.opts.menuItemSelector, this.opts, this.menuItemLeave ) 27 .find( 'a' ) 28 .on( 'focus.' + pluginName + ', blur.' + pluginName, this.opts, this.menuItemToggleClass ); 29 }, 30 31 /** 32 * Add class to menu item on hover so it can be delayed on mouseout. 33 * 34 * @since 1.0.0 35 */ 36 menuItemEnter: function( event ) { 37 // Clear all existing hover delays 38 $.each( hoverTimeout, function( index ) { 39 $( '#' + index ).removeClass( event.data.hoverClass ); 40 clearTimeout( hoverTimeout[ index ] ); 41 }); 42 // Reset list of hover delays 43 hoverTimeout = []; 44 45 $( this ).addClass( event.data.hoverClass ); 46 }, 47 48 /** 49 * After a short delay, remove a class when mouse leaves menu item. 50 * 51 * @since 1.0.0 52 */ 53 menuItemLeave: function( event ) { 54 var $self = $( this ); 55 // Delay removal of class 56 hoverTimeout[ this.id ] = setTimeout(function() { 57 $self.removeClass( event.data.hoverClass ); 58 }, event.data.hoverDelay ); 59 }, 60 61 /** 62 * Toggle menu item class when a link fires a focus or blur event. 63 * 64 * @since 1.0.0 65 */ 66 menuItemToggleClass: function( event ) { 67 $( this ).parents( event.data.menuItemSelector ).toggleClass( event.data.hoverClass ); 68 } 69 }); 70 71 // A really lightweight plugin wrapper around the constructor, 72 // preventing against multiple instantiations 73 $.fn[ pluginName ] = function( options ) { 74 this.each(function() { 75 if ( ! $.data( this, 'plugin_' + pluginName ) ) { 76 $.data( this, 'plugin_' + pluginName, new Plugin( this, options ) ); 77 } 78 }); 79 80 // chain jQuery functions 81 return this; 82 }; 83 84 $.fn[ pluginName ].options = { 85 // The CSS class to add to indicate item is hovered or focused 86 hoverClass: 'menu-item-hover', 87 88 // The delay to keep submenus showing after mouse leaves 89 hoverDelay: 250, 90 91 // Selector for general menu items. If you remove the default menu item 92 // classes, then you may want to call this plugin with this value 93 // set to something like 'nav li' or '.menu li'. 94 menuItemSelector: '.menu-item' 95 }; 96})( jQuery, window, document ); 97 98/** 99 * Seasoned Pro General Scripts 100 * 101 * @copyright Copyright (c) 2016, Shay Bocks 102 * @license MIT 103 */ 104(function( $, undefined ) { 105 'use strict'; 106 107 var $document = $( document ); 108 var $navs = $( 'nav' ); 109 110 /** 111 * Returns a function, that, as long as it continues to be invoked, will not 112 * be triggered. The function will be called after it stops being called for 113 * N milliseconds. 114 * 115 * @source underscore.js 116 * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ 117 * @param {Function} func to wrap 118 * @param {Number} wait in ms (`100`) 119 */ 120 function debounce( func, wait ) { 121 var timeout; 122 123 return function() { 124 var that = this; 125 var args = arguments; 126 127 clearTimeout( timeout ); 128 129 timeout = setTimeout( function() { 130 timeout = null; 131 func.apply( that, args ); 132 }, wait ); 133 }; 134 } 135 136 /** 137 * Check whether or not a given element is visible. 138 * 139 * @param {object} $object a jQuery object to check 140 * @return {bool} true if the current element is hidden 141 */ 142 function isHidden( $object ) { 143 var element = $object[0]; 144 145 if ( 'undefined' === typeof element ) { 146 return false;
147 } 148 149 return ( null === element.offsetParent ); 150 } 151 152 function addNavToggles() { 153 $navs.before( '<div class="menu-toggle"><span></span></div>' ); 154 $navs.find( '.sub-menu' ).before( '<div class="sub-menu-toggle"></div>' ); 155 } 156 157 function showHideNav() { 158 $( '.menu-toggle, .sub-menu-toggle' ).on( 'click', function() { 159 var $that = $( this ); 160 $that.toggleClass( 'active' ); 161 $that.next( 'nav, .sub-menu' ).slideToggle( 'slow' ); 162 }); 163 } 164 165 function reflowNavs() { 166 if ( isHidden( $navs ) ) { 167 $navs.removeAttr( 'style' ); 168 $( '.sub-menu-toggle, .menu-toggle' ).removeClass( 'active' ); 169 } 170 } 171 172 function navInit() { 173 if ( 0 !== $navs.length ) { 174 addNavToggles(); 175 showHideNav(); 176 $( window ).resize( debounce( reflowNavs, 200 ) ); 177 } 178 } 179 180 function toggleRecipeFilters() { 181 if ( ! $( document.body ).hasClass( 'page-template-filter-recipes' ) ) { 182 return; 183 } 184 185 var $sidebar = $( '.sidebar' ); 186 187 $( '.filter-toggle' ).on( 'click', function() { 188 var $that = $( this ); 189 $that.toggleClass( 'active' ); 190 $sidebar.find( '.filter-wrap' ).slideToggle( 'slow' ); 191 }); 192 } 193 194 $document.ready(function() { 195 $document.gamajoAccessibleMenu(); 196 navInit(); 197 toggleRecipeFilters(); 198 }); 199}( jQuery ) );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.