PageSourceSearch

https://www.dodho.com/wp-content/plugins/bold-page-builder/content…/bt_bb_post_grid.js?ver=5.5.2

js dodho.com collected 2026-09-24 09:16:49 UTC 5,155 bytes, 171 lines download raw bytes

1(function( $ ) {
2	"use strict";
3	
4	var bt_bb_post_grid_resize = function( root ) {
5		root.each(function() {
6			$( this ).find( '.bt_bb_grid_item' ).each(function() {
7				$( this ).find( '.bt_bb_grid_item_post_thumbnail' ).height( Math.floor( $( this ).width() * $( this ).data( 'hw' ) ) );
8			});
9		});
10	}
11
12	var bt_bb_post_grid_load_images = function( root ) {
13		root.each(function() {
14			var page_bottom = $( window ).scrollTop() + $( window ).height();
15			$( this ).find( '.bt_bb_grid_item' ).each(function() {
16				var this_top = $( this ).offset().top;
17				if ( this_top < page_bottom + $( window ).height() ) {
18					var img_src = $( this ).data( 'src' );
19					if ( img_src !== '' && $( this ).find( '.bt_bb_grid_item_post_thumbnail a' ).html() == '' ) {
20						$( this ).find( '.bt_bb_grid_item_post_thumbnail a' ).html( '<img src="' + img_src + '" alt="' + $( this ).data( 'alt' ) + '">' );
21					}
22				}
23			});
24		});
25	}
26
27	var bt_bb_post_grid_load_items = function( root ) {
28		root.each(function() {
29			var loading = root.data( 'loading' );
30			if ( loading === undefined || ( loading != 'loading' && loading != 'no_more' ) ) {
31				var page_bottom = $( window ).scrollTop() + $( window ).height();
32				$( this ).find( '.bt_bb_grid_item' ).each(function() {
33					var this_top = $( this ).offset().top;
34					if ( this_top < page_bottom + $( window ).height() ) {
35						if ( $( this ).is( ':last-child' ) ) {
36							var root_data_offset = root.data( 'offset' );
37							var offset = parseInt( root_data_offset === undefined ? 0 : root_data_offset ) + parseInt( root.data( 'number' ) );
38							bt_bb_post_grid_load_posts( root, offset );
39							return false;
40						}
41					}
42				});
43			}
44		});
45	}
46
47	var bt_bb_post_grid_load_posts = function( root, offset ) {
48
49		if ( offset == 0 ) {
50			root.addClass( 'bt_bb_grid_hide' );
51			root.find( '.bt_bb_grid_item' ).remove();
52			if ( root.hasClass( 'masonry' ) ) {
53				root.masonry( 'destroy' );
54			}
55		}
56
57		root.parent().find( '.bt_bb_post_grid_loader' ).show();
58
59		var action = 'bt_bb_get_grid';
60
61		var root_data_number = root.data( 'number' );
62
63		var data = {
64			'action': action,
65			'number': root_data_number,
66			'category': root.data( 'category' ),
67			'show': root.data( 'show' ),
68			'bt-bb-masonry-post-grid-nonce': root.data( 'bt-bb-masonry-post-grid-nonce' ),
69			'post-type': root.data( 'post-type' ),
70			'ignore-nonce': root.data( 'ignore-nonce' ),
71			'offset': offset
72		};
73
74		root.data( 'loading', 'loading' );
75
76		$.ajax({
77			type: 'POST',
78			url: ajax_object.ajax_url,
79			data: data,
80			async: true,
81			success: function( response ) {
82
83				if ( response == '' ) {
84					root.data( 'loading', 'no_more' );
85					root.parent().find( '.bt_bb_post_grid_loader' ).hide();
86					return;
87				}
88
89				var $content = $( response );
90				root.append( $content );
91				bt_bb_post_grid_resize( root );
92
93				root.data( 'offset', offset );
94
95				if ( offset > 0 ) {
96					root.masonry( 'appended', $content );
97				} else {
98					if ( $( 'html' ).attr( 'dir' ) == 'rtl' ) {
99						root.masonry({
100							columnWidth: '.bt_bb_grid_sizer',
101							itemSelector: '.bt_bb_grid_item',
102							gutter: 0,
103							percentPosition: true,
104							isRTL: true
105						});	
106					} else {
107						root.masonry({
108							columnWidth: '.bt_bb_grid_sizer',
109							itemSelector: '.bt_bb_grid_item',
110							gutter: 0,
111							percentPosition: true
112						});
113					}
114				}
115				root.parent().find( '.bt_bb_post_grid_loader' ).hide();
116				root.removeClass( 'bt_bb_grid_hide' );
117				$( '.bt_bb_grid_container' ).css( 'height', 'auto' );
118
119				bt_bb_post_grid_load_images( root );
120
121				if ( root.data( 'auto-loading' ) == 'auto_loading' ) {
122					root.data( 'loading', '' );
123				} else {
124					root.data( 'loading', 'no_more' );
125				}
126
127			},
128			error: function( response ) {
129				root.parent().find( '.bt_bb_post_grid_loader' ).hide();
130				root.removeClass( 'bt_bb_grid_hide' );			
131			}
132		});
133	}
134
135	$( document ).ready(function() {
136		
137		var grid_length = $( '.bt_bb_masonry_post_grid_content' ).length;
138		var i = 1;
139		$( '.bt_bb_masonry_post_grid_content' ).each(function() {
140			if ( i < grid_length ) {
141				$( this ).attr( 'data-auto-loading', '' );
142			}
143			i++;
144		});
145
146		$( window ).on( 'resize', function() {
147			bt_bb_post_grid_resize( $( '.bt_bb_masonry_post_grid_content' ) );
148		});
149
150		$( window ).on( 'scroll', function() {
151			bt_bb_post_grid_load_images( $( '.bt_bb_masonry_post_grid_content' ) );
152			bt_bb_post_grid_load_items( $( '.bt_bb_masonry_post_grid_content' ) );
153		});
154
155		$( '.bt_bb_masonry_post_grid_content' ).each(function() {
156			var grid_content = $( this );
157			bt_bb_post_grid_load_posts( grid_content, 0 );
158		});
159
160		$( '.bt_bb_post_grid_filter_item' ).on( 'click', function() {
161			var root = $( this ).closest( '.bt_bb_grid_container' );
162			root.height( root.height() );
163			$( this ).parent().find( '.bt_bb_post_grid_filter_item' ).removeClass( 'active' ); 
164			$( this ).addClass( 'active' );
165			var grid_content = $( this ).closest( '.bt_bb_masonry_post_grid' ).find( '.bt_bb_masonry_post_grid_content' );
166			grid_content.data( 'category', $( this ).data( 'category' ) );
167			bt_bb_post_grid_load_posts( grid_content, 0 );
168		});
169
170	});
171})( 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.