PageSourceSearch

https://1789hub.com/wp-content/themes/dyad-2/js/global.js?ver=20151204

js 1789hub.com collected 2026-10-04 02:15:50 UTC 6,576 bytes, 232 lines download raw bytes

1/**
2 * Theme frontend scripts
3 *
4 * @package    dyad
5 *
6 */
7
8( function( $ ) {
9
10	var $window = $( window );
11
12	$( '.no-js' ).removeClass( 'no-js' );
13
14	/**
15	 * Banner slider
16	 */
17
18	if ( $().slick ) {
19
20		$( '#site-banner.enable-slider .site-banner-inner' ).slick( {
21			'adaptiveHeight' : false,
22			'autoplay'       : true,
23			'autoplaySpeed'  : ( ! jQuery( '#site-banner' ).data( 'speed' ) ) ? ( 5400 ) : ( jQuery( '#site-banner' ).data( 'speed' ) ),
24			'cssEase'        : 'ease-in-out',
25			'dots'           : false,
26			'draggable'      : false,
27			'easing'         : 'easeInOutBack',
28			'fade'           : true,
29			'pauseOnHover'   : true,
30			'slide'          : 'article',
31			'speed'          : 600,
32			'swipeToSlide'   : true,
33			'prevArrow'      : '<div class="slider-nav slider-nav-prev"><button type="button" class="slick-prev"><span class="genericon genericon-expand"></span></button></div>',
34			'nextArrow'      : '<div class="slider-nav slider-nav-next"><button type="button" class="slick-next"><span class="genericon genericon-expand"></span></button></div>'
35		} );
36
37	}
38
39
40	/**
41	 * Page scrolled?
42	 */
43
44	if ( 0 == $window.scrollTop() ) {
45		$( 'body' ).addClass( 'not-scrolled' )
46	}
47
48	$window.on( 'scroll', function( e ) {
49		if ( 0 == $window.scrollTop() ) {
50			$( 'body' ).addClass( 'not-scrolled' ).removeClass( 'is-scrolled' );
51		} else {
52			$( 'body' ).addClass( 'is-scrolled' ).removeClass( 'not-scrolled' );
53		}
54	} );
55
56
57	/*
58	 * Add 'focus' style to contact form
59	 */
60
61	$('.comment-form-author input, .comment-form-email input, .comment-form-url input, .comment-form-comment textarea').focus( function() {
62		$( this ).parent().addClass( 'focus' );
63	} ).blur( function() {
64		if( "" == $( this). val() ) {
65			$( this ).parent().removeClass( 'focus' );
66		}
67	} );
68
69	/*
70	 * Make sure 'Add Yours' comment link doesn't overshoot the form when header is fixed
71	 */
72
73	$( '.add-comment-link' ).click( function( e ) {
74		if( $( window ).width() > 1400 ) {
75			e.preventDefault();
76			var offset = $( '#respond' ).offset();
77			var scrollto = offset.top - ( $('#masthead').innerHeight() + 50 );
78			$('html, body').animate({scrollTop:scrollto}, 0);
79		}
80	} );
81
82
83	/**
84	 * Make sure content isn't too high in grid view
85	 */
86
87	function adjustPosts() {
88		$('.posts .entry-inner').each( function() {
89			var $contain = $(this),
90				$innerContainHeight = $('.entry-inner-content', this ).height(),
91				$linkMoreHeight = $( '.link-more', this ).height();
92				$header = $('.entry-header', this),
93				$headerHeight = $header.innerHeight(),
94				$content = $('.entry-content', this),
95				$contentHeight = $content.innerHeight(),
96				$wholeContentHeight = $headerHeight + $contentHeight;
97
98			if ( ( $innerContainHeight - $linkMoreHeight ) < $wholeContentHeight ) {
99				$contain.parent().addClass('too-short');
100			} else {
101				$contain.parent().removeClass('too-short');
102			}
103		} );
104	}
105
106
107	/**
108	 * Adjust header height
109	 */
110
111	function adjustHeaderHeight() {
112	 	var $header = $('#masthead'),
113	 		$headerHeight = $header.outerHeight() + 50;
114
115	 	if( $('body').hasClass('blog') || $('body').hasClass('home')  ) {
116			if( $('.site-banner-header').length !== 0 && $('.site-banner-header').offset().top <= $headerHeight ) {
117		 		$('.site-banner').addClass('too-tall');
118			}
119
120		} else {
121			$('body:not(.blog, .home, .single-format-image.has-post-thumbnail) .site-content').css('padding-top', $headerHeight );
122		}
123	}
124
125	/**
126	 * Masonry for footer widgets
127	 */
128
129	function widgetMasonry() {
130
131	 	// Make sure we're on a larger screen
132		if ( 'none' !== $( '#colophon .widget-area .widget:first-of-type' ).css( 'float' ) ) {
133			// Determine text direction
134			var ltr = true;
135			if ( $('html' ).attr( 'dir' ) == 'rtl') {
136				ltr = false;
137			}
138
139			$grid = $( '.grid-container' ).masonry( {
140				itemSelector: '.widget',
141				columnWidth: '.widget-area aside',
142				isOriginLeft: ltr,
143			} );
144
145			// Re-fire masonry after set of time, for any late-loading widgets
146			setTimeout( function() { $grid.masonry( 'layout' ); }, 2000 );
147		}
148	}
149
150	/**
151	 * Firing events
152	 */
153
154	// Fire on load
155	$( window ).on( 'load', function() {
156		widgetMasonry();
157	} );
158
159	// Fire on document ready
160	$( document ).ready(function(){
161		adjustPosts();
162		adjustHeaderHeight();
163
164		// Make sure we're on a larger screen
165		if ( 'none' !== $( '#colophon .widget-area .widget:first-of-type' ).css( 'float' ) ) {
166
167			// Set some min-heights to help improve Masonry's treatment of these widgets
168
169			// Get Twitter widgets and set a min-height on parent elements
170			$( 'a.twitter-timeline' ).each( function() {
171
172				var thisHeight = $( this ).attr( 'data-height' );
173
174				// Set the widget to have this height
175				$( this ).parent().css( 'min-height', thisHeight + 'px' );
176			} );
177
178			// Get Facebook widgets and set a min-height on parent elements
179			$( '.fb-page' ).each( function() {
180
181				// Get some settings from the initial markup:
182				var $set_height = $( this ).data( 'height' ),
183					$hide_cover = $( this ).data( 'hide-cover' ),
184					$show_facepile = $( this ).data( 'show-facepile' ),
185					$show_posts = $( this ).data( 'show-posts' ), // AKA stream
186					$min_height = $set_height; // set the default 'min-height'
187
188				// These values are defaults from the FB widget.
189				var $no_posts_no_faces = 130,
190					$no_posts = 220;
191
192				if ( $show_posts ) {
193					// Showing posts; may also be showing faces and/or cover - the latter doesn't affect the height at all.
194					$min_height = $set_height;
195
196				} else if ( $show_facepile ) {
197					// Showing facepile with or without cover image - both would be same height.
198					// If the user selected height is lower than the no_posts height, we'll use that instead
199					$min_height = ( $set_height < $no_posts ) ? $set_height : $no_posts;
200
201				} else {
202					// Either just showing cover, or nothing is selected (both are same height).
203					// If the user selected height is lower than the no_posts_no_faces height, we'll use that instead
204					$min_height = ( $set_height < $no_posts_no_faces ) ? $set_height : $no_posts_no_faces;
205				}
206
207				// apply min-height to .fb-page container
208				$( this ).css( 'min-height', $min_height + 'px' );
209			} );
210		}
211	} );
212
213	//Fire on window resize
214	var resizeTimer;
215
216	$( window ).on( 'resize', function() {
217		clearTimeout( resizeTimer );
218		resizeTimer = setTimeout( function() {
219			adjustPosts();
220			adjustHeaderHeight();
221
222			// Fire Masonry, in case we're moving from mobile to desktop
223			widgetMasonry();
224		}, 250 );
225	} );
226
227	// if Infinite Scroll, fire again when new posts are loaded
228	$( document.body ).on( 'post-load', function() {
229		adjustPosts();
230	} );
231
232} )( 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.