PageSourceSearch

https://rsez.lv/wp-content/plugins/progress-map-markers-filter/assets/js/main/main.js?ver=1.2

js rsez.lv collected 2026-10-02 19:11:11 UTC 38,272 bytes, 903 lines download raw bytes

1jQuery(document).ready(function($){				
2	
3	"use strict"; 		
4        
5    /**
6     * This will show or hide the check mark that indicates if the directions feature is activated or not 
7     * @since 1.0 */
8    
9    var cspmmf_check_mark = function(map_id, status){
10
11        if(typeof map_id === 'undefined')
12            return;
13
14        var $check_mark = jQuery('div.cspm_map_btn[data-map-id='+map_id+'][id=cspmmf_btn] .cspm_element_btn_check');
15
16        if(status == 'hide'){
17            $check_mark.hide();
18        }else if(status == 'show'){
19            $check_mark.show();
20        }
21
22    }
23
24    
25    /**
26     * This will open the list of options of the fields with the display status set to "show"
27     * @since 1.0 */
28    
29    var cspmmf_display_options_on_form_load = function(map_id, is_filter_request, callback){
30        
31        if(typeof map_id === 'undefined')
32            return;
33        
34        if(typeof is_filter_request === 'undefined')
35            is_filter_request = false;
36        
37        var $filter_fields_titles = $('div.cspmmf_filter_field_title[data-map-id='+map_id+']');
38                   
39        $.each($filter_fields_titles, function(index){
40            
41            var options_init_display_status = $(this).attr('data-options-init-display-status');
42            var options_display_status = $(this).attr('data-options-display-status');
43            
44            var filter_field_options = 'div.cspmmf_filter_field_options[data-map-id='+map_id+']';
45            
46            /** Filter is loaded for the first time or using open/close button! */
47            
48            if(options_init_display_status == 'true' && !is_filter_request){ 
49               
50                $(this).trigger('click').attr('data-options-init-display-status', 'false');                  
51            
52            /** Filter is re-loaded after ajax request + field options list is still hidden! */
53            
54            }else if(options_display_status == 'true' && is_filter_request && $(this).next(filter_field_options).is(':hidden')){
55                
56                $(this).trigger('click').attr('data-options-init-display-status', 'false');      
57                        
58            /** Filter is re-loaded after ajax request + field options list is already visible! */
59            
60            }else if(is_filter_request && $(this).next(filter_field_options).is(':visible')){
61                
62                $(this).attr('data-options-init-display-status', 'false');      
63            
64            }
65            
66            if(index == $filter_fields_titles.length - 1)
67                callback;
68            
69        });
70        
71    }
72    
73    
74    /**
75     * This will adjust the width of the sidebar
76     * @since 1.0 */
77    
78    var cspmmf_set_sidebar_width = function(map_id){
79         
80        if(typeof map_id === 'undefined')
81            return;
82               
83        var $filters_container = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']')
84        
85        var side = $filters_container.attr('data-location');
86        var filter_width = $filters_container.attr('data-width');
87            
88        /**
89         * Set sidebar width */
90
91        if(side == 'left' || side == 'right'){                        
92            filter_width = (filter_width == '100%') ? 'calc(100% - 10px)' : filter_width;
93            $('.cspm_sidebar.'+side+'[data-map-id='+map_id+'][data-content-id=cspmmf_markers_filter]').css('width', filter_width);
94        }       
95 
96    }
97    
98    
99    /**
100     * This will adjust the max height of the filters container
101     * @since 1.0 */
102    
103    var cspmmf_set_filter_max_height = function(map_id){
104
105        var map_height = $('#codespacing_progress_map_div_'+map_id).innerHeight();
106       
107        var basic_height = map_height;
108        
109        var $filters_container = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']')
110        var side = $filters_container.attr('data-location');
111        var filter_height = $filters_container.attr('data-height');
112        if(side == 'top' || side == 'bottom'){ // In case of top & bottom locations, we'll calculate based on the filters container height instead of the map height
113            var filter_height_value;
114            if(filter_height.lastIndexOf('%') > -1){ // Get filters container percente height by calculating x% of the map height
115                filter_height_value = filter_height.substring(0, filter_height.length - 1); // Remove "%" to get only height number
116                basic_height = (filter_height_value / 100) * map_height;
117            }else if(filter_height.lastIndexOf('px') > -1){ // Get filters container pixel height as set in the setting
118                filter_height_value = filter_height.substring(0, filter_height.length - 2); // Remove "px" to get only height number
119                basic_height = (filter_height_value > map_height) ? map_height : filter_height_value; // Make sure the height of the filters container doesn't exceed the height of the map, otherwise, use the map height instead
120            }            
121        }
122        
123        var filter_title_height = ($('.cspmmf_filter_title[data-map-id='+map_id+']').length == 0) 
124            ? 0 : $('.cspmmf_filter_title[data-map-id='+map_id+']').innerHeight(); // The height of the filter title
125       
126        var filter_btns_container_height = $('.cspmmf_filter_btns_container[data-map-id='+map_id+']').innerHeight(); // The height of the filter buttons ("filter" & "Clean filters") container
127       
128        var switch_container_height = ($('.cspmmf_switch_container[data-map-id='+map_id+']').length == 0)
129            ? 0 : $('.cspmmf_switch_container[data-map-id='+map_id+']').innerHeight(); // The height of the switcher "On-the-fly"
130        
131        var filter_options_container_height = (basic_height - (filter_title_height + 20)); // "20" refers to the margin between the form and the map
132        var filter_to_toggle_height = (filter_options_container_height - (filter_btns_container_height + switch_container_height));
133        
134        $('.cspmmf_filter_options_container[data-map-id='+map_id+']').css('max-height', filter_options_container_height+'px');
135        $('.cspmmf_filter_to_toggle[data-map-id='+map_id+']').css('max-height', filter_to_toggle_height+'px');
136       
137    }
138    
139    
140	/**
141	 * Open the markers filter tool
142	 * @since 1.0 */
143	
144    $(document).on('click', 'div.cspmmf_btn', function(){
145		
146        var $this = $(this);
147        
148		var map_id = $this.attr('data-map-id');
149        var side = $this.attr('data-side');
150
151        var $filter_container = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']');
152        
153        if($filter_container.hasClass('freeze'))
154            return;
155        		
156        if($('.cspm_sidebar.'+side+'[data-content-id=cspmmf_markers_filter] div.cspmmf_markers_filter_container[data-map-id='+map_id+']').length == '0'){
157            
158            /**
159             * Set sidebar width */
160            
161            cspmmf_set_sidebar_width(map_id);
162            
163            /**
164             * Set filters container max height */
165            
166            setTimeout(function(){
167                cspmmf_set_filter_max_height(map_id);
168            }, 500);
169            
170            /**
171             * Append filters in sidebar */
172             
173            $('div.cspmmf_markers_filter_container[data-map-id='+map_id+']')
174                .removeClass('cspmmf_hide_before_load')
175                .appendTo('.cspm_sidebar.'+side+'[data-map-id='+map_id+'][data-content-id=cspmmf_markers_filter]');
176            
177        }
178		
179        /**
180         * Show filters & open sidebar */
181                
182        cspm_toggle_map_sidebar(map_id, 'cspmmf_markers_filter', $this);        
183		cspmmf_display_options_on_form_load(map_id, false);
184        
185	});		
186	
187	
188	/**
189	 * Close the map filters
190	 * @since 1.0 */
191	
192    $(document).on('click', 'a.cspmmf_filter_title', function(e){ 
193        
194        e.preventDefault();
195		
196        var map_id = $(this).attr('data-map-id');
197        var $filter_container = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']');
198        
199        if($filter_container.hasClass('freeze'))
200            return;
201        
202        $('div.cspmmf_btn[data-map-id='+map_id+']').trigger('click');
203        
204	});
205    
206	
207	/**
208	 * This will filter the map by showing only provided post IDs
209	 * @since 1.0 */
210	
211	var cspmmf_filter_the_map = function(map_id, post_ids){
212			
213		var plugin_map = $('div#codespacing_progress_map_div_'+map_id);
214		var show_carousel = $('div.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-show-carousel');
215        var extensions = $('div.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-ext');
216        var map_script_id = (typeof progress_map_vars.map_script_args[map_id] !== 'undefined') ? map_id : 'initial';
217		
218		posts_to_retrieve[map_id] = post_ids;
219				        
220		if(typeof NProgress !== 'undefined')
221			NProgress.set(0.5);		
222		
223		/**
224		 * Hide all markers */
225		 
226		cspm_hide_all_markers(plugin_map, map_id).done(function(){
227				
228            if(typeof NProgress !== 'undefined')
229                NProgress.set(0.5);
230				
231			/**
232			 * Show markers within the selected filter query */
233			 
234			cspm_set_markers_visibility(plugin_map, map_id, null, 0, post_ids_and_categories[map_id], posts_to_retrieve[map_id], true);
235			cspm_simple_clustering(plugin_map, map_id);						
236						
237			/**
238			 * Center the map on the first post in the array */
239
240			setTimeout(function(){
241				
242				var markers_bounds = new google.maps.LatLngBounds();
243				
244				plugin_map.gmap3({
245					get: {
246						name: 'marker',
247						tag: 'to_cluster',
248						all: true,
249						callback: function(markers){
250							
251							if(!markers)
252								return;
253							
254							var visible_markers = 0;
255								
256							$.each(markers, function(i, marker){
257								
258								var marker_id = marker.id;
259								
260								if(typeof marker !== 'undefined' && marker.visible == true && marker_id != 'user_location'){
261									markers_bounds.extend(marker.getPosition());
262									visible_markers++;
263								}
264
265								if(i == (markers.length-1)){
266									setTimeout(function(){								
267										if(visible_markers > 0){
268											plugin_map.gmap3('get').fitBounds(markers_bounds);
269										}else{
270											cspm_recenter_map(plugin_map, map_id);
271										}
272										cspm_zoom_in_and_out(plugin_map);						
273									}, 100);
274								}
275
276							});
277
278						}
279					}
280				});
281                
282            }, 100);
283                
284            /**
285             * Save the post_ids in the global object.
286             * This is usefull when using the plugin with an extension */
287
288            cspm_global_object.posts_to_retrieve[map_id] = posts_to_retrieve[map_id];																											
289        
290            if(extensions == 'cspml_list'){
291							
292                var show_listings = $('div.cspml_listings_area_'+map_id+' input[name=show_listings]').val();
293
294                /**
295                 * Filter HTML listings */
296
297                if(show_listings == 'true'){
298
299                    /**
300                     * Reset filter form input */
301
302                    cspml_reset_filter_fields(map_id);
303
304                    /**
305                     * Show listing animation */
306
307                    cspml_show_listings_animation(map_id);
308
309                    /**
310                     * Filter posts */
311
312                    var request_type = 'filter';
313
314                    cspml_filter_listings(map_id, posts_to_retrieve[map_id], true, '', false, request_type);					
315
316                    $('div#cspml_listings_container[data-map-id='+map_id+']').attr('data-first-load', 'false');
317
318                }
319
320            }else if(show_carousel == 'yes'){
321                
322                setTimeout(function(){
323                    if(progress_map_vars.map_script_args[map_script_id]['show_posts_count'] == "yes")
324                        $('span.the_count_'+map_id).empty().html(posts_to_retrieve[map_id].length);
325                }, 100);
326                
327                /**
328                 * Rewrite Carousel */
329
330                if(progress_map_vars.map_script_args[map_script_id]['sync_carousel_to_viewport'] == 'no'){ 
331                    setTimeout(function(){
332                        cspm_rewrite_carousel(map_id, show_carousel, posts_to_retrieve[map_id]);
333                    }, 100);
334                }
335
336            }
337
338            /**
339             * Reset nearby points of interest */
340
341            $('a.cspm_reset_proximities[data-map-id='+map_id+']').trigger('click'); 
342            
343            /**
344             * End the Progress Bar Loader */
345
346            if(typeof NProgress !== 'undefined')
347                NProgress.done();		
348			
349		});
350		
351	}
352
353	
354	/**
355	 * =================================================
356	 * ==== Markers filters =============== Start =====
357	 * ================================================= */
358		
359	/**
360	 * Filter the map
361	 * @since 1.0 */
362	
363	var cspmmf_filter_xhr = {};
364	var cspmmf_filter_active = {};
365		
366    var cspmmf_filter_query = function(map_id, init_post_ids, filter_form_fields_val, request_type, invoked_field_name, on_the_fly_filter){
367	
368		var plugin_map = $('div#codespacing_progress_map_div_'+map_id);
369		var map_script_id = (typeof progress_map_vars.map_script_args[map_id] !== 'undefined') ? map_id : 'initial';
370		
371        if(typeof cspmmf_filter_xhr[map_id] === 'undefined')
372            cspmmf_filter_xhr[map_id] = {}; // Init
373        
374        if(typeof cspmmf_filter_active[map_id] === 'undefined')
375            cspmmf_filter_active[map_id] = false; // Init
376        
377		if(cspmmf_filter_active[map_id])
378			cspmmf_filter_xhr[map_id].abort();
379		        
380		cspmmf_filter_active[map_id] = true;    
381        		
382        if(typeof NProgress !== 'undefined'){
383
384            NProgress.configure({
385              parent: 'div#codespacing_progress_map_div_'+map_id,
386              showSpinner: true
387            });				
388
389            NProgress.start();
390
391        }	        
392
393        var $filter_container = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']');
394                    
395        var sync_all_fields = $filter_container.attr('data-sync-all-fields');
396
397        if(sync_all_fields == 'true')
398            $filter_container.addClass('freeze');
399        
400		cspmmf_filter_xhr[map_id] = jQuery.post(
401			cspmmf_vars.ajax_url,
402			{
403				action: 'cspmmf_filter_query',
404				map_id: map_id,
405				init_post_ids: init_post_ids,
406				filter_args: filter_form_fields_val,
407				request_type: request_type,	                
408				map_settings: progress_map_vars.map_script_args[map_id]['map_settings'],				
409			},
410			function(data){
411				
412				cspmmf_filter_active[map_id] = false;
413                				
414				posts_to_retrieve[map_id] = JSON.parse(data);	
415
416				if(posts_to_retrieve[map_id].length > 0){
417	               
418                    var side = $('div.cspmmf_btn[data-map-id='+map_id+']').attr('data-side');
419                    
420                    if($('.cspm_sidebar.'+side+'[data-content-id=cspmmf_markers_filter] div.cspmmf_markers_filter_container[data-map-id='+map_id+']').is(':hidden'))
421                        $('div.cspmmf_btn[data-map-id='+map_id+']').trigger('click');
422                    
423					/**
424					 * Save the post_ids in the global object
425					 * This is usefull when using the plugin with an extension */
426					 
427					cspm_global_object.posts_to_retrieve[map_id] = posts_to_retrieve[map_id];																																						
428					        
429					/**
430					 * ==== Reload & Refine the filters ==== */
431                    
432                    if(sync_all_fields == 'true'){
433                        
434                        jQuery.post(
435                            cspmmf_vars.ajax_url,
436                            {
437                                action: 'cspmmf_map_markers_filters',
438                                refine: 'true', 
439                                request_type: request_type,
440                                map_id: map_id, 
441                                init_post_ids: init_post_ids,
442                                carousel: $filter_container.attr('data-show-carousel'),
443                                extensions: $filter_container.attr('data-ext'),
444                                post_type: $filter_container.attr('data-post-type'),
445                                post_status: $filter_container.attr('data-post-status'),
446                                map_type: $filter_container.attr('data-map-type'),
447                                page_url: $filter_container.attr('data-page-url'),                            
448                                post_ids: posts_to_retrieve[map_id].toString(),
449                                invoked_field_name: typeof(invoked_field_name !== 'undefined') ? invoked_field_name : '',
450                                on_the_fly_filter: on_the_fly_filter,
451                                map_settings: progress_map_vars.map_script_args[map_id]['map_settings'],
452                            },
453                            function(data){                            
454
455                                var style = $filter_container.attr('style'); // Get current style to re-use its position when is draggable!
456
457                                $filter_container.replaceWith(data);
458
459                                $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('style', style).show();	// Note: Using "$filter_container" won't work!
460
461                                cspmmf_filter_custom_scroll(); // Reload filter custom scroll
462                                cspmmf_set_sidebar_width(map_id); // Set sidebar width
463                                setTimeout(function(){
464                                    cspmmf_set_filter_max_height(map_id); // Set filters container max height 
465                                }, 500);                           
466
467                                if(typeof filter_select[map_id] !== 'undefined')
468                                    filter_select[map_id] = {}; // Reset all options
469
470                                if(typeof filter_args[map_id] !== 'undefined'){
471                                    Object.keys(filter_args[map_id]).forEac
471h(function(key){
472                                        var checked_field_name = key; // @key: Also equals to field name!                                    
473                                        if(typeof(filter_args[map_id][key] !== 'undefined')){                                        
474                                            var checked_field_options = typeof(filter_args[map_id][key]['field_options'] !== 'undefined') ? filter_args[map_id][key]['field_options'] : {};                                        
475                                            var filter_field_title_data_attr = '[data-map-id='+map_id+'][data-field-name='+key+']';
476                                            if(cspm_object_size(checked_field_options) > 0){
477                                                $('div.cspmmf_filter_field_title'+filter_field_title_data_attr).trigger('click', [checked_field_name, checked_field_options]);
478                                            }
479                                        }
480                                    });
481                                } 
482
483                                cspmmf_display_options_on_form_load(map_id, true, function(){
484                                    setTimeout(function(){
485                                        $filter_container.removeClass('freeze');
486                                    }, 2000);
487                                }); // Re-open the filters                               
488
489                                $('a.cspmmf_reset_filter[data-map-id='+map_id+']').removeClass('not_active');
490
491                                cspm_convert_img_to_svg();   
492                                
493                                setTimeout(function(){
494                                    if($filter_container.hasClass('freeze')){
495                                        $filter_container.removeClass('freeze');
496                                    }
497                                }, 4000); //Fallback!
498
499                            }
500                        );
501                        
502                    }else $('a.cspmmf_reset_filter[data-map-id='+map_id+']').removeClass('not_active');
503					
504					/**
505					 * ==== Filter the map ==== */
506					
507					cspmmf_filter_the_map(map_id, posts_to_retrieve[map_id]);                                       
508					
509					/**
510					 * ==== Show the filter's check mark icon ====  */
511				 	
512                    if(request_type == 'filter')
513					   cspmmf_check_mark(map_id, 'show');
514                    
515				}else{
516					
517					var message = progress_map_vars.map_script_args[map_script_id]['no_location_found_msg'];
518					cspm_popup_msg(map_id, 'warning', '', message);
519                    $('a.cspmmf_reset_filter[data-map-id='+map_id+']').removeClass('not_active');
520                    if($filter_container.hasClass('freeze')){
521                        $filter_container.removeClass('freeze');
522                    }
523					
524				}
525                                
526				/**
527				 * End the Progress Bar Loader */
528					
529				if(typeof NProgress !== 'undefined')
530					NProgress.done();                
531					
532			}
533			
534		);
535
536	}
537    
538	
539	/**
540	 * Apply custom scroll to the map filters' container 
541	 * @since 1.0 */
542	
543    var cspmmf_filter_custom_scroll = function(){
544        $('div.cspmmf_filter_to_toggle').mCustomScrollbar('destroy');
545        $('div.cspmmf_filter_to_toggle').mCustomScrollbar({
546            autoHideScrollbar: false,
547            scrollbarPosition: 'outside',
548            contentTouchScroll: true,
549            mouseWheel:{
550                enable: true,
551                preventDefault: true,
552            },
553            theme: 'inset-dark',
554            scrollButtons:{ enable: true },
555            live: true,
556            advanced:{ 
557                extraDraggableSelectors: '.cspmmf_filter_options_list, .cspmmf_filter_field_title, .cspmmf_filter_field_options',
558                releaseDraggableSelectors: '.cspmmf_filter_options_list, .cspmmf_filter_field_title, .cspmmf_filter_field_options',
559            },
560        });
561    }
562    cspmmf_filter_custom_scroll(); 
563    
564	
565	/**
566	 * Prevent submitting filter request when hitting enter		
567	 * @since 1.0 */
568	 
569	$('.cspmmf_filter_select .ms-search input').keypress(function(e){
570		if(e.keyCode == 13){
571			e.preventDefault();			
572		}
573	});		
574	
575	
576	/**
577	 * Open/Close filter field options' container 
578	 * @since 1.0 */
579	
580	var filter_select = {};
581	var filter_args = {};
582    
583    $(document).on('click', 'div.cspmmf_filter_field_title', function(event, checked_field_name, checked_field_options){ 
584		
585		var $field_title = $(this);	
586		
587		var map_id = $field_title.attr('data-map-id');
588		var init_post_ids = $field_title.parents('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-init-post-ids');
589        
590		var field_name = $field_title.attr('data-field-name');
591        var field_type = $field_title.attr('data-field-type');
592        var display_type = $field_title.attr('data-display-type');
593        var invoked_field_name = field_name;        
594		
595        if(typeof filter_select[map_id] === 'undefined'){
596            filter_select[map_id] = {};
597        }
598        
599        if(typeof filter_args[map_id] === 'undefined'){
600            filter_args[map_id] = {};
601        }
602        
603		if(typeof filter_args[map_id][field_name] === 'undefined'){
604            filter_args[map_id][field_name] = {};
605        } // Note: Only init filter args when first loaded. This will make sure not to clear the field options when they're already checked/selected in the filter!
606		
607		var first_loading = true;
608		
609		$('div.cspmmf_filter_field_options[data-map-id='+map_id+'][data-field-name='+field_name+']').slideToggle('fast', function(){
610			
611			var count_options = $(this).attr('data-count-options');
612			
613			/**
614			 * Multiselect */
615			 
616			if(typeof filter_select[map_id][field_name] === 'undefined'){
617				
618				filter_select[map_id][field_name] = $('select.cspmmf_filter_select[data-map-id='+map_id+'][name='+field_name+']').multipleSelect({										
619                    displayValues: true,
620                    formatSelectAll: function(){
621						return cspmmf_vars.select_all;
622					},
623                    formatCountSelected: function(count, total){
624                        return cspmmf_vars.count_selected.replace('%1$s', count).replace('%2$s', total);
625                    },
626					formatNoMatchesFound: function(){
627						return cspmmf_vars.no_matches_found;
628					},
629					onOpen: function(){	
630                        
631						$('.cspmmf_filter_field_options[data-map-id='+map_id+'][data-field-name='+field_name+'] .ms-drop ul').mCustomScrollbar({
632							autoHideScrollbar: false,
633							scrollbarPosition: 'inside',
634                            setHeight: '100%',
635							mouseWheel:{
636								enable: true,
637								preventDefault: false,                            
638							},
639							theme: 'dark-thin',
640							scrollButtons:{ enable: false },
641							live: true,                            
642						});
643                        
644                        /**
645                         * Check previously selected options after refining the filters */
646                        
647                        if(typeof event.isTrigger !== 'undefined' && typeof checked_field_name !== 'undefined' && checked_field_name == field_name){
648                            if(typeof checked_field_options !== 'undefined' && typeof checked_field_options === 'object'){
649                                $('select.cspmmf_filter_select[data-map-id='+map_id+'][name='+field_name+']').multipleSelect('setSelects', checked_field_options); // Check previously selected options
650                                if(typeof cspmmf_filter_xhr[map_id] !== 'undefined'){
651							         cspmmf_filter_xhr[map_id].abort();
652                                     if(typeof NProgress !== 'undefined')
653								        NProgress.done();	
654                                } // Abort to stop filtering again (ignore "onClick", "onCheckAll" and other events!) 
655                            }
656                        }
657                        
658					},
659					onClick: function(view){
660                        
661						filter_args[map_id][field_name]['field_type'] = field_type;
662						filter_args[map_id][field_name]['field_name'] = field_name;
663						filter_args[map_id][field_name]['field_options'] = filter_select[map_id][field_name].multipleSelect('get
663Selects');                                                  
664                        
665                        var on_the_fly_filter = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-on-the-fly-filter');
666                        
667                        if(on_the_fly_filter == 'true'){                            
668                                    
669                            /**
670                             * Get & Calculate the number of selected options in all filters in order to determine the request type.
671                             * Note: "On-the-fly" search only! */
672                        
673                            setTimeout(function(){
674                                
675                                var all_currently_checked_options = [];
676                               
677                                Object.keys(filter_select[map_id]).forEach(function(key, index, array){
678                                    
679                                    var selected_options = filter_select[map_id][key].multipleSelect('getSelects');                                    
680                                    
681                                    all_currently_checked_options.push( Object.values( selected_options ) );
682                                    
683                                    if(Object.is(array.length - 1, index)){ // Loop end
684                                        
685                                        var request_type = (all_currently_checked_options.flat().length == 0) ? 'reset' : 'filter';
686                                        
687                                        /**
688                                         * Filter or Reset */
689                                        
690                                        cspmmf_filter_query(
691                                            map_id, 
692                                            init_post_ids, 
693                                            JSON.stringify(filter_args[map_id]), 
694                                            request_type, 
695                                            invoked_field_name, 
696                                            on_the_fly_filter
697                                        );
698                                        
699                                    }
700                                    
701                                });                                 
702                                
703                            }, 100);
704                            
705                        }
706					},
707					onCheckAll: function(){
708						filter_args[map_id][field_name]['field_type'] = field_type;
709						filter_args[map_id][field_name]['field_name'] = field_name;
710						filter_args[map_id][field_name]['field_options'] = filter_select[map_id][field_name].multipleSelect('getSelects');
711                        var on_the_fly_filter = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-on-the-fly-filter');
712                        if(on_the_fly_filter == 'true'){
713                            cspmmf_filter_query(
714                                map_id, 
715                                init_post_ids, 
716                                JSON.stringify(filter_args[map_id]), 
717                                'filter', 
718                                invoked_field_name, 
719                                on_the_fly_filter
720                            );
721                        }
722					},
723					onUncheckAll: function(){
724						
725                        if(first_loading) return; // Make sure to ingore filtering when loading the field for the first time!
726						
727                        filter_args[map_id][field_name]['field_type'] = field_type;
728						filter_args[map_id][field_name]['field_name'] = field_name;
729						filter_args[map_id][field_name]['field_options'] = filter_select[map_id][field_name].multipleSelect('getSelects');
730                        
731                        var on_the_fly_filter = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-on-the-fly-filter');
732                        
733                        if(on_the_fly_filter == 'true'){                            
734                                    
735                            /**
736                             * Get & Calculate the number of selected options in all filters in order to determine the request type.
737                             * Note: "On-the-fly" search only! */
738                        
739                            setTimeout(function(){
740                                
741                                var all_currently_checked_options = [];
742                               
743                                Object.keys(filter_select[map_id]).forEac
743h(function(key, index, array){
744                                    
745                                    var selected_options = filter_select[map_id][key].multipleSelect('getSelects');                                    
746                                    
747                                    all_currently_checked_options.push( Object.values( selected_options ) );
748                                    
749                                    if(Object.is(array.length - 1, index)){ // Loop end
750                                        
751                                        var request_type = (all_currently_checked_options.flat().length == 0) ? 'reset' : 'filter';
752                                        
753                                        /**
754                                         * Filter or Reset */
755                                        
756                                        cspmmf_filter_query(
757                                            map_id, 
758                                            init_post_ids, 
759                                            JSON.stringify(filter_args[map_id]), 
760                                            request_type, 
761                                            invoked_field_name, 
762                                            on_the_fly_filter
763                                        );
764                                        
765                                    }
766                                    
767                                });                                 
768                                
769                            }, 100);
770                            
771                        }
772					},
773					onFilter: function(){
774						if(typeof cspmmf_filter_xhr[map_id] !== 'undefined'){
775							cspmmf_filter_xhr[map_id].abort();
776							if(typeof NProgress !== 'undefined')
777								NProgress.done();							
778						}
779					}
780				}).multipleSelect('uncheckAll'); // Make sure to uncheck all options on first loading!
781				
782                /**
783                 * Re-open dropdown list after ajax request */
784                
785                if(typeof event.isTrigger !== 'undefined' && typeof checked_field_name !== 'undefined' && checked_field_name == field_name){
786                    if(typeof checked_field_options !== 'undefined' && typeof checked_field_options === 'object'){
787                        if(display_type == 'dropdown_list'){
788                           $('select.cspmmf_filter_select[data-map-id='+map_id+'][name='+field_name+']').multipleSelect('open');
789                        }
790                    }
791                }
792                
793				first_loading = false;
794				
795			}
796            
797			if($(this).is(':visible')){
798				$field_title.find('i.fa').removeClass('icon-angle-right').addClass('icon-angle-down');
799			}else $field_title.find('i.fa').removeClass('icon-angle-down').addClass('icon-angle-right');
800            
801		});
802		
803	});
804    
805	    
806    /**
807     * Filter the map from "Filter" button
808     * @since 1.0 */
809    
810    $(document).on('click', 'a.cspmmf_do_filter', function(e, reset){ 
811
812        e.preventDefault();
813        
814        if($(this).hasClass('disabled'))
815            return;
816		
817        var map_id = $(this).attr('data-map-id');
818        var init_post_ids = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-init-post-ids');
819        var on_the_fly_filter = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-on-the-fly-filter');
820                
821        if(jQuery.inArray(on_the_fly_filter, ['false', 'switch']) > -1){        
822            var request_type = (typeof reset === 'undefined' || !reset) ? 'filter' : 'reset';
823            var current_filter_args = (typeof reset !== 'undefined' && reset) ? {} : JSON.stringify(filter_args[map_id]);
824            cspmmf_filter_query(
825                map_id, 
826                init_post_ids, 
827                current_filter_args, 
828                request_type, 
829                '', 
830                on_the_fly_filter
831            );
832        }
833        
834    });
835    
836
837	/**
838	 * Reset the map filters
839	 * @since 1.0 */
840	
841    $(document).on('click', 'a.cspmmf_reset_filter', function(e){
842		
843		e.preventDefault();
844        
845        if($(this).hasClass('not_active'))
846            return;
847		
848		var map_id = $(this).attr('data-map-id');
849		var on_the_fly_filter = $('.cspmmf_markers_filter_container[data-map-id='+map_id+']').attr('data-on-the-fly-filter');
850        
851		if(typeof filter_select[map_id] !== 'undefined'){
852			Object.keys(filter_select[map_id]).forEach(function(key){
853				filter_select[map_id][key].multipleSelect('uncheckAll');
854			});            
855		}
856       
857        if(jQuery.inArray(on_the_fly_filter, ['false', 'switch']) > -1){
858            $('a.cspmmf_do_filter[data-map-id='+map_id+']').trigger('click', [true]);
859        } // Reset by click on the button "Filter" but only if "On-the-fly" filtering is not active, in this case "uncheckAll" will reset the filters.
860        
861        setTimeout(function(){
862            cspmmf_check_mark(map_id, 'hide');
863        }, 500);
864        
865        $(this).addClass('not_active');
866		
867	});
868    
869    
870	/**
871	 * Switch "On the fly" filtering
872	 * @since 1.0 */
873    
874	$(document).on('change', 'label.cspmmf_switch input', function(e){
875		
876		var map_id = $(this).attr('data-map-id');
877		var on_the_fly_filter = $(this).attr('data-on-the-fly-filter');
878		
879		var switcher = $('label.cspmmf_switch[data-map-id='+map_id+']');
880		
881		switcher.addClass('interactive-effect');
882		setTimeout(function() {
883			switcher.removeClass('interactive-effect');
884		}, 400);
885
886        var on_the_fly_state = (on_the_fly_filter == 'true') ? 'false' : 'true';
887
888        $('*[data-map-id='+map_id+'][data-on-the-fly-filter]').each(function(){			
889			$(this).attr('data-on-the-fly-filter', on_the_fly_state);
890		});
891        
892        if(on_the_fly_state == 'true'){
893            $('a.cspmmf_do_filter[data-map-id='+map_id+']').addClass('disabled');
894        }else $('a.cspmmf_do_filter[data-map-id='+map_id+']').removeClass('disabled');
895		
896	});	
897	
898	/**
899	 * =================================================
900	 * ==== Markers filters =============== End ========
901	 * ================================================= */	
902	
903});

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.