PageSourceSearch

https://betterbirthblog.org/wp-content/plugins/js_composer/assets/…/vc_grid_style_load_more.js?ver=4.7.4

js betterbirthblog.org collected 2026-10-02 12:44:31 UTC 3,602 bytes, 124 lines download raw bytes

1/* =========================================================
2 * vc_grid_style_load_more.js v1.0
3 * =========================================================
4 * Copyright 2014 Wpbakery
5 *
6 * Basic Grid Style load more button
7 * ========================================================= */
8var vcGridStyleLoadMore = null;
9(function ( $ ) {
10	/**
11	 * "Load more btn" grid style.
12	 * ==============================
13	 *
14	 * @param grid
15	 * @constructor
16	 */
17	vcGridStyleLoadMore = function ( grid ) {
18		this.grid = grid;
19		this.settings = grid.settings;
20		this.$loadMoreBtn = false;
21		this.$el = false;
22		this.filterValue = null;
23		this.$content = false;
24		this.isLoading = false;
25		this.$loader = $( '<div class="vc_grid-loading"></div>' );
26		this.init();
27	};
28
29	/**
30	 * Initialize
31	 */
32	vcGridStyleLoadMore.prototype.setIsLoading = function () {
33		this.$loadMoreBtn && this.$loadMoreBtn.hide();
34		this.isLoading = true;
35	};
36
37	vcGridStyleLoadMore.prototype.unsetIsLoading = function () {
38		this.isLoading = false;
39		this.setLoadMoreBtn();
40	};
41	vcGridStyleLoadMore.prototype.init = function () {
42		_.bindAll( this
43			, 'addItems'
44		);
45	};
46
47	/**
48	 * Build required content and data.
49	 */
50	vcGridStyleLoadMore.prototype.render = function () {
51		this.$el = this.grid.$el;
52		this.$content = this.$el;
53		this.setIsLoading();
54		this.$content.append( this.$loader );
55		this.grid.ajax( {}, this.addItems );
56	};
57
58	vcGridStyleLoadMore.prototype.showItems = function () {
59		var $els = this.$content.find( '.vc_grid_filter-item:not(.vc_visible-item):lt(' + this.settings.items_per_page + ')' );
60		this.setIsLoading();
61		$els.addClass( 'vc_visible-item ' + vcGridSettings.addItemsAnimation + ' animated' );
62		this.unsetIsLoading();
63		jQuery( window ).trigger( 'grid:items:added', this.$el );
64	};
65	/**
66	 * Filter function called by grid object ot filter content.
67	 *
68	 * @param filter - string parameter with filter settings.
69	 */
70	vcGridStyleLoadMore.prototype.filter = function ( filter ) {
71		filter = _.isUndefined( filter ) || '*' === filter ? '' : filter;
72		if ( this.filterValue == filter ) {
73			return false; // already filtred
74		}
75		this.$content.find( '.vc_visible-item, .vc_grid_filter-item' ).removeClass( 'vc_visible-item vc_grid_filter-item '
76		+ ( 'none' !== vcGridSettings.addItemsAnimation ? vcGridSettings.addItemsAnimation + ' animated' : '') );
77		this.filterValue = filter;
78		this.$content
79			.find( '.vc_grid-item' + this.filterValue )
80			.addClass( 'vc_grid_filter-item' );
81		this.showItems();
82	};
83
84	/**
85	 * Add new grid elements to content block. This request is sent after load more btn click.
86	 * @param html
87	 */
88	vcGridStyleLoadMore.prototype.addItems = function ( html ) {
89		var els = $( html );
90
91		this.$el.append( els );
92		this.unsetIsLoading();
93
94		this.$content = els.find( '[data-vc-grid-content="true"]' );
95
96		this.$loadMoreBtn = els.find( '[data-vc-grid-load-more-btn="true"] .vc_btn' );
97		var self = this;
98		this.$loadMoreBtn.click( function ( e ) {
99			e.preventDefault();
100			self.showItems();
101		} );
102		this.$loadMoreBtn.hide();
103
104		this.grid.initFilter();
105		this.filter();
106		this.$loader.remove();
107		window.vc_prettyPhoto();
108
109	};
110
111	/**
112	 * Show/hide load more btn.
113	 *
114	 * If vc_grid-last-item object is appended to grid, btn is hidden.
115	 */
116	vcGridStyleLoadMore.prototype.setLoadMoreBtn = function () {
117		if ( ! $( '.vc_grid_filter-item:not(".vc_visible-item")', this.$content ).length || ! $( '.vc_grid_filter-item',
118				this.$content ).length ) {
119			this.$loadMoreBtn && this.$loadMoreBtn.hide();
120		} else {
121			this.$loadMoreBtn && this.$loadMoreBtn.show();
122		}
123	};
124})( window.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.