PageSourceSearch

https://www.rishabhsoft.com/wp-content/themes/hello-theme-child-master/assets/js/filter-listing.js?ver=547

js rishabhsoft.com collected 2026-10-03 19:04:22 UTC 6,273 bytes, 184 lines download raw bytes

1(function ($) {
2	'use strict';
3
4    /* Get listing */
5    function load_posts(post_type){
6		var paged = $("#curr_page").val(); /* get paged value */
7		var next_page = parseInt(paged) + 1;
8		var services = selected_values('service');
9		var industries = selected_values('industry');
10		$.ajax({
11			type: "POST",
12			dataType: "json",
13			url: ajax_vars.ajaxurl,
14			data: "action=load_posts&post_type="+post_type+"&paged=" + paged+"&service="+services+"&industry="+industries,
15			beforeSend: function () {
16				
17			},
18			success: function (result) {
19				
20                if( paged==1 && (result.final_content_html)=="" ){
21                    $('#our_work_lists').html("");
22					$('#no_posts_msg').html("No posts found");
23					$('#no_posts_msg').show();
24					$('#load_more_btn').hide();
25                }
26                else{
27                    $('#no_posts_msg').hide();
28                    $('#our_work_lists').append(result.final_content_html);
29                    $("#curr_page").val(next_page);
30                    if( next_page <= parseInt(result.total_pages) ){
31                        $('#load_more_btn').show();
32                    }
33                    else{
34                        $('#load_more_btn').hide();
35                    }
36                    
37                    if( Object.values(result.featured_imgs).length > 0 ){
38                        Object.entries(result.featured_imgs).forEach(([key, value]) => {
39                            console.log(key,value);
40                            $('div[post_id="'+key+'"]').css('background-image', 'url("'+value+'")');
41                        });
42                    }
43                }
44				
45
46				
47			},
48			error: function (jqXHR, textStatus, errorThrown) {
49				console.log(jqXHR + " :: " + textStatus + " :: " + errorThrown); /* Show error with error status */
50			},
51			complete: function () {
52				
53			}
54
55		});
56	}
57
58    /* Show selected count next to option label */
59    function update_selected_count(data_type) {
60		if (data_type != '') {
61			var total_selected = $('.btn-list[data-list-type='+data_type+']').find('.e-filter-item[aria-pressed="true"]:not([data-filter="__all"])').length;
62			if (total_selected == 0) {
63				$('.dropdown-label[data-list-type='+data_type+']').find('span.selected_count').html("");
64				$('.btn-list[data-list-type='+data_type+']').find('.e-filter-item[data-filter="__all"').attr("aria-pressed","true");
65			}
66			else {
67				$('.dropdown-label[data-list-type='+data_type+']').find('span.selected_count').html("( " + total_selected + " Selected )");
68			}
69		}
70		else {
71			$('.dropdown-label[data-list-type='+data_type+']').find('span.selected_count').html("");
72			$('.btn-list[data-list-type='+data_type+']').find('.e-filter-item[data-filter="__all"').attr("aria-pressed","true");
73		}
74
75	}
76
77    /* Get selected options list */
78	function selected_values(data_type){
79		var tmp_arr = [];
80		var selected_values = '';
81		$('.btn-list[data-list-type='+data_type+']').find('.e-filter-item[aria-pressed="true"]:not([data-filter="__all"])').each(function(index, element) {
82			var this_val = $(this).attr('data-value');
83			if(this_val!=0){
84				tmp_arr.push(this_val);
85			}
86		}); 
87		if( tmp_arr.length > 0 ){
88			selected_values = tmp_arr.join(',');
89		}
90		return selected_values;
91	}
92
93	/* Expand list on Label click */
94	$('.dropdown-label').click(function () {
95
96		var data_type = $(this).attr('data-list-type');
97		$('.btn-list[data-list-type='+data_type+']').toggleClass('hide-ele');
98		$(this).find('.plus-icon').toggleClass('hide-ele');
99		$(this).find('.minus-icon').toggleClass('hide-ele');
100		$(this).toggleClass('active');
101
102		/* collapse rest of the dropdowns(if any) */
103		$('.btn-list:not([data-list-type="' + data_type + '"])').addClass('hide-ele');
104		$('.dropdown-label:not([data-list-type='+data_type+'])').find('.plus-icon').removeClass('hide-ele');
105		$('.dropdown-label:not([data-list-type='+data_type+'])').find('.minus-icon').addClass('hide-ele');
106		$('.dropdown-label:not([data-list-type='+data_type+'])').removeClass('active');
107
108		update_selected_count(data_type);
109
110	});
111
112
113
114	/* Handle click event when clicked specific dropdown item */
115	$('.btn-list .e-filter-item').click(function () {
116
117		var data_type = $(this).closest('.btn-list').attr('data-list-type');
118
119		/* .elementor-widget-taxonomy-filter is default taxonomy widget. Below code is for custom dropdown only. */
120		if( $(this).closest('.elementor-widget-taxonomy-filter').length == 0 ){
121			if( $(this).attr('data-filter') == '__all' ){
122				$(this).attr("aria-pressed","true");
123				$(this).closest('.btn-list').find('.e-filter-item:not([data-filter="__all"])').attr("aria-pressed","fal
123se");
124			}
125			else{
126				$(this).closest('.btn-list').find('.e-filter-item[data-filter="__all"').attr("aria-pressed","false");
127
128				if( $(this).attr("aria-pressed") == "true" ){
129					$(this).attr("aria-pressed","false");
130				}
131				else{
132					$(this).attr("aria-pressed","true");
133				}
134			}
135		}
136
137		/* Avoid custom ajax call for default blog posts, webinar */
138		if( $('.webinar-search').length == 0 && $('.blog-search').length == 0 ){
139			$('#our_work_lists').html(""); /* Reset container when option clicked/changed */
140			$("#curr_page").val(1); /* Reset paged value when option clicked/changed */
141			if($('#listing_post_type').length > 0){
142				load_posts($('#listing_post_type').val());
143			}
144			else{
145				load_posts('our-work');
146			}
147			
148		}
149		
150		
151
152		requestAnimationFrame(function () {
153			update_selected_count(data_type);
154		});
155
156	});
157
158	$('#load_more_btn').click(function(e){
159		e.preventDefault();
160		if($('#listing_post_type').length > 0){
161			load_posts($('#listing_post_type').val());
162		}
163		else{
164			load_posts('our-work');
165		}
166	});
167
168	if( $('#our_work_lists').length > 0 ){
169		if($('#listing_post_type').length > 0){
170			load_posts($('#listing_post_type').val());
171		}
172		else{
173			load_posts('our-work');
174		}
175	}
176
177    /* Blog listing page: When page load along with filter query string, show selected count */
178	if ( $('.btn-list').length > 0 ) {
179		$('.btn-list').each(function(index, element) {
180			update_selected_count($(this).attr('data-list-type'));  
181		}); 
182	}
183
184})(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.