PageSourceSearch

https://candypo.com/wp-content/themes/foodiepro-2.1.7/assets/js/general.js?ver=2.1.7

js candypo.com collected 2026-09-26 19:35:56 UTC 4,438 bytes, 164 lines download raw bytes

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 * Dear 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		$navs     = $( 'nav' );
109
110	/**
111	 * Debounce a window resize event.
112	 */
113	function debouncedResize( c, t ) {
114		onresize = function() {
115			clearTimeout( t );
116			t = setTimeout( c, 100 );
117		};
118		return c;
119	}
120
121	/**
122	 * Check whether or not a given element is visible.
123	 *
124	 * @param  {object} $object a jQuery object to check
125	 * @return {bool} true if the current element is hidden
126	 */
127	function isHidden( $object ) {
128		var element = $object[0];
129		return ( null === element.offsetParent );
130	}
131
132	function addNavToggles() {
133		$navs.before( '<div class="menu-toggle"><span></span></div>' );
134		$navs.find( '.sub-menu' ).before( '<div class="sub-menu-toggle"></div>' );
135	}
136
137	function showHideNav() {
138		$( '.menu-toggle, .sub-menu-toggle' ).on( 'click', function() {
139			var $that = $( this );
140			$that.toggleClass( 'active' );
141			$that.next( 'nav, .sub-menu' ).slideToggle( 'slow' );
142		});
143	}
144
145	function reflowNavs() {
146		if ( isHidden( $navs ) ) {
147			$navs.removeAttr( 'style' );
148			$( '.sub-menu-toggle, .menu-toggle' ).removeClass( 'active' );
149		}
150	}
151
152	function navInit() {
153		addNavToggles();
154		showHideNav();
155		debouncedResize(function() {
156			reflowNavs();
157		})();
158	}
159
160	$document.ready(function() {
161		$document.gamajoAccessibleMenu();
162		navInit();
163	});
164}( 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.