PageSourceSearch

https://www.femaletrainer.co.uk/wp-content/plugins/fitness-club/bt_grid.js?ver=6.7.9

js femaletrainer.co.uk collected 2026-10-04 21:23:41 UTC 8,664 bytes, 261 lines download raw bytes

1(function( $ ) {
2	
3	var BT_Grid = function() {
4		this.bt_no_posts = false;
5		this.bt_loading_grid = false;
6		this.bt_ajax_req = [];
7		this.bt_ajax_elems_all = [];
8	};
9	
10	var BT_Grid_array = [];
11
12	$( document ).ready(function() {
13	
14		$( '.tilesWall.btAjaxGrid' ).each(function() {
15			
16			var root = $( this ).closest( '.btGridContainer' );
17			
18			root.data( 'index', BT_Grid_array.length );
19			
20			var grid = new BT_Grid();
21			BT_Grid_array.push( grid );
22
23			grid.bt_scroll_loading = $( this ).data( 'scroll-loading' ) == 'yes' ? true : false;
24			grid.bt_grid_type = $( this ).data( 'grid-type' );
25			grid.bt_tiled_format = $( this ).data( 'format' ) + '';
26			if ( grid.bt_tiled_format != '' ) {
27				grid.bt_tiled_format = grid.bt_tiled_format.split( ',' );
28			} else {
29				grid.bt_tiled_format = [];
30			}
31			
32			if ( grid.bt_scroll_loading ) {
33				root.height( window.innerHeight );
34			}
35
36			$( this ).packery({
37				itemSelector: '.gridItem',
38				columnWidth: '.gridSizer',
39				gutter: 0,
40				percentPosition: true,
41				transitionDuration: 0,
42				isResizeBound: false
43			});
44
45		});
46		
47		bt_load_posts( $( '.tilesWall.btAjaxGrid' ) );
48		
49		$( '.btCatFilterItem.all' ).addClass( 'active' );
50		
51		$( '.btCatFilterItem' ).click(function() {
52			
53			var root = $( this ).closest( '.btGridContainer' );
54			
55			$( this ).closest( '.btCatFilter' ).find( '.btCatFilterItem' ).removeClass( 'active' );
56			$( this ).addClass( 'active' );
57			root.find( '.tilesWall.btAjaxGrid' ).data( 'cat-slug', $( this ).data( 'slug' ) );
58			
59			for ( var n = 0; n < BT_Grid_array[ root.data( 'index' ) ].bt_ajax_req.length; n++ ) {
60				BT_Grid_array[ root.data( 'index' ) ].bt_ajax_req[ n ].abort();
61			}
62			BT_Grid_array[ root.data( 'index' ) ].bt_ajax_req = [];
63			
64			root.height( root.height() );
65			
66			var $container = root.find( '.tilesWall.btAjaxGrid' ).packery();
67			$container.packery( 'remove', $( '.gridItem' ) );
68			$container.packery();
69
70			BT_Grid_array[ root.data( 'index' ) ].bt_grid_offset = 0;
71
72			BT_Grid_array[ root.data( 'index' ) ].bt_no_posts = false;
73			
74			root.find( '.btNoMore' ).hide();
75			root.find( '.btLoaderGrid' ).show();
76			
77			bt_load_posts( root.find( '.tilesWall.btAjaxGrid' ) );
78		});
79		
80	});
81	
82	$( window ).resize(function() {
83		$( '.tilesWall.btAjaxGrid' ).each(function() {
84			$c = $( this );
85			var root = $c.closest( '.btGridContainer' );
86			var index = root.data( 'index' );			
87			bt_packery_tweak( $c, BT_Grid_array[ index ].bt_grid_type );
88			setTimeout(function() {
89				bt_packery_tweak( $c, BT_Grid_array[ index ].bt_grid_type );
90			}, 150 );
91		});
92	});
93	
94	$( window ).scroll(function() {
95		$( '.btGridContainer' ).each(function() {
96			if ( bt_is_load_scroll( $( this ).data( 'index' ) ) && BT_Grid_array[ $( this ).data( 'index' ) ].bt_scroll_loading && ! BT_Grid_array[ $( this ).data( 'index' ) ].bt_no_posts && ! BT_Grid_array[ $( this ).data( 'index' ) ].bt_loading_grid ) {
97				BT_Grid_array[ $( this ).data( 'index' ) ].bt_loading_grid = true;
98				bt_load_posts( $( this ).find( '.tilesWall.btAjaxGrid' ) );
99			}
100		});
101	});
102
103	var bt_is_load_scroll = function( index ) {
104		var $c = $( '.btGridContainer' ).eq( index ).find( '.tilesWall.btAjaxGrid' );
105		var height = window.innerHeight
106		|| document.documentElement.clientHeight
107		|| document.body.clientHeight;
108		if ( $( window ).scrollTop() + height > $c.offset().top + $c.height() ) {
109			return true;
110		}
111		return false;
112	}
113
114	// ajax loader
115	
116	var bt_load_posts = function( target ) {
117		target.each(function() {
118			
119			var parent_element = $( this );
120			var root = parent_element.closest( '.btGridContainer' );
121			var index = root.data( 'index' );
122		
123			if ( typeof BT_Grid_array[ index ].bt_grid_offset === 'undefined' ) BT_Grid_array[ index ].bt_grid_offset = 0;
124			var num = parent_element.data( 'num' );
125			var data = {
126				'action': 'bt_get_grid',
127				'number': num,
128				'offset': BT_Grid_array[ index ].bt_grid_offset,
129				'cat_slug': parent_element.data( 'cat-slug' ),
130				'post_type': parent_element.data( 'post-type' ),
131				'grid_type': parent_element.data( 'grid-type' ),
132				'tiles_title': parent_element.data( 'tiles-title' ),
133				'related': parent_element.data( 'related' ),
134				'sticky_in_grid': parent_element.data( 'sticky' ),
135				'format': BT_Grid_array[ index ].bt_tiled_format.slice( BT_Grid_array[ index ].bt_grid_offset, BT_Grid_array[ index ].bt_grid_offset + num ).join()
136			};
137			BT_Grid_array[ index ].bt_grid_offset = BT_Grid_array[ index ].bt_grid_offset + num;
138			$( '.btLoaderGrid' ).css( 'opacity', '1' );
139			BT_Grid_array[ index ].bt_ajax_req.push($.ajax({
140				type: 'POST',
141				url: window.BoldThemesAJAXURL,
142				data: data,
143				async: true,
144				success: function( response ) {
145				
146					var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false );
147					
148					if ( ! BT_Grid_array[ index ].bt_scroll_loading ) $( '.btLoaderGrid' ).hide();
149
150					if ( response.indexOf( 'no_posts' ) == 0 ) {
151						$( '.btLoaderGrid' ).css( 'opacity', '0' );
152						$( '.btLoaderGrid' ).hide();
153						if ( BT_Grid_array[ index ].bt_scroll_loading ) $( '.btNoMore' ).fadeIn();
154						BT_Grid_array[ index ].bt_no_posts = true;
155						return;
156					}
157					
158					$post = JSON.parse( response );
159
160					BT_Grid_array[ index ].bt_ajax_elems = [];
161					
162					$( '.btLoaderGrid' ).css( 'opacity', '0' );
163
164					for ( var i = 0; i < $post.length; i++ ) {
165						var elem = document.createElement( 'div' );
166						elem.className = $post[ i ].container_class;
167
168						$( elem ).append( $post[ i ].html );
169						
170						BT_Grid_array[ index ].bt_ajax_elems.push( elem );
171						BT_Grid_array[ index ].bt_ajax_elems_all.push( elem );
172						
173						$( elem ).attr( 'data-i', i );
174						
175						imagesLoaded( BT_Grid_array[ index ].bt_ajax_elems_all[ BT_Grid_array[ index ].bt_ajax_elems_all.length - 1 ], function() {
176							var n = $( this.elements[0] ).attr( 'data-i' );
177							$( this.elements[0] ).css( { 'transition-delay': .1 + n * .1 + 's' } );
178							$( this.elements[0] ).addClass( 'btGridItemLoaded' );
179						});
180					}
181
182					for ( var i = 0; i < BT_Grid_array[ index ].bt_ajax_elems.length; i++ ) {
183
184						parent_element.append( BT_Grid_array[ index ].bt_ajax_elems[ i ] );
185						
186						var $container = parent_element.packery();
187						$container.packery( 'appended', BT_Grid_array[ index ].bt_ajax_elems[ i ] );
188						
189						bt_packery_tweak( parent_element, BT_Grid_array[ index ].bt_grid_type );
190						
191						if ( BT_Grid_array[ index ].bt_grid_type == 'classic' ) {
192							$( '.btMediaBox' ).each(function() {
193								if ( $( this ).attr( 'data-hw' ) != undefined ) {
194									$( this ).height( $( this ).outerWidth( true ) * $( this ).attr( 'data-hw' ) );
195								}
196							});
197						}
198						
199						bt_packery_tweak( parent_element, BT_Grid_array[ index ].bt_grid_type );
200						
201						$( '.btAjaxGrid .boldPhotoSlide:not(.btFeaturedPostsSlider)' ).each(function() {
202							if ( ! $( this ).hasClass( 'slick-initialized' ) ) {
203								$( this ).slick({
204									dots: false,
205									arrows: true,
206									infinite: false,
207									speed: 300,
208									slide: '.bpbItem',
209									slidesToShow: 1,
210									slidesToScroll: 1,
211									useTransform: true,
212									prevArrow: window.boldthemes_prevArrowHtml_simple,
213									nextArrow: window.boldthemes_nextArrowHtml_simple
214								});
215							}
216						});
217
218						$( '.btAjaxGrid .boldPhotoSlide.btFeaturedPostsSlider' ).each(function() {
219							if ( ! $( this ).hasClass( 'slick-initialized' ) ) {
220								$( this ).slick({
221									dots: false,
222									arrows: true,
223									infinite: false,
224									speed: 300,
225									slide: '.bpbItem',
226									slidesToShow: 3,
227									slidesToScroll: 3,
228									prevArrow: window.bt_prevArrowHtml,
229									nextArrow: window.bt_nextArrowHtml,
230									responsive: [
231										{
232											breakpoint: 880,
233											settings: {
234												slidesToShow: 1,
235												slidesToScroll: 1
236											}
237										}
238									]
239								});
240							}
241						});
242					}
243
244					BT_Grid_array[ index ].bt_loading_grid = false;
245					
246					$( '.btGridContainer' ).css( 'height', 'auto' );
247
248					if ( bt_is_load_scroll( index ) && BT_Grid_array[ index ].bt_scroll_loading && ! BT_Grid_array[ index ].bt_no_posts ) {
249						bt_load_posts( parent_element );
250					}
251
252				},
253				error: function( xhr, status, error ) {
254					parent_element.find( '.btLoaderGrid' ).css( 'opacity', '0' );
255				}
256				
257			}));
258		});
259	}
260
261})( 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.