PageSourceSearch

https://dietculturetimeline.com/wp-content/themes/daily-dish-pro/js/global.js?ver=1.0.0

js dietculturetimeline.com collected 2026-10-04 05:31:43 UTC 2,117 bytes, 96 lines download raw bytes

1/**
2 * This script adds the jquery effects to the Daily Dish Pro Theme.
3 *
4 * @package Daily Dish\JS
5 * @author StudioPress
6 * @license GPL-2.0+
7 */
8(function( $ ) {
9
10	// Make sure JS class is added.
11	$( document ).ready( function() {
12		$( 'body' ).addClass( 'js' );
13	});
14
15	// Set variables for header search.
16	var $header    = $( '.nav-primary' ),
17		$hsToggle  = $( '.toggle-header-search' ),
18		$hsWrap    = $( '#header-search-wrap' ),
19		$hsInput   = $hsWrap.find( 'input[type="search"]' );
20
21
22	// Handler for click a show/hide button.
23	$hsToggle.on( 'click', function( event ) {
24
25		event.preventDefault();
26
27		if ( $( this ).hasClass( 'close' ) ) {
28			hideSearch();
29		} else {
30			showSearch();
31		}
32
33	});
34
35	// Handler for pressing show/hide button.
36	$hsToggle.on( 'keydown', function( event ) {
37
38		// If tabbing from toggle button, and search is hidden, exit early.
39		if ( event.keyCode === 9 && ! $header.hasClass( 'search-visible' ) ) {
40			return;
41		}
42
43		event.preventDefault();
44		handleKeyDown( event );
45
46	});
47
48	// Hide search when tabbing or escaping out of the search bar.
49	$hsInput.on( 'keydown', function( event ) {
50
51		// Tab: 9, Esc: 27.
52		if ( event.keyCode === 9 || event.keyCode === 27 ) {
53			hideSearch( event.target );
54		}
55
56	});
57
58	// Hide search on blur, such as when clicking outside it.
59	$hsInput.on( 'blur', hideSearch );
60
61	// Helper function to show the search form.
62	function showSearch() {
63
64		$header.addClass( 'search-visible' );
65		$hsWrap.fadeIn( 'fast' ).find( 'input[type="search"]' ).focus();
66		$hsToggle.attr( 'aria-expanded', true );
67
68	}
69
70	// Helper function to hide the search form.
71	function hideSearch() {
72
73		$hsWrap.fadeOut( 'fast' ).parents( '.nav-primary' ).removeClass( 'search-visible' );
74		$hsToggle.attr( 'aria-expanded', false );
75
76	}
77
78	// Keydown handler function for toggling search field visibility.
79	function handleKeyDown( event ) {
80
81		// Enter/Space, respectively.
82		if ( event.keyCode === 13 || event.keyCode === 32 ) {
83
84			event.preventDefault();
85
86			if ( $( event.target ).hasClass( 'close' ) ) {
87				hideSearch();
88			} else {
89				showSearch();
90			}
91
92		}
93
94	}
95
96})( 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.