PageSourceSearch

https://blog.museuciencies.cat/wp-content/themes/dyad/js/global.js?ver=20151204

js museuciencies.cat collected 2026-10-02 03:13:48 UTC 6,452 bytes, 229 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				$header = $('.entry-header', this),
92				$headerHeight = $header.innerHeight(),
93				$content = $('.entry-content', this),
94				$contentHeight = $content.innerHeight(),
95				$wholeContentHeight = $headerHeight + $contentHeight;
96
97			if ( $innerContainHeight < $wholeContentHeight ) {
98				$contain.parent().addClass('too-short');
99			} else {
100				$contain.parent().removeClass('too-short');
101			}
102		} );
103	}
104
105
106	/**
107	 * Adjust header height
108	 */
109
110	function adjustHeaderHeight() {
111	 	var $header = $('#masthead'),
112	 		$headerHeight = $header.outerHeight() + 50;
113
114	 	if( $('body').hasClass('blog') || $('body').hasClass('home')  ) {
115			if( $('.site-banner-header').length !== 0 && $('.site-banner-header').offset().top <= $headerHeight ) {
116		 		$('.site-banner').addClass('too-tall');
117			}
118
119		} else {
120			$('body:not(.blog, .home, .single-format-image.has-post-thumbnail) .site-content').css('padding-top', $headerHeight );
121		}
122	}
123
124	/**
125	 * Masonry for footer widgets
126	 */
127
128	function widgetMasonry() {
129	 	// Make sure we're on a larger screen
130		if ( 'none' !== $( '#colophon .widget-area .widget:first-of-type' ).css( 'float' ) ) {
131			// Determine text direction
132			var ltr = true;
133			if ( $('html' ).attr( 'dir' ) == 'rtl') {
134				ltr = false;
135			}
136
137			$( '.grid-container' ).masonry( {
138				itemSelector: '.widget',
139				columnWidth: '.widget-area aside',
140				isOriginLeft: ltr,
141			} );
142		}
143	}
144
145	/**
146	 * Firing events
147	 */
148
149	// Fire on load
150	$( window ).on( 'load', function() {
151		widgetMasonry();
152		// Re-fire masonry after set of time, for any late-loading widgets
153		setTimeout( widgetMasonry, 2000 );
154	} );
155
156	// Fire on document ready
157	$( document ).ready(function(){
158		adjustPosts();
159		adjustHeaderHeight();
160
161		// Make sure we're on a larger screen
162		if ( 'none' !== $( '#colophon .widget-area .widget:first-of-type' ).css( 'float' ) ) {
163
164			// Set some min-heights to help improve Masonry's treatment of these widgets
165
166			// Get Twitter widgets and set a min-height on parent elements
167			$( 'a.twitter-timeline' ).each( function() {
168
169				var thisHeight = $( this ).attr( 'height' );
170
171				// Set the widget to have this height
172				$( this ).parent().css( 'min-height', thisHeight + 'px' );
173			} );
174
175			// Get Facebook widgets and set a min-height on parent elements
176			$( '.fb-page' ).each( function() {
177
178				// Get some settings from the initial markup:
179				var $set_height = $( this ).data( 'height' ),
180					$hide_cover = $( this ).data( 'hide-cover' ),
181					$show_facepile = $( this ).data( 'show-facepile' ),
182					$show_posts = $( this ).data( 'show-posts' ), // AKA stream
183					$min_height = $set_height; // set the default 'min-height'
184
185				// These values are defaults from the FB widget.
186				var $no_posts_no_faces = 130,
187					$no_posts = 220;
188
189				if ( $show_posts ) {
190					// Showing posts; may also be showing faces and/or cover - the latter doesn't affect the height at all.
191					$min_height = $set_height;
192
193				} else if ( $show_facepile ) {
194					// Showing facepile with or without cover image - both would be same height.
195					// If the user selected height is lower than the no_posts height, we'll use that instead
196					$min_height = ( $set_height < $no_posts ) ? $set_height : $no_posts;
197
198				} else {
199					// Either just showing cover, or nothing is selected (both are same height).
200					// If the user selected height is lower than the no_posts_no_faces height, we'll use that instead
201					$min_height = ( $set_height < $no_posts_no_faces ) ? $set_height : $no_posts_no_faces;
202				}
203
204				// apply min-height to .fb-page container
205				$( this ).css( 'min-height', $min_height + 'px' );
206			} );
207		}
208	} );
209
210	//Fire on window resize
211	var resizeTimer;
212
213	$( window ).on( 'resize', function() {
214		clearTimeout( resizeTimer );
215		resizeTimer = setTimeout( function() {
216			adjustPosts();
217			adjustHeaderHeight();
218
219			// Fire Masonry, in case we're moving from mobile to desktop
220			widgetMasonry();
221		}, 250 );
222	} );
223
224	// if Infinite Scroll, fire again when new posts are loaded
225	$( document.body ).on( 'post-load', function() {
226		adjustPosts();
227	} );
228
229} )( 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.