PageSourceSearch

https://www.californiastrawberries.com/wp-content/themes/layers-el…/assets/js/layers.framework.js?ver=1.0.3

js californiastrawberries.com collected 2026-10-02 07:20:32 UTC 6,489 bytes, 229 lines download raw bytes

1/**
2 * Layers JS file
3 *
4 * This file contains all theme JS functions, from height matching to button toggling
5 *
6 * @package Layers
7 * @since Layers 1.0.0
8 * Contents
9 * 1 - Container padding on first widgets for header fixed
10 * 2 - Offsite sidebar Toggles
11 * 3 - Sticky Header
12 * 4 - FitVids
13 * 5 - Layers Custom Easing
14 * 6 - Swiper Height Matching Functions
15 * 7 - Container padding on first widgets for header fixed - helper function.
16 *
17 * Author: Obox Themes
18 * Author URI: http://www.oboxthemes.com/
19 * License: GNU General Public License v2 or later
20 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
21*/
22
23jQuery(function($) {
24
25	/**
26	* 1 - Container padding on first widgets for header fixed
27	*/
28
29	$(window).on('load', function() {
30		layers_apply_overlay_header_styles();
31	});
32
33	/**
34	* 2 - Offsite sidebar Toggles
35	*/
36
37	$(document).on( 'click' , '[data-toggle^="#"]'  , function(e){
38
39		e.preventDefault();
40
41		// "Hi Mom"
42		$that = $(this);
43
44		// Setup target ID
45		$target = $that.data( 'toggle' );
46
47		// Toggle .open class
48		$( $target ).toggleClass( $that.data( 'toggle-class' ) );
49
50		return false;
51
52	});
53
54    // Remove toggle on click of area which is not affected by toggle
55    $(document).on( 'click' , function(e) {
56
57        $('[data-toggle^="#"]').each(function() {
58            var $that = $(this);
59
60            // Get the target with hash
61            var $target =  $that.data( 'toggle' );
62
63            // Get the target id without hash
64            var $targetId = $target.replace(/^#/,'');
65
66            // Get the toggle class
67            var toggleClass = $that.data( 'toggle-class' );
68
69            if (
70                // If click is not made on the element itself
71            e.target.id != $targetId &&
72            // And if click is not inside the element
73            !$( e.target ).parents($target).size() &&
74            // And the target element has the toggled class
75            $( $target ).hasClass(toggleClass)
76            ) {
77                // Try to close it
78                $( $target ).toggleClass(toggleClass);
79
80                // Even if a single element is closed then prevent the default
81                // click that was executed
82                e.preventDefault && e.preventDefault();
83            }
84        });
85    });
86	/**
87	* 3 - Sticky Header
88	*/
89
90	// Set site header element
91	$header_sticky = $("section.header-sticky");
92
93	// Handle scroll passsing the go-sticky position.
94	$("body").waypoint({
95		offset 	: - layers_script_settings.header_sticky_breakpoint,
96		handler	: function(direction) {
97			if ( 'down' == direction ) {
98
99				// Sticky the header
100				$header_sticky.stick_in_parent({
101					parent: 'body'
102				});
103
104				// Clear previous timeout to avoid duplicates.
105				clearTimeout( $header_sticky.data( 'timeout' ) );
106
107				// Show header miliseconds later so we can css animate in.
108				$header_sticky.data( 'timeout', setTimeout( function() {
109					$header_sticky.addClass('is_stuck_show');
110				}, '10' ) );
111			}
112		}
113	});
114
115	// Handle scroll ariving at page top.
116	$("body").waypoint({
117		offset 	: -1,
118		handler	: function(direction) {
119			if ( 'up' == direction ) {
120
121				// Clear previous timeout to avoid late events.
122				clearTimeout( $header_sticky.data( 'timeout' ) );
123
124				// Detach the header
125				$header_sticky.removeClass('is_stuck_show');
126				$header_sticky.trigger("sticky_kit:detach");
127			}
128		}
129	});
130
131	/**
132	* 4 - FitVids resposive video embeds.
133	*
134	* Target your .container, .wrapper, .post, etc.
135	*/
136
137	$(".media-image, .thumbnail-media, .widget.slide .image-container, .post .thumbnail").fitVids();
138
139	/**
140	* 5 - Layers Custom Easing
141	*
142	* Extend jQuery easing with custom Layers easing function for UI animations - eg slideUp, slideDown
143	*/
144
145	// easeInOutQuad
146	jQuery.extend( jQuery.easing, { layersEaseInOut: function (x, t, b, c, d) {
147		if ((t/=d/2) < 1) return c/2*t*t + b;
148		return -c/2 * ((--t)*(t-2) - 1) + b;
149	}});
150});
151
152/**
153* 6 - Swiper Height Matching Functions
154*
155*/
156
157function layers_swiper_resize( s ){
158
159	// Find the highest slide, and set the Swiper container to that height.
160	var height = 0;
161	s.slides.each(function( key, slide ){
162
163		var slide_height = jQuery(slide).find( '.container' ).outerHeight();
164		if ( jQuery(slide).find( '.content' ).outerHeight() ) slide_height += jQuery(slide).find( '.content' ).outerHeight();
165		if ( jQuery(slide).find( '.content' ).height() ) slide_height -= jQuery(slide).find( '.content' ).height();
166
167		if( height < slide_height ){
168			height = slide_height;
169		}
170	});
171	s.container.css({ height: height+'px' });
172}
173
174/**
175 * 7 - Container padding on first widgets for header fixed - helper function.
176 */
177
178var $first_element;
179function layers_apply_overlay_header_styles() {
180
181	// Get header.
182	$header = jQuery( '.header-site' );
183	$header_height = $header.outerHeight();
184
185	// Get content wrapper.
186	$content_wrapper = jQuery( '#wrapper-content' );
187
188	if( $header.hasClass( 'header-overlay' ) ) {
189
190		// Get first element.
191		if( ! $first_element ) $first_element = $content_wrapper.children().eq(0);
192
193		if( 'A' == $first_element.prop("tagName") ) $first_element = $content_wrapper.children( '.widget' ).eq(0);
194
195		if( $first_element.hasClass( 'slide' ) && !$first_element.hasClass( '.full-screen' ) ) {
196
197			// Reset previous incase this is being re-aplied due to window resize.
198			// $first_element.find('.swiper-slide > .content' ).css('padding-top', '' );
199
200			// $first_element_height = $first_element.outerHeight();
201
202			// var padding_top = $first_element.find('.swiper-slide > .content' ).eq(0).css('padding-top').replace('px', '');
203			// padding_top = ( '' != padding_top ) ? parseInt( padding_top ) : 0 ;
204
205			// First element is Slider Widget.
206			// $first_element.css( 'height', ( $header_height + $first_element_height ) );
207			// $first_element.find('.swiper-slide' ).css( 'height', ( $header_height + $first_element_height ) );
208			// $first_element.css( 'height', ( $first_element_height - $header_height ) );
209
210
211			jQuery('body').addClass( 'header-overlay-no-push' );
212		}
213		else if( $first_element.hasClass('title-container') ) {
214
215			// Reset previous incase this is being re-aplied due to window resize.
216			$first_element.css('padding-top', '' );
217
218			var padding_top = $first_element.css('padding-top').replace('px', '');
219			padding_top = ( '' != padding_top ) ? parseInt( padding_top ) : 0 ;
220
221			// First element is Title (eg WooCommerce).
222			$first_element.css({ 'paddingTop': $header_height + padding_top });
223			jQuery('body').addClass( 'header-overlay-no-push' );
224		}
225		else{
226		}
227
228	}
229}

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.