PageSourceSearch

https://www.readfrontier.org/wp-content/themes/the-frontier/js/atomic-blocks.js?ver=1.0

js readfrontier.org collected 2026-10-02 05:05:31 UTC 4,556 bytes, 160 lines download raw bytes

1( function( $ ) {
2	'use strict';
3
4	$( document ).ready( function() {
5
6		$( window ).on( 'load', function() {
7			var current_width = $( window ).width();
8
9			// Only run on desktop
10			if ( 768 < current_width ) {
11
12				// Find menu items with a drop menu and center them
13		        $( '.main-navigation li' ).each( function() {
14		            if ( 0 < $( this ).find( 'ul:first-of-type' ).length ) {
15		                var parent_width = $( this ).outerWidth( true );
16		                var child_width  = $( this ).find( 'ul' ).outerWidth( true );
17		                var new_width    = parseInt( ( child_width - parent_width ) / 2 );
18		                $( this ).find( 'ul' ).css( 'margin-left', -new_width + 'px' );
19		            }
20		        });
21        	}
22		});
23
24
25		// Standardize drop menu types
26		$( '.main-navigation .children' ).addClass( 'sub-menu' );
27		$( '.main-navigation .page_item_has_children' ).addClass( 'menu-item-has-children' );
28
29
30		// Toggle the mobile menu
31		$( '.menu-toggle' ).click( function() {
32			$( '.mobile-navigation' ).toggleClass( 'toggle-active' );
33			$( '.drawer' ).toggle();
34			$( this ).find( 'span' ).toggle();
35		});
36
37		// Append a clickable icon to mobile drop menus
38		var item = $( '<button class="toggle-sub" aria-expanded="false"><i class="fa fa-angle-down"></i></button>' );
39
40		// Append clickable icon for mobile drop menu
41		if ( 0 == $( '.drawer .menu-item-has-children .toggle-sub' ).length ) {
42			$( '.drawer .menu-item-has-children,.drawer .page_item_has_children' ).append( item );
43		}
44
45		// Show sub menu when toggle is clicked
46		$( '.drawer .menu-item-has-children .toggle-sub' ).click( function( e ) {
47			$( this ).each( function() {
48				e.preventDefault();
49
50				// Change aria expanded value
51				$( this ).attr( 'aria-expanded', ( 'false' == $( this ).attr( 'aria-expanded' ) ) ? 'true' : 'false' );
52
53				// Open the drop menu
54				$( this ).closest( '.menu-item-has-children' ).toggleClass( 'drop-open' );
55				$( this ).prev( '.sub-menu' ).toggleClass( 'drop-active' );
56
57				// Change the toggle icon
58				$( this ).find( 'i' ).toggleClass( 'fa-angle-down' ).toggleClass( 'fa-angle-up' );
59			});
60		});
61
62
63		// // Fitvids
64		// function fitVids() {
65		// 	$('.post,.featured-image').fitVids();
66		// }
67		// fitVids();
68
69
70		// Scroll back to top
71		$( '.back-to-top a, .sticky-title' ).click( function( e ) {
72			e.preventDefault();
73
74			$( 'html,body' ).animate({
75			    scrollTop: 0
76			}, 700 );
77
78			return false;
79		});
80
81
82		// Infinite scroll
83		$( document.body ).on( 'post-load', function() {
84			var $container = $( '#post-wrap' );
85			var $newItems  = $( '.new-infinite-posts' ).not( '.is--replaced' );
86			var $elements  = $newItems.find( '.post' );
87
88			// Remove the empty elements that break the grid
89			$( '.new-infinite-posts,.infinite-loader' ).remove();
90
91			// Append IS posts
92			$container.append( $elements );
93
94			// Run fitvids on newly arrived posts
95			// fitVids();
96			const player = new Plyr( '.wp-block-embed-youtube > div' );
97		});
98
99
100		// Create the sticky nav bar if we're on the single page
101		if ( $( '.single .header-text h1' )[0]) {
102			var section_single = $( '#page' ).offset().top;
103
104			// Show the nav bar when we get to the post title
105			$( window ).scroll( function() {
106				if ( $( window ).scrollTop() > section_single ) {
107					$( '.home-nav' ).addClass( 'show-nav' );
108				} else {
109					$( '.home-nav' ).removeClass( 'show-nav' );
110				}
111			});
112		}
113
114
115		// Search togle
116		$( '.search-toggle' ).click( function( e ) {
117
118			// Add a class to the header
119			$( '.site-header' ).toggleClass( 'search-drawer-open' );
120
121			// Toggle the expanded tag
122			$( '.search-drawer' ).attr( 'aria-expanded', ( 'false' == $( '.search-drawer' ).attr( 'aria-expanded' ) ) ? 'true' : 'false' ).slideToggle( 200 );
123
124			// Set the focus when the search is opened
125			$( '.big-search .search-input' ).focus();
126
127			// Change the toggle icon
128			$( '.search-toggle i' ).toggle();
129
130			return false;
131		});
132
133
134		// Close the search drawer
135		function closeDrawer() {
136			$( '.search-drawer' ).attr( 'aria-expanded', 'false' ).slideUp( 200 );
137			$( '.search-toggle span' ).hide();
138			$( '.search-drawer-open .search-toggle i' ).toggle();
139			$( '.site-header' ).removeClass( 'search-drawer-open' );
140		}
141
142
143		// Escape key closes drawer
144		$( document ).keyup( function( e ) {
145		    if ( 27 == e.keyCode ) {
146
147				// Hide any drawers that are open
148				closeDrawer();
149		    }
150		});
151
152
153		// Allow clicking in the drawer when it's open
154		$( '.search-drawer' ).click( function( event ) {
155		    event.stopPropagation();
156		});
157
158	});
159
160}( 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.