PageSourceSearch

https://yellowscene.com/wp-content/plugins/eventON/assets/js/eventon_script.js?ver=4.9.12

js yellowscene.com collected 2026-10-02 02:47:05 UTC 100,974 bytes, 3,194 lines download raw bytes

1/**
2 * Javascript code that is associated with the front end of the calendar
3 * @version 4.9.12
4 */
5
6jQuery(document).ready(function($){
7
8	//return;
9	var BODY = $('body');
10	var BUS = ''; // initial eventon calendar data
11	var ajax_url = evo_general_params.ajaxurl;
12
13
14// EventON calendar main function
15	
16	// to run before cal ajax is performed @4.6
17	$.fn.evo_pre_cal = function(options){
18		var el = this;
19		var cal = {};
20		var OO = $.extend({}, options);
21
22		var run = function(){
23			cal_width_assoc();
24			cal_load_nav_html();
25		}
26		var cal_width_assoc = function(){
27			cal_w = el.width();
28
29			if( cal_w <300) el.addClass('szS');
30			if( cal_w >300 && cal_w <600) el.addClass('szM');
31			if( cal_w >600 && cal_w <900) el.addClass('szL');
32			if( cal_w >900) el.addClass('szX');
33		}
34
35		// load nav html into cal
36		var cal_load_nav_html = function(){
37			nav_data = el.evo_cal_get_footer_data('nav_data');
38			
39			if( nav_data && 'month_title' in nav_data){
40
41				__html = nav_data.month_title;
42				if( 'arrows' in nav_data ) __html += nav_data.arrows;
43
44				el.find('.evo_header_mo').html( __html );
45				el.find('.evo_footer_nav').html( __html );
46			}
47		}
48		run();
49	}
50
51	// Calendar processing 2.8.6 u 4.6
52	$.fn.evo_calendar = function (options) {
53
54		var el = this;
55		var cal = this;
56		var cal = {};
57		var calO = $.extend({
58			'SC': {},
59			'json':{},
60			'type':'init' ,
61			map_delay:0
62		}, options);
63		var SC = el.evo_shortcode_data();
64
65		
66		// load calendar eventcard and eventtop interactions
67		this.find('.eventon_list_event').each(function(){
68			evo_cal_eventcard_interactions( $(this) );
69		});
70
71		var init = function(){
72
73			// change IDs for map section for eventon widgets
74			if( $(el).hasClass('evcal_widget')){
75				$(el).find('.evcal_gmaps').each(function(){
76					var gmap_id = obj.attr('id');
77					var new_gmal_id =gmap_id+'_widget'; 
78					obj.attr({'id':new_gmal_id})
79				});
80			}
81
82			// load maps on calendar
83			_evo_run_eventcard_map_load();
84
85			// initial actions on calendar
86			$(el).evo_cal_filtering();
87
88			// localizing event time
89			$(el).evo_cal_localize_time();
90
91			// load lightbox events on page load
92			$(cal).evo_cal_oneevent_onload(calO.type);
93			
94			el.evo_cal_hide_data();	
95
96			live_now_cal();
97			counters();
98		};
99		
100		// support	
101			var live_now_cal = function(){
102				$(el).find('.evo_img_time').each(function(){
103					if( $(this).closest('a.desc_trig').find('em.evcal_time').length ){
104						_html = $(this).closest('a.desc_trig').find('em.evcal_time')[0].outerHTML;
105						$(this).html( _html );
106					}				
107				});
108			}
109
110			var counters = function(){
111				$(el).find('.evo_countdowner').each(function(){
112					$(this).evo_countdown();
113				});
114			}
115
116		init();	
117	};
118
119      
120// Event Card handling v4.6.1
121	var evo_eventcard_listeners = function(){
122
123		BODY
124		// localize time
125			.on('click','.tzo_trig',function(event){
126				event.preventDefault();
127				event.stopPropagation();
128
129				$(this).evo_localize_time();
130				//return;
131			})
132		// event images
133			.on('click','.evo_event_more_img',function(){
134				var O = $(this);
135				var box = O.closest('.evcal_eventcard');
136				const gal = O.closest('.evocard_fti_in');
137
138				if( box.length == 0 ) return;
139
140				O.siblings('span').removeClass('select');
141				O.addClass('select');
142
143				mainIMG = box.find('.evocard_main_image');
144				mainIMG.data({
145						'h': O.data('h'), 
146						w: O.data('w'),
147						f: O.data('f')
148					});
149
150				if( mainIMG.hasClass('def')){
151					mainIMG.css('background-image', 'url('+ O.data('f') +')' );
152				}else{
153					mainIMG.html('<span style="background-image:url('+ O.data('f') +')"></span>' );
154					mainIMG.eventon_process_main_ft_img( );
155				}
156			})
157			// open lightbox from main image click
158			.on('click','.evo_img_triglb',function(){
159				O = $(this);
160
161				// if already in lightbox 4.6.4
162				if( O.hasClass('inlb') ) return;
163
164				__ac = parseInt(O.data('w')) >= parseInt( O.data('h') ) ? 'iW':'iH';
165				O.evo_lightbox_open({
166					uid:'evocard_ft_img',
167					lbc:'evolb_ft_img',lbac:'within evocard_img '+ __ac,
168					content: "<img class='evocard_main_image inlb' src='" + O.data('f') +"' data-w='"+O.data('w')+"' data-h='"+O.data('h')+"' class=''/>",
169					end:'client',
170					lb_padding:'',
171					d: {event_id: O.data('event_id'), ri: O.data('ri')}
171
172				});
173			})			
174		// repeat series
175			.on('click','.evo_repeat_series_date',function(){
176
177				if( !($(this).parent().hasClass('clickable')) ) return;
178
179				ux = $(this).data('ux');
180				URL =  $(this).data('l');
181				if( ux == 'def' ) window.location = URL;
182				if( ux == 'defA' )window.open( URL, '_blank');
183			})
184
185		// copy event link			
186			.on('click','.copy.evo_ss', function(event){
187				const OBJ = $(this);
188				const ROW = OBJ.closest('.evcal_evdata_row');
189				var link = decodeURIComponent( OBJ.data('l') );
190				navigator.clipboard.writeText( link );
191
192				evo_card_socialshare_html = ROW.html();
193				ROW.html( "<p style='display:flex'><i class='fa fa-check marr10'></i> " + $(this).data("t") + "</p>");
194
195				setTimeout(function(){
196					ROW.html( evo_card_socialshare_html);
197				},3000);
198			})
199
200		// location image more
201			.on('click','.evo_locimg_more',function(event){
202				event.preventDefault();
203				event.stopPropagation();
204				$(this).closest('.evo_metarow_locImg').toggleClass('vis');
205			})
206
207		// general gallery image changing 4.6
208			.on('click','.evo_gal_icon',function(event){
209				event.preventDefault();
210				event.stopPropagation();
211
212				const O = $(this);
213				if( O.hasClass('on') ) return;
214				O.siblings('div').removeClass('on');
215				O.addClass('on');
216
217				O.closest('.evo_gal_box').find('.evo_gal_main_img').css('background-image', 'url('+ O.data('u') +')')
218					.data('f', O.data('u') )
219					.data('h', O.data('h') )
220					.data('w', O.data('w') );
221			})
222		// show more/less event details
223			.on('click','.evobtn_details_show_more',function(e){	
224				e.preventDefault();	
225				control_more_less( $(this));	
226			})
227
228		// close eventcard 4.6.1
229			.on('click','.evcal_close',function(e){
230				e.preventDefault();
231				$(this).closest('.evcal_eventcard').slideUp().removeClass('open');
232			})
233
234		// when light box is processed
235			.on('evo_lightbox_processed',function(event, OO, LIGHTBOX){
236				if( !(LIGHTBOX.hasClass('evolb_ft_img'))) return;
237				LIGHTBOX.eventon_check_img_size_on_lb( );
238			})
239
240		// event top buttons
241			.on('click','.evocmd_button', function(event){
242				event.preventDefault();
243				event.stopPropagation();
244
245				href = $(this).data('href');			
246				if( $(this).data('target')=='yes'){
247					window.open(href,'_blank');
248				}else{
249					window.location = href;
250				}
251			})
252		// organizer links from eventtop @4.5
253			.on('click','.evo_org_clk_link',function(){
254				window.open( $(this).data('link') , "_blank");
255			})
256
257		// edit event button redirect
258			.on('click','.editEventBtnET', function(event){
259				event.stopPropagation();
260				href = $(this).attr('href');
261				window.open(href);
262			})
263
264		;
265
266		// actual animation/function for more/less button
267		var control_more_less = function(obj){
268			var content = obj.attr('content');
269			var current_text = obj.find('.ev_more_text').html();
270			var changeTo_text = obj.find('.ev_more_text').attr('data-txt');
271			const cell = obj.closest('.evcal_evdata_cell');
272				
273			// show more
274			if(content =='less'){			
275				
276				obj.closest('.evcal_evdata_cell').removeClass('shorter_desc');		
277				obj.attr({'content':'more'});
278				obj.find('.ev_more_arrow').removeClass('ard');
279				obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text);
280				
281			}else{
282				obj.closest('.evcal_evdata_cell').addClass('shorter_desc');				
283				obj.attr({'content':'less'});
284				obj.find('.ev_more_arrow').addClass('ard');
285				obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text);
286			}
287		}
288
289	}
290	var evo_cal_eventcard_interactions = function( EC , load_maps ){
291
292		// process featured image sizes
293		EC.find(".evocard_main_image").eventon_process_main_ft_img(  );		
294
295		// process content sliders
296		EC.find('.evo_elm_HCS').each(function(){
297			$(this).evo_process_content_slider();
298		});	
299
300		// countdown
301		EC.find('.evo_countdowner').each(function(){
302			var obj = $(this);
303			obj.removeClass('evo_cd_on');
304			obj.evo_countdown();
305		});
306		
307		$(window).on('resize',function(){
308			EC.find(".evocard_main_image").eventon_process_main_ft_img(  );	
309		});
310	}
311	$.fn._evo_cal_eventcard_interactions = function( EC, load_maps){
312		evo_cal_eventcard_interactions( EC , load_maps);
313	}
314
315	// run all map waiting map @4.6.1
316	function _evo_run_eventcard_map_load(){
317		BODY.evo_run_eventcard_map_load();
318	}
319	$.fn.evo_run_eventcard_map_load = function(){
320
321		time = 600;
322
323		BODY.find('.evo_metarow_gmap').each(function(index){	
324			O = $(this);
325			if( !(O.is(":visible")) ) return;
326			O.evo_load_gmap({
327				map_canvas_id: O.attr('id'),
328				trigger_point:'evo_calendar',
329				delay: time
330			});
331			time += 600;
332		});			
333	}
334
335// EventTop Interactions v4.6
336	var evo_cal_eventtop_interactions = function( ET ){	}
337	
338// RUN on Page load
339	init();
340	function init(){
341
342		init_load_cal_data();
343
344		handlebar_additional_arguments();
345		
346		evo_cal_body_listeners();
347
348		jitsi();
349
350		// run basic countdown timers
351		BODY.find('.evo_countdowner').each(function(){
352			$(this).evo_countdown();
353		});
354	}
355
356// Initial load data via ajax u4.6
357	function init_load_cal_data(){
358
359		evo_eventcard_listeners();
360
361		// check if calendars are present in the page
362			var run_initload = false;
363
364			if( $('body').find('.ajde_evcal_calendar').length > 0 ) run_initload = true;
365			if( $('body').find('.ajax_loading_cal').length > 0 ) run_initload = true;
366			if( $('body').find('.eventon_single_event').length > 0 ) run_initload = true;
367
368			if(run_initload == false) return false;
369
370			var data_arg = {};	
371
372			BODY.trigger('evo_global_page_run');
373
374			data_arg['global'] = $('#evo_global_data').data('d');
375			data_arg['cals'] ={};	
376			data_arg['nonce'] = evo_general_params.n;				
377
378		// run through all the calendars on page
379			BODY.find('.ajde_evcal_calendar').each(function(){
380				const CAL = $(this);
381				var SC = CAL.evo_shortcode_data();
382
383				CAL.evo_pre_cal();
384
385				if( CAL.hasClass('ajax_loading_cal')){
386					data_arg['cals'][ CAL.attr('id')] = {};
387					data_arg['cals'][ CAL.attr('id')]['sc'] = SC;
388
389					BODY.trigger('evo_global_page_run_after', CAL , SC );// @4.6.1
390				}
391			});
392			
393		
394		$.ajax({
395			beforeSend: function(){},
396			type: 'POST',
397			url: get_ajax_url('eventon_init_load'), 
398			data: data_arg,dataType:'json',
399			success:function(data){
400				$('#evo_global_data').data('d', data);
401
402				BUS = data;
403
404				// append html to calendars if present
405				if('cals' in data){
406					var time = 300;
407					$.each(data.cals, function(i,v){
408
409						setTimeout( function(){
410
411							CAL = BODY.find('#'+ i);
412							if(CAL.length === 0) return;
413							
414							if('html' in v){						
415								CAL.find('#evcal_list').html( v.html );
416								CAL.removeClass('ajax_loading_cal');
417								CAL.find('.evo_ajax_load_events').remove();
418							}	
419
420							// load SC and JSON to calendar
421							CAL.evo_cal_functions({action:'update_shortcodes',SC: v.sc});
422							CAL.evo_cal_functions({action:'update_json',json: v.json});
423							
424							$('body').trigger('evo_init_ajax_success_each_cal', [data, i, v, CAL]);
425
426						}, time);
427						time += 300;
428					});
429				}
430
431				$('body').trigger('evo_init_ajax_success', [data]);
432
433				// after timeout based cal loading, process all cals
434				setTimeout( function(){
435					BODY.find('.ajde_evcal_calendar').each(function(){
436						if( $(this).hasClass('.ajax_loading_cal') ) return;					
437						$(this).evo_calendar({'type':'complete'});
438					});
439				}, time );
440
441			},complete:function(data){				
442				$('body').trigger('evo_init_ajax_completed', [data]);
443			}
444		});
445	}
446	
447
448// GENERALIZED functions
449// General AJAX trigger - added 3.1
450	$(document).on('click','.evo_trig_ajax',function(event ){
451		var ajax_data = {};
452		const obj = $(this);
453
454		ajax_data = obj.data();
455		$(document).data( 'evo_data', ajax_data );
456
457		$(document).trigger('evo_before_trig_ajax', [obj]);
458
459		var new_ajax_data = $(document).data( 'evo_data');
460		new_ajax_data['nn'] = the_ajax_script.postnonce;
461
462		$.ajax({
463			beforeSend: function(){
464				$(document).trigger('evo_beforesend_trig_ajax', [obj, new_ajax_data]);
465			},
466			type: 'POST',url: get_ajax_url('eventon_gen_trig_ajax') ,data: new_ajax_data,dataType:'json',
467			success:function(return_data){
468				$(document).trigger('evo_success_trig_ajax', [obj, new_ajax_data, return_data]);
469			},complete:function(){
470				$(document).trigger('evo_complete_trig_ajax', [obj, new_ajax_data]);
471			}
472		});
473
474	});
475
476// Virtual Events & jitsi
477	function jitsi(mod_refresh){
478		
479		const domain = 'meet.jit.si';
480	    const api = [];
481
482	    jQuery('.evo-jitsi-wrapper').each(function(index, element) {
483	    	const O = $(this);
484	    	const eventO = O.closest('.eventon_list_event');
485
486	    	// check if mod refresh is set or no
487	    	if( mod_refresh != '' && mod_refresh == 'mod_refresh_no' && O.hasClass('mod')) return;
488
489	        var roomName = jQuery(element).data('n'),
490	            width = jQuery(element).data('width'),
491	            height = jQuery(element).data('height'),
492	            audioMuted = jQuery(element).data('audiomute'),
493	            videoMuted = jQuery(element).data('videomute'),
494	            screenSharing = jQuery(element).data('screen');
495	           
496
497	        const myOverwrite =
498			{
499			 	'TOOLBAR_BUTTONS': $(element).data('d'),
500			    "DEFAULT_BACKGROUND": '#494a4e',
501			    'MOBILE_APP_PROMO': false,
502			    'SETTINGS_SECTIONS':['devices', 'language', 'profile', 'calendar'],
503			};
504
505
506	        const options = {
507	            roomName,
508	            width,
509	            height,
510	            parentNode: element,	            
511	            configOverwrite: { 
512	            	startWithAudioMuted: audioMuted,
513	                startWithVideoMuted: videoMuted,
514	                startScreenSharing: false,	  
515	                disableInviteFunctions: false,             
516	            },
517	            interfaceConfigOverwrite: myOverwrite,     
518	        };
519
520
521	        const api = new JitsiMeetExternalAPI(domain, options);      
522
523	        api.addEventListener('participantRoleChanged', function(event){
524
525	        	// record moderator joined
526	        	if (event.role === "moderator"){	        		
527	        		_record_moderator_join( 'yes', eventO.data('event_id'), eventO.data('ri'));
528	        	}
529
530	        	const pp = jQuery(element).data('p');
531	        	if (event.role === "moderator" && pp != '__') {
532	        		ppp = pp.replace('_','');
533			        api.executeCommand('password', ppp);
534			    }	        	
535	        });	
536
537	        // moderator leave	        
538	        api.addEventListener('videoConferenceLeft', function(event){
539	        	if( eventO.find('.evo_vir_data').data('ismod') =='y'){
540	        		_record_moderator_join( 'no', eventO.data('event_id'), eventO.data('ri'));
541	        		O.siblings('.evo_vir_mod_left').show();
542	        		O.hide();
543	        	}
544	        });
545	    });
546	}
547	// record moderator logins for jitsi
548		function _record_moderator_join(joined, eid, ri){
549			var data_arg = {
550				'action': 'eventon_record_mod_joined',
551				'eid': eid,
552				'ri': ri,
553				'joined': joined,
554				'nonce': evo_general_params.n,				
555			};
556
557			$.ajax({
558				beforeSend: function(){},
559				type: 'POST',url: ajax_url,data: data_arg,dataType:'json',
560				success:function(data){	}
561			});
562		}
563	
564
565	// refresh event card elements  - evo_reload_virtual_events
566	// @+ 3.1
567		$('body').on('evo_refresh_elements',function(event, send_data ){
568
569			if( send_data.length <= 0 || !send_data) return;
570
571			send_data['nonce'] = evo_general_params.n;
572
573			$.ajax({
574				beforeSend: function(){	
575					if( 'evo_data' in send_data){
576						$.each(send_data.evo_data, function(ekey, eclasses){
577							$.each(eclasses, function(classnm, val){	
578								if(val && 'loader' in val && val['loader'] && 'loader_class' in val){
579									$('#event_'+ekey).find('.'+val['loader_class']).addClass('evoloading');	
580								}
581							});
582						});	
583					}
584				},
585				type: 'POST',url: get_ajax_url('eventon_refresh_elm'),data: send_data,dataType:'json',
586				success:function(data){
587					if( data.status == 'good' ){
588						evo_apply_refresh_content( data );
589					}
590				},complete: function(){	
591					if( 'evo_data' in send_data){
592						$.each(send_data.evo_data, function(ekey, eclasses){
593							$.each(eclasses, function(classnm, val){
594								if(val && 'loader' in val && val['loader'] && 'loader_class' in val){
595									$('#event_'+ekey).find('.'+val['loader_class']).removeClass('evoloading');	
596								}
597							});
598						});	
599					}
600				}
601			});
602		});
603
604		// refresh the closest hearbeat run parent
605		$('body').on('evo_refresh_designated_elm', function(ee, elm, elm_class, extra_data){
606
607			//get closest event object
608			const event = $(elm).closest('.eventon_list_event');
609
610			if( !event ) return;
611			if( event.find('.'+elm_class).length == 0 ) return;
612
613			const refresh_elm = event.find('.'+elm_class);
614
615			var send_data = {};		
616
617			send_data['evo_data'] = build_elm_refresh_data( refresh_elm , extra_data);
618			
619			$('body').trigger('evo_refresh_elements',[ send_data ]);
620		});
621
622	// record sign in - virtual plus
623		// @+3.1
624		$('body').on('click','.evo_vir_signin_btn',function(){
625						
626			extra_data = {};
627			extra_data['signin'] = 'y';
628			extra_data['refresh_main'] = 'y';
629			extra_data['loader'] = true;
630			extra_data['loader_class'] = 'evo_vir_main_content';
631
632			$('body').trigger('evo_refresh_designated_elm',[ $(this) , 'evo_vir_data',extra_data]);
633		});
634
635
636	// apply refresh event element content with matching data that is sent
637		function evo_apply_refresh_content(data){
638
639			if( 'evo_data' in data ){
640
641				$.each(data.evo_data, function(eclass, boxes){
642					// if event exists in the page
643
644					var vir_data_vals = false;
645					if( 'evo_vir_data' in boxes) vir_data_vals = boxes.evo_vir_data.data;
646
647					$('body').find('.'+eclass).each(function(){
648						const event_elm = $(this);
649
650						// set html
651						$.each(boxes, function(boxclass, boxdata){
652							if( !('html' in boxdata) ) return;
653							if( boxdata.html == '' ) return;
654							if( event_elm.find('.'+boxclass).legnth <= 0 ) return;
655
656							event_elm.find( '.'+boxclass ).html( boxdata.html );
657						});
658
659						// only for virtual event update
660						if( vir_data_vals ){
661
662							// reload jitsi for main content - if main content html is sent it will refresh
663								if( vir_data_vals && ('vir_type' in vir_data_vals) 
664									&& vir_data_vals.vir_type == 'jitsi' 
665									&& ('evo_vir_main_content' in boxes) 
666									&& ('html' in boxes.evo_vir_main_content)  
667									&& boxes.evo_vir_main_content.html != ''
668								){
669									jitsi('mod_refresh_no');
670								}
671
672							// update data for sent object
673								$.each(boxes, function(boxclass, boxdata){
674									if( boxdata.data == '' || boxdata.data === undefined) return;
675
676									// for jitsi if mod left --> force refresh main
677									if( boxdata !== undefined && vir_data_vals.vir_type == 'jitsi' && vir_data_vals.mod_joined =='left'){
678										
679										// force refresh main
680										boxdata.data['refresh_main'] = 'yy';
681									}	
682
683									event_elm.find( '.'+boxclass ).data( boxdata.data );
684								});
685						}
686
687					});
688				});
689			}
690		}
691	// get refresh data for specified elem
692		function build_elm_refresh_data( elm , extra_data){
693
694			dataObj = {};
695
696			// get closest event element and event id/ri from it
697				const event = $(elm).closest('.eventon_list_event');
698
699				dataObj = {}
700				const ekey = event.data('event_id')+'_'+ parseInt(event.data('ri'));
701				dataObj[ ekey ] = {};
702
703			const key2 = elm.data('key');
704
705			// append new data to the element
706			dataObj[ ekey ][ key2 ] = elm.data();
707
708			// check if awaitmod need checked
709				if( elm.data('check_awaitmod')){
710
711					// if waiting for mod element is on page -> set as user awaiting mod
712					if( ( event.find('.evo_vir_jitsi_waitmod').length>0) )
713						dataObj[ ekey ][ key2 ]['refresh_main'] = 'yy';
714
715					// if jitsi is loaded on page & mod is still in --> stop refreshing main
716					if( event.find('.evo-jitsi-wrapper').length>0 && dataObj[ ekey ][ key2 ]['mod_joined'] !='left') 
717						dataObj[ ekey ][ key2 ]['refresh_main'] =  '';
718				}
719
720			// append extra data
721			if( extra_data && extra_data !== undefined){
722				$.each( extra_data, function (index,val){
723					dataObj[ ekey ][ key2 ][index] = val;
724				});
725			}
726
727			return dataObj;
728		}	
729
730	// mark as virtual event ended
731		$(document)
732		.on('evo_before_trig_ajax',function(event, obj){
733			if(!obj.hasClass('evo_trig_vir_end')) return;
734			
735			var new_ajax_data = $(document).data( 'evo_data');
736			new_ajax_data['fnct'] = 'mark_event_ended';
737			$(document).data( 'evo_data', new_ajax_data );
738			
739		})
740		.on('evo_beforesend_trig_ajax',function( event, obj, new_ajax_data){
741			if(!obj.hasClass('evo_trig_vir_end')) return;
742
743			obj.closest('.evo_vir_mod_box').addClass('evoloading');
744		})
745		.on('evo_success_trig_ajax',function( event, obj, new_ajax_data, return_data){
746			if(!obj.hasClass('evo_trig_vir_end')) return;
747
748			// if virtual events were marked as ended
749			if(!('_vir_ended' in return_data)) return;
750
751			// refresh the virtual main content
752			extra_data = {};
753			extra_data['refresh_main'] = 'yy';
754			extra_data['loader'] = true;
755			extra_data['loader_class'] = 'evo_vir_main_content';
756
757			//console.log(extra_data);
758
759			$('body').trigger('evo_refresh_designated_elm',[ obj , 'evo_vir_data',extra_data]);
760		})
761		.on('evo_complete_trig_ajax',function( event, obj, new_ajax_data){
762
763			if(!obj.hasClass('evo_trig_vir_end')) return;
764			obj.closest('.evo_vir_mod_box').removeClass('evoloading');
765		})
766		;
767
768// Heartbeat - added 3.1
769	//hook into heartbeat-send
770	jQuery(document).on('heartbeat-send', function(e, data) {
771
772		// if there is run heartbeat items
773		if( $('body').find('.evo_refresh_on_heartbeat').length>0 ){
774			
775			$('body').find('.evo_refresh_on_heartbeat').each(function(){
776				if( $(this).closest('.eventon_list_event').length <= 0) return;
777				if( $(this).data('refresh')!== undefined && !$(this).data('refresh') ) return;
778
779				data['evo_data'] = build_elm_refresh_data( $(this) );
780			});			
781		}
782	});
783	
784	//hook into heartbeat-tick
785	jQuery(document).on('heartbeat-tick', function(e, data) {	
786		evo_apply_refresh_content( data );
787	});
788
789// Schedule View - 4.0 / u 4.6
790	$('body')
791	.on('evo_init_ajax_success_each_cal',function(event, data, i, v, CAL){
792		$('body').find('.ajde_evcal_calendar.evoSV').each(function(){
793			evosv_populate( $(this) );
794		});
795	})
796	.on('evo_main_ajax_before_fnc', function(event, CAL,  ajaxtype, data_arg){
797		SC = data_arg.shortcode;
798		if( SC.calendar_type == 'schedule'){
799			CAL.find('#evcal_list').removeClass('evo_hide').show();
800		}
801	}).on('evo_main_ajax_success', function(event, CAL,  ajaxtype, data , data_arg){
802		SC = data_arg.shortcode;
803		if( SC.calendar_type == 'schedule'){
804			CAL.find('#evcal_list').addClass('evo_hide').hide();
805		}
806	}).on('evo_main_ajax_complete', function(event, CAL,  ajaxtype, data , data_arg){
807		SC = data_arg.shortcode;
808		if( SC.calendar_type == 'schedule'){
809			evosv_populate( CAL );
810		}
811	})
812	// view switching
813	.on('evo_vSW_clicked_before_ajax',function(event, O, CAL, DD, reload_cal_data){
814		if(!(O.hasClass('evosv'))) return;
815		var SC = CAL.evo_shortcode_data();
816
817		CAL.evo_update_cal_sc({F:'calendar_type', V: 'schedule'});
818		CAL.evo_update_cal_sc({F:'fixed_day', V: SC.fixed_day });
819
820	})
821	.on('evo_vSW_clicked',function(event, OBJ, CAL, DD, reload_cal_data){
822		if(!(OBJ.hasClass('evosv'))) return;
823				
824		CAL.evo_update_cal_sc({F:'calendar_type', V: 'schedule'});
825
826	})
827	.on('evo_vSW_clicked_noajax',function(event, OBJ, CAL, DD, reload_cal_data){
828		if(!(OBJ.hasClass('evosv'))) return;
829				
830		evosv_populate( CAL );		
831	})
832	// open events from schedule view
833		.on('click','.evosv_items',function(event, elm){
834			O = $(this);
835			CAL = O.closest('.ajde_evcal_calendar');
836			var e_cl = 'event_'+O.data('id');
837			
838			const clicked_event_uxval = O.data('uxval');
839
840			// if event is set to slide down .. switch to lightbox
841			if( clicked_event_uxval == '1' ){
842				CAL.find('.'+e_cl).find('.desc_trig').data('ux_val', 3);
843			}
844
845			CAL.find('.'+e_cl).find('.desc_trig').trigger('click');
846		});
847
848	// populate the schedule view data @4.5.8
849	function evosv_populate(CAL){
850		//console.log('s');
851		var SC = CAL.evo_shortcode_data();
852		OD = CAL.evo_get_OD(); // calendar other data 
853
854		var cal_events = CAL.find('.eventon_list_event');
855		days_in_month = CAL.evo_day_in_month({M: SC.fixed_month, Y: SC.fixed_year});
856		time_format = CAL.evo_get_global({S1:'cal_def',S2:'wp_time_format'});
857
858		// text strings
859			_txt = CAL.evo_get_txt({V:'no_events'});
860			_txt2 = CAL.evo_get_txt({V:'until'});
861			_txt3 = CAL.evo_get_txt({V:'from'});
862			_txt4 = CAL.evo_get_txt({V:'all_day'});
863		
864		CAL.find('#evcal_list').addClass('evo_hide');
865
866		var has_events = false;
867		var html = '';
868		var template_data = {};
869		var processed_ids = {};
870
871		// Set initial date - date values
872			var SU = parseInt( SC.focus_start_date_range);	var EU = '';
873			var M = moment.unix( SU ).tz( OD.cal_tz );
874
875		// go through each day in month
876		for(var x=1; x<= days_in_month; x++){
877			
878			var month_name = CAL.evo_get_dms_vals({ V: (M.get('month') +1), type:'m3'});
879			var day_name = CAL.evo_get_dms_vals({ V: M.day(), type:'d3'});
880			
881			// set event unix into moment
882				SU = M.unix();	M.endOf('day');
883				EU = M.unix();	M.startOf('day');
884			
885			// run through each event and get events in this date
886				var events = {};
887
888				cal_events.each(function(index, elm){
889					ED = $(elm).evo_cal_get_basic_eventdata();
890					if( !ED) return;
891
892					processed_ids[ED.uID] = ED.uID;
893					ESU = ED.unix_start; EEU = ED.unix_end;
894
895					// check for date range
896						var inrange = CAL.evo_is_in_range({
897							'S': SU,	'E': EU,	'start': ESU,	'end':EEU
898						});
899						if(!inrange) return; // skip if no in range
900
901					has_events = true;
902
903					// event time relative to calendar tz
904					m = moment.unix( ESU ).tz( OD.cal_tz );
905					me = moment.unix( end ).tz( OD.cal_tz );
906
907					var all_day = $(elm).find('a.desc_trig').hasClass('allday') ? true: false;
908
909					// get event time correct for all day
910					if( all_day ){
911						ED['t'] = _txt4;
912					}else{
913						if( ESU <= SU ){
914							if( EEU >= EU) ED['t'] = _txt4;
915							if( EEU < EU ) ED['t'] = _txt2+' ' + me.format( time_format);		
916						}else if(ESU > SU){
917							if( EEU >= EU)  ED['t'] = _txt3+' '+ m.format( time_format);
918							if( EEU < EU ) ED['t'] = m.format( time_format) +' - '+ me.format( time_format);
919						}	
920					}						
921
922					// hide end time
923					if( ED.hide_et == 'y')		ED['t'] = m.format( time_format);
924
925					events[index] = ED;
926				});			
927
928			// if there are events in this date
929				if( events && Object.keys(events).length > 0){
930					
931					template_data[ x ] = {};
932					template_data[ x ]['date'] = '<b>' + M.get('date')+'</b> '+ month_name+' '+ day_name;
933					template_data[ x ]['d'] =  M.format('YYYY-M-D');
934					template_data[ x ]['SU'] = SU;
935					template_data[ x ]['events'] = {}
936
937					$.each(events, function(index, item){		
938
939						location_data = organizer_data = event_tags = '';
940
941						// location 
942						if( SC.show_location == 'yes' && 'location' in item){
943							location_data = "<div class='evosv_subdata evosv_location'><i class='fa fa-location-pin marr5'></i>" +item.location+"</div>";
944						}
945
946						// organizer					
947						if( SC.show_organizer == 'yes' && 'organizer' in item){
948							organizer_data = "<div class='evosv_subdata evosv_org'>" +item.organizer+"</div>";
949						}
950
951						// event tags
952						if( SC.show_tags == 'yes' && 'event_tags' in item){
953							event_tags = "<div class='evosv_subdata evosv_tags'>";
954							$.each( item.event_tags, function(index, val){
955								event_tags += "<span class='evosv_tag " + index +"'>" + val+"</span>";
956							});
957							event_tags += "</div>";
958						}
959
960						template_data[ x ]['events'][ item.uID ] = {
961							'time': item.t,
962							'ux_val': item.ux_val,
963							'title': item.event_title,
964							'color':item.hex_color,
965							'tag': event_tags,
966							'loc': location_data,
967							'org': organizer_data,
968							'i': item
969						}
970
971					});					
972				}
973
974			// next date
975			M.add(1, 'd');
976		}
977
978		var html_ = "<div class='evosv_grid evoADDS'>";
979		
980		// if no events
981		if( !has_events){
982			no_event_content = CAL.evo_get_global({S1: 'html', S2:'no_events'});			
983			html_ += "<div class='date_row'><div class='row no_events evosv'>"+no_event_content+"</div></div>";
984		}else{
985			html_ += CAL.evo_HB_process_template({
986				TD:template_data, part:'evosv_grid'
987			});
988		}
989
990		html_ += '</div>';
991
992		if( CAL.find('.evosv_grid').length > 0){
993			CAL.find('.evosv_grid').replaceWith( html_ );
994		}else{
995			ELM = CAL.find('#eventon_loadbar_section');
996			ELM.after( html_ );
997		}
998		
999	}
1000
1001// ELEMENTS u4.9
1002	// tooltips
1003		$('body').on('mouseover','.ajdeToolTip, .evotooltip, .evotooltipfree',function(event){
1004			event.stopPropagation();
1005			
1006			const el = $(this);
1007			if(el.hasClass('show')) return;
1008
1009			var free = el.hasClass('free') || el.hasClass('evotooltipfree');
1010			var content =  el.data('d') || el.attr('title') || '';
1011			if (!content) return;
1012
1013			var p = el.position();			
1014			var cor = getCoords(event.target);
1015
1016			$('.evo_tooltip_box').removeClass('show').removeClass('L').html( content );
1017			var box_height = $('.evo_tooltip_box').height();
1018			var box_width = $('.evo_tooltip_box').width();
1019			var top = cor.top - 55 - box_height + (free ? 20 : 0);
1020
1021			$('.evo_tooltip_box').css({'top': top, 'left': ( cor.left + 5 ) })
1022				.addClass('show');
1023
1024			// left align
1025			if( $(this).hasClass('L')){
1026				$('.evo_tooltip_box').css({'left': (cor.left - box_width - 15) }).addClass('L');			
1027			}
1028		})
1029		.on('mouseout','.ajdeToolTip, .evotooltip, .evotooltipfree',function(e){	
1030			event.stopPropagation();
1031			var relatedTarget = $(event.relatedTarget);
1032			var target = $(this);
1033
1034			$('.evo_tooltip_box').removeClass('show');
1035		});
1036
1037		function getCoords(elem) { // crossbrowser version
1038		    var box = elem.getBoundingClientRect();
1039		    //console.log(box);
1040
1041		    var body = document.body;
1042		    var docEl = document.documentElement;
1043
1044		    var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
1045		    var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
1046
1047		    var clientTop = docEl.clientTop || body.clientTop || 0;
1048		    var clientLeft = docEl.clientLeft || body.clientLeft || 0;
1049
1050		    var top  = box.top +  scrollTop - clientTop;
1051		    var left = box.left + scrollLeft - clientLeft;
1052
1053		    return { top: Math.round(top), left: Math.round(left) };
1054		}
1055	// yes no button		
1056		$('body').on('click','.ajde_yn_btn ', function(event){
1057
1058			// stop this code from working on wp-admin
1059			if($('body').hasClass('wp-admin')) return false; 
1060			
1061			var obj = $(this);
1062			var afterstatement = obj.attr('afterstatement');
1063				afterstatement = (afterstatement === undefined)? obj.attr('data-afterstatement'): afterstatement;	
1064			var uid = '';
1065
1066			// yes
1067			if(obj.hasClass('NO')){					
1068				obj.removeClass('NO');
1069				obj.siblings('input').val('yes');
1070
1071				// afterstatment
1072				if(afterstatement!=''){
1073					var type = (obj.attr('as_type')=='class')? '.':'#';
1074					if( obj.data('uid') !== undefined) uid = obj.data('uid');
1075					$(type+ afterstatement).slideDown('fast');						
1076				}
1077
1078			}else{//no
1079				obj.addClass('NO');
1080				obj.siblings('input').val('no');
1081				
1082				if(afterstatement!=''){
1083					var type = (obj.attr('as_type')=='class')? '.':'#';
1084					$(type+ afterstatement ).slideUp('fast');
1085				}
1086			}
1087		});
1088
1089	// content slider v4.6
1090		BODY.on('click','.evo_elmHCS_nav.content_slide_trig',function(){
1091			O = $(this);
1092
1093			var _HCS = O.closest('.evo_elm_HCS'),
1094			_HCS_in = _HCS.find('.evo_elm_HCS_in');
1095			_line_width = _HCS_in[0].scrollWidth;
1096			_container_width = parseInt( _HCS.width() ) + 0;
1097			_leftPos = _HCS_in.scrollLeft();
1098			_scrollable_legth = _line_width - _container_width;
1099
1100			//console.log(_line_width+' '+_container_width+' '+_leftPos+' '+_scrollable_legth);
1101			//return;
1102
1103			const scroll_length = _container_width /2;
1104			
1105			// move right
1106			if( O.hasClass('HCSnavR') ){
1107														
1108				_HCS_in.animate({scrollLeft:_leftPos + scroll_length},200);
1109				_HCS.find('.HCSnavL').addClass('vis');
1110			// move left
1111			}else{
1112				sleft = (_leftPos - scroll_length < scroll_length) ? 0 :  _leftPos - scroll_length;
1113				_HCS_in.animate({scrollLeft: sleft },200);											
1114			}
1115
1116			setTimeout(function(){
1117				var _leftPos = _HCS_in.scrollLeft();
1118				//console.log(_leftPos);
1119				if( _leftPos < 10){
1120					_HCS.find('.HCSnavL').removeClass('vis');
1121					_HCS.find('.HCSnavR').addClass('vis');
1122				}
1123
1124				if( _leftPos > ( _scrollable_legth - 5 ) ){
1125					_HCS.find('.HCSnavR').removeClass('vis');
1126				}
1127			},200);
1128								
1129		});
1130		$.fn.evo_process_content_slider = function(){
1131
1132			_HCS = this;
1133			_HCS_in = _HCS.find('.evo_elm_HCS_in');
1134			_line_width = _HCS_in[0].scrollWidth;
1135			_container_width = parseInt( _HCS.width() ) + 3;
1136			var leftPos = _HCS_in.scrollLeft();
1137
1138			// console.log(_container_width+' '+_line_width);
1139
1140			// content is not showing full
1141			if( _line_width > _container_width ){
1142
1143				// if some of content is hidden on right
1144				if( ( _container_width + leftPos  ) < _line_width )
1145					_HCS.find('.HCSnavR').addClass('vis');
1146
1147				// if content has been scrolled
1148				if( leftPos > 0 ){
1149					_HCS.find('.HCSnavL').addClass('vis');
1150				}else{
1151					_HCS.find('.HCSnavR').addClass('vis');
1152				}
1153			}else{
1154				_HCS.find('.HCSnavL').removeClass('vis');
1155				_HCS.find('.HCSnavR').removeClass('vis');
1156			}
1157		}
1158
1159
1160			$(window).on('resize',function(){
1161				BODY.find('.evo_elm_HCS').each( function(event){
1162					$(this).evo_process_content_slider();
1163				});
1164			});
1165
1166
1167	// dynamic select @4.8.2
1168		BODY.on('click', '.evo_elm_dynamic_select_trig',function(e){
1169			e.preventDefault();
1170			const btn = $(this);
1171		    const row = btn.closest('.evo_elm_dynamic_select');
1172		    const list = btn.find('.evoelm_ds_list');
1173
1174		    row.toggleClass('open');
1175		    btn.toggleClass('open');
1176
1177			if (btn.hasClass('open')) {
1178		        const options = btn.siblings('div').data('d');
1179		        let html = `<div class="evoelm_ds_list evobr10 evodfx evofx_dr_c evobgcw evofz14 evoff_2 evo_ofh evoposa evoleft0 " role="listbox" aria-labelledby="selected-option">`;
1180
1181		        $.each(options, (index, value) => {
1182		            html += `<span class="evoelm_ds_list_item evopad10 evocurp evoborderb" role="option" tabindex="-1" data-index="${index}">${value}</span>`;
1183		        });
1184
1185		        html += '</div>';
1186		        btn.append(html);
1187		    } else {
1188		        list.remove();
1189		    }
1190		});
1191
1192		$(document).click(function(event){
1193			if( !$(event.target).closest('.evo_elm_dynamic_select').length){
1194				const openBox = BODY.find('.evo_elm_dynamic_select.open');
1195		        openBox.removeClass('open').find('button').removeClass('open');
1196		        openBox.find('.evoelm_ds_list').remove();
1197			}	
1198		});
1199
1200		// item clicked from the list
1201		BODY.on('click','.evoelm_ds_list_item',function(event){
1202			const item = $(this);
1203		    const box = item.closest('.evo_elm_dynamic_select');
1204		    const value = item.data('index');
1205
1206		    // update focus item name
1207		    box.find('.evoelm_ds_current').html( item.html() );
1208
1209		    // set new value to input
1210		    box.find('input').val( value );
1211
1212		    // plug for others
1213			BODY.trigger('evoelm_dynamic_select_clicked', [ item, value, box ]);
1214
1215			box.removeClass('open');
1216            box.find('button').removeClass('open');
1217            item.parent().remove();
1218
1219		});
1220
1221	// Image Select @added 4.9 @updated: 4.9.12
1222		var file_frame;	
1223		var __img_index;
1224		var __img_obj;
1225		var __img_box;
1226		var __img_type;
1227	  
1228	    BODY.on('click','.evolm_img_select_trig',function(event) {
1229	    	event.preventDefault();
1230
1231	    	__img_obj = $(this);
1232	    	__img_box = __img_obj.closest('.evo_metafield_image');
1233	    	__img_type = __img_box.hasClass('multi')? 'multi': 'single';
1234
1235	    	if( __img_type == 'single' &&  __img_box.hasClass('has_img') ) return;
1236	    	if( __img_type == 'multi'){
1237	    		__img_index = __img_obj.data('index');
1238
1239	    		// remove image
1240				if( __img_obj.hasClass('on')){
1241					__img_obj.css('background-image', '').removeClass('on');
1242					__img_obj.find('input').val( '' );
1243					return;
1244				}
1245	    	}
1246
1247	    	// Reset file_frame to avoid stale state
1248	        if (file_frame) {     file_frame.close(); file_frame = null;   }
1249
1250			// Get user_id (0 for non-logged-in users)
1251	        var user_id = __img_obj.data('userid') ? parseInt(__img_obj.data('userid')) : 0;
1252	        var library_args = { type: 'image' };
1253	        if (user_id > 0) { library_args.author = user_id; }
1254
1255			// Create the media frame
1256			file_frame = wp.media.frames.downloadable_file = wp.media({
1257				title: 'Choose an Image', 
1258				button: {text: 'Use Image'},	
1259				multiple: false,
1260				library: library_args,
1261			});
1262
1263
1264			// When an image is selected, run a callback.
1265			file_frame.on( 'select', function() {
1266				var selection = file_frame.state().get('selection');
1267        		//console.log('Selection:', selection.toJSON());
1268
1269        		if (selection.length > 0) {
1270	                var attachment = selection.first().toJSON();
1271	                //console.log('Selected attachment:', attachment);
1272
1273	                if (__img_type == 'single') {
1274	                    __img_box.addClass('has_img');
1275	                    __img_box.find('input.evo_meta_img').val(attachment.id);
1276	                    __img_box.find('.evoelm_img_holder').css('background-image', 'url(' + attachment.url + ')');
1277	                    //console.log('Single image updated:', __img_box.find('.evoelm_img_holder').css('background-image'));
1278	                } else {
1279	                    __img_obj.css('background-image', 'url(' + attachment.url + ')').addClass('on');
1280	                    __img_obj.find('input').val(attachment.id);
1281	                    //console.log('Multi image updated:', __img_obj.css('background-image'));
1282	                }
1283	            } else {
1284	                console.log('No image selected');
1285	            }
1286
1287			});
1288
1289			// Handle errors
1290	        file_frame.on('error', function(error) {
1291	            console.error('Media Uploader Error:', error); alert('Error: ' + error.message);
1292	        });
1293
1294			// Finally, open the modal.
1295			file_frame.open();
1296			
1297	    });  
1298		// remove image
1299		BODY.on('click','.evoel_img_remove_trig',function(){
1300
1301			const field = $(this).closest('.evo_metafield_image');
1302
1303			if( !(field.hasClass('has_img') ) ) return;
1304			
1305			field.removeClass('has_img');
1306			field.find('input').val('');
1307			field.find('button').addClass('chooseimg');
1308			field.find('.evoelm_img_holder').css('background-image', '' );
1309		});
1310
1311
1312	// plus minus changer @updated 4.9
1313		$('body').on('click','.evo_plusminus_change', function(event){
1314
1315			// only run on frontend
1316			if( evo_general_params.cal.is_admin ) return;
1317
1318	        OBJ = $(this);
1319
1320	        QTY = parseInt(OBJ.siblings('input').val());
1321	        MAX = OBJ.siblings('input').data('max');        
1322	        if(!MAX) MAX = OBJ.siblings('input').attr('max');           
1323
1324	        NEWQTY = (OBJ.hasClass('plu'))?  QTY+1: QTY-1;
1325
1326	        NEWQTY =(NEWQTY <= 0)? 0: NEWQTY;
1327
1328	        // can not go below 1
1329	        if( NEWQTY == 0 && OBJ.hasClass('min') ){    return;    }
1330
1331	        NEWQTY = (MAX!='' && NEWQTY > MAX)? MAX: NEWQTY;
1332	        if( isNaN( NEWQTY ) ) NEWQTY = 0;
1333
1334	        OBJ.siblings('input').val(NEWQTY).attr('value',NEWQTY);
1335
1336	        if( QTY != NEWQTY) $('body').trigger('evo_plusminus_changed',[NEWQTY, MAX, OBJ]);
1337	       
1338	        if(NEWQTY == MAX){
1339	            PLU = OBJ.parent().find('b.plu');
1340	            if(!PLU.hasClass('reached')) PLU.addClass('reached');   
1341
1342	            if(QTY == MAX)   $('body').trigger('evo_plusminus_max_reached',[NEWQTY, MAX, OBJ]);                 
1343	        }else{            
1344	            OBJ.parent().find('b.plu').removeClass('reached');
1345	        } 
1346	    });
1347
1348// CAL BODY Listeners
1349	function evo_cal_body_listeners(){
1350		BODY.evo_cal_lb_listeners();
1351
1352		BODY
1353		// after both eventcard lightbox content is loaded
1354		.on('evolightbox_end',function(event, LB, CAL){
1355			setTimeout(function(){
1356				//console.log('e');
1357				LB.find('.eventon_list_event').each(function(){
1358					evo_cal_eventcard_interactions( $(this) , true );
1359				});
1360
1361				// load maps
1362				_evo_run_eventcard_map_load();
1363
1364				// run localize time
1365				LB.evo_cal_localize_time();
1366
1367			}, 1000);
1368		})
1369
1370		// load eventon event anywhere via lightbox ajax u4.6
1371			.on('click','.eventon_anywhere.evoajax', function(event){
1372				event.preventDefault();
1373
1374				var obj = $(this);
1375				var data = obj.data('sc');
1376
1377				if( data.ev_uxval == '4') return;
1378			
1379				// NOTE: repeat_interval is already in SC
1380				data['evortl'] = 'no';
1381				if( 'id' in data ) data['event_id'] = data.id;
1382				data['ux_val'] = '3a';
1383				data['ajax_eventtop_show_content'] = false;
1384
1385				obj.evo_cal_lightbox_trigger( data, obj, false);
1386			})
1387
1388		// click on no events - @v 4.2
1389			.on('click','.evo_no_events_btn', function (e){
1390				BODY.trigger('click_on_no_event_btn', [$(this) ] );
1391			})
1392		// MONTH switch
1393			.on('click','.evcal_arrows', function(e){
1394				e.preventDefault();
1395
1396				const CAL = $(this).closest('.ajde_evcal_calendar');
1397
1398				dir = $(this).hasClass('evcal_btn_prev') ? 'prev': 'next';
1399				var cal_id = CAL.attr('id');
1400
1401				if( $(this).closest('.ajde_evcal_calendar').hasClass('evortl') ){
1402					dir = ( dir == 'next') ? 'prev': 'next';
1403				}
1404
1405				// if its from footer or header 4.6
1406				if( $(this).closest('.evo_footer_nav').length > 0){
1407
1408					BOX = $(this).closest('.evo_footer_nav');
1409
1410					offset = BOX.offset();
1411					scrolltop = $(window).scrollTop();
1412					viewport_top = offset.top - scrolltop;
1413
1414					
1415											
1416					CAL.addClass('nav_from_foot').data('viewport_top', viewport_top );
1417				}
1418
1419				// run the cal action
1420				run_cal_ajax( cal_id, dir ,'switchmonth');
1421			})
1422
1423		// Show more events on list
1424			.on('click','.evoShow_more_events',  function(){
1425				CAL = $(this).closest('.ajde_evcal_calendar');
1426				SC = CAL.evo_shortcode_data();
1427
1428				OBJ = $(this);
1429
1430				// redirect to an external link 
1431					if(SC.show_limit_redir !== ''){
1432						window.location = SC.show_limit_redir;	return false;
1433					}
1434
1435				// ajax pagination
1436				if( SC.show_limit_ajax =='yes'){
1437					CURRENT_PAGED = parseInt(SC.show_limit_paged);				
1438					CAL.evo_update_cal_sc({F:'show_limit_paged', V: CURRENT_PAGED+1});
1439					run_cal_ajax( CAL.attr('id'), 'none','paged');
1440
1441				}else{
1442					var event_count = parseInt( SC.event_count );
1443					
1444					var eventList = OBJ.parent();
1445					var allEvents = eventList.find('.eventon_list_event').length;
1446
1447					var currentShowing = eventList.find('.eventon_list_event:visible').length;
1448
1449					for(x=1; x<=event_count ; x++ ){
1450						var inde = currentShowing+x-1;
1451						eventList.find('.eventon_list_event:eq('+ inde+')').slideDown();
1452					}
1453
1454					// hide view more button
1455					if(allEvents >= currentShowing && allEvents<=  (currentShowing+event_count)){
1456						$(this).fadeOut();
1457					}
1458				}
1459			})
1460
1461		// refresh event top
1462			.on('runajax_refresh_eventtop',function(e, OBJ, nonce){})
1463
1464		// when event card is slided done @4.6.1
1465			.on('evo_slidedown_eventcard_complete',function(event, event_id, obj, __is_slide_down){
1466
1467				if( !__is_slide_down  ) return;
1468
1469				setTimeout(function(){
1470
1471					OO = obj.closest('.eventon_list_event');
1472					evo_cal_eventcard_interactions( OO , true );
1473				},300);
1474			})
1475		// JUMPER switch v4.6
1476			.on('calendar_month_changed',function(event, CAL){
1477				SC = CAL.evo_shortcode_data();
1478				B = CAL.find('.evo-gototoday-btn');
1479
1480				var O = CAL.find('.evo_j_container');
1481				O.find('.evo_j_months a').removeClass('set');
1482				O.find('.evo_j_months a[data-val="'+ SC.fixed_month +'"]').addClass('set');
1483
1484				O.find('.evo_j_years a').removeClass('set');
1485				O.find('.evo_j_years a[data-val="'+ SC.fixed_year +'"]').addClass('set');
1486
1487				// show go to today 				
1488				if( SC.fixed_month != B.data('mo') || SC.fixed_year != B.data('yr')){
1489					//B.show();
1490					BODY.trigger('show_cal_head_btn', [B]);
1491				}else{
1492					//B.hide();
1493					BODY.trigger('hide_cal_head_btn', [B]);
1494				}
1495			})
1496		// click on go to today
1497			.on('click','.evo-gototoday-btn', function(){
1498				var obj = $(this);
1499				CAL = obj.closest('.ajde_evcal_calendar');			
1500				var calid = CAL.attr('id');
1501
1502				CAL.evo_update_cal_sc({F:'fixed_month', V: obj.data('mo')});
1503				CAL.evo_update_cal_sc({F:'fixed_year', V: obj.data('yr')});
1504				
1505				run_cal_ajax( calid,'none','today');
1506				BODY.trigger('hide_cal_head_btn', [obj]);
1507			})
1508					
1509		// refresh now calendar
1510			.on('runajax_refresh_now_cal',function(e, OBJ, nonce){
1511
1512				const section = OBJ.closest('.evo_eventon_live_now_section');
1513				const CAL = section.find('.ajde_evcal_calendar').eq(0);
1514
1515				var dataA = {
1516					nonce: nonce,
1517					other: OBJ.data(),
1518					SC: CAL.evo_shortcode_data()
1519				};
1520
1521				
1522
1523				$.ajax({
1524					beforeSend: function(){
1525						section.addClass('evoloading');
1526					},
1527					type: 'POST',url: get_ajax_url('eventon_refresh_now_cal'), data: dataA,dataType:'json',
1528					success:function(data){
1529						if( data.status == 'good'){
1530							section.html( data.html);
1531
1532							$('body').trigger('evo_refresh_designated_elm',[ OBJ, 'evo_vir_data']);
1533						}
1534
1535					},complete:function(data){
1536						section.removeClass('evoloading');
1537
1538						BODY.find('.evo_countdowner').each(function(){
1539							$(this).evo_countdown();
1540						});
1541					}
1542				});
1543			})
1544
1545		// cal header buttons
1546			.on('click','.cal_head_btn',function(){
1547
1548				if( $(this).hasClass('vis')){
1549					BODY.trigger('hide_cal_head_btn',[ $(this)]);	
1550				}else{
1551					BODY.trigger('show_cal_head_btn',[ $(this)]);	
1552				}
1553				
1554			})
1555
1556			.on('show_cal_head_btn',function(event, obj ){
1557				//CAL = obj.closest('.ajde_evcal_calendar');
1558				if( obj.hasClass('evo-gototoday-btn') ){	}else{
1559					obj.siblings(':not(.evo-gototoday-btn)').removeClass('show vis');
1560				}
1561				obj.addClass('show vis');
1562				CAL = obj.closest('.ajde_evcal_calendar');
1563
1564				BODY.trigger('evo_cal_header_btn_clicked', [ obj , CAL ,'show']);	
1565
1566			})
1567			.on('hide_cal_head_btn',function(event , obj){
1568
1569				CAL = obj.closest('.ajde_evcal_calendar');
1570				//obj.siblings().removeClass('show vis');
1571				obj.removeClass('show vis');
1572
1573				BODY.trigger('evo_cal_header_btn_clicked', [ obj , CAL ,'hide']);	
1574
1575			})
1576
1577			// click on tile box style 3
1578			.on('click','.ajde_evcal_calendar.boxstyle3 .eventon_list_event',function(e){
1579				e.preventDefault(); e.stopPropagation();
1580				$(this).find('.desc_trig').trigger('click');
1581			})
1582
1583		// OPENING event card -- USER INTREACTION and loading google maps
1584			.on('click','.eventon_list_event .desc_trig', function(event){
1585				event.preventDefault();
1586				const $this = $(this);
1587			    const $eventBox = $this.closest('.eventon_list_event');
1588			    const $cal = $this.closest('.evo_lightbox').data('cal_id')
1589			        ? $('#' + $this.closest('.evo_lightbox').data('cal_id'))
1590			        : $this.closest('.ajde_evcal_calendar');
1591			    const SC = $cal.evo_shortcode_data();
1592			    const ux_val = $cal.evo_cal_event_get_uxval(SC, $this);
1593			    const event_id = $eventBox.data('event_id');
1594			    const exlk = $this.data('exlk');
1595			    const isSingleEventBox = $this.closest('.eventon_single_event').length > 0 && $cal.find('.evo-data').data('exturl');
1596
1597			    // UX-specific handlers
1598			    const actions = {
1599			        '3': () => openLightbox($this, $cal, SC, event_id, $eventBox),
1600			        '3a': () => openLightbox($this, $cal, SC, event_id, $eventBox),
1601			        '4': () => openUrl($this.attr('href') || $this.parent().siblings('.evo_event_schema').find('a').attr('href'), '_self'),
1602			        '4a': () => openUrl($this.attr('href') || $this.parent().siblings('.evo_event_schema').find('a').attr('href'), '_blank'),
1603			        '2': () => handleExternalLink($this, isSingleEventBox),
1604			        'X': () => false,
1605			        'none': () => false,
1606			        'default': () => exlk === '1' ? handleExternalLink($this, isSingleEventBox) : slideDownEventCard($this, $eventBox, $cal, SC, event_id)
1607			    };
1608
1609			    // Execute action based on ux_val
1610			    return (actions[ux_val] || actions['default'])();
1611
1612			    // Helper functions
1613			    function openLightbox($trigger, $cal, SC, event_id, $eventBox) {
1614			        const repeat_interval = parseInt($eventBox.data('ri')) || 0;
1615			        const etttc_class = $cal.attr('class').split(' ').find(cls => cls.startsWith('etttc_')) || '';
1616			        const new_SC_data = {
1617			            ...SC,
1618			            repeat_interval,
1619			            event_id,
1620			            ux_val,
1621			            evortl: $trigger.closest('.eventon_events_list').hasClass('evortl') ? 'yes' : 'no',			            
1622			            ajax_eventtop_show_content: true,
1623			            additional_class: etttc_class
1624			        };
1625			        $cal.evo_cal_lightbox_trigger(new_SC_data, $trigger, $cal);
1626			        return false;
1627			    }
1628
1629			    function openUrl(url, target) {
1630			    	// if open in new window
1631			    	if( $this.attr('target') == '_blank') {
1632			    		target = '_blank';
1633			    	}
1634			        if (url) {
1635			            window.open(url, target);
1636			        }
1637			        return target === '_blank';
1638			    }
1639
1640			    function handleExternalLink($trigger, isSingleEventBox) {
1641			        if (isSingleEventBox) return false;
1642			        const url = $trigger.attr('href');
1643			        if (url) {
1644			            window.open(url, $trigger.attr('target') === '_blank' ? '_blank' : '_self');
1645			        }
1646			        return !!url;
1647			    }
1648
1649			    function slideDownEventCard($trigger, $eventBox, $cal, SC, event_id) {
1650			        const $content = $eventBox.find('.event_description');
1651			        const isOpen = $content.hasClass('open');
1652			        if (SC.accord === 'yes') {
1653			            $cal.find('.eventon_list_event').removeClass('open');
1654			            $cal.find('.event_description').slideUp().removeClass('open');
1655			        }
1656			        $eventBox.toggleClass('open', !isOpen);
1657			        $content[isOpen ? 'slideUp' : 'slideDown']().toggleClass('open', !isOpen);
1658
1659			        if ($eventBox.find('.evo_metarow_gmap').length) {
1660			            $eventBox.find('.evo_metarow_gmap').evo_load_gmap({ trigger_point: 'slideDownCard' });
1661			        }
1662
1663			        if ($trigger.data('runjs')) {
1664			            $('body').trigger('evo_load_single_event_content', [event_id, $trigger]);
1665			        }
1666			        $('body').trigger('evo_slidedown_eventcard_complete', [event_id, $trigger, !isOpen]);
1667
1668			        return false;
1669			    }
1670
1671
1672			})
1673
1674		;
1675	}
1676
1677// Other	
1678	
1679	// eventcard lightbox event navigation
1680	// @version 4.9.2
1681		BODY.on('evolightbox_end',function(e, LB, CAL, OO){
1682			if (!evo_general_params.cal.lbnav) return;
1683			if (evo_general_params.cal.lbnav == 'no') return; // 4.9.2
1684
1685		    const event = $(OO.other_data.obj).closest('.event');
1686		    const calId = ( CAL ? CAL.attr('id') : '');
1687		    const buttons = [
1688		        { dir: 'prev', icon: 'left', sibling: event.prev('.event') },
1689		        { dir: 'next', icon: 'right', sibling: event.next('.event') }
1690		    ].filter(b => b.sibling.length)
1691		     .map(b => `
1692		        <div class='evocard_lb_navs'>
1693		            <button class='evocard_nav_trig ${b.dir} evoposa evocurp evohoop7 evobr30 evobgcw evodfx evofxjcc evofxaic evo_transit_all evoboxbb' data-id='${b.sibling.attr('id')}' data-cid='${calId}'>
1694		                <i class='fa fa-chevron-${b.icon}'></i>
1695		            </button>
1696		        </div>
1697		    `).join('');
1698
1699		    LB.find('.evolb_box').append(buttons);
1700		    setTimeout(() => LB.find('.evocard_nav_trig').addClass('show'), 500);
1701		})
1702		.on('click','.evocard_nav_trig',function(e){
1703			e.preventDefault();
1704		    const $el = $(e.currentTarget);
1705		    const CAL = $('#' + $el.data('cid'));
1706		    const SC = CAL.evo_shortcode_data();
1707		    const eventId = $el.data('id').split('_')[1];
1708		    const newEvent = CAL.find(`#${$el.data('id')}`);
1709		    const newEventTrigger = newEvent.find('.desc_trig');
1710		    const LB = $el.closest('.evo_lightbox');
1711
1712		    LB.find('.evocard_nav_trig').fadeOut().addClass('old');
1713		    setTimeout(() => LB.find('.evocard_lb_navs').has('.old').remove(), 500);
1714
1715		    LB.evo_lightbox_show_open_animation({ animation_type: 'saving' });
1716
1717		    const updatedSC = {
1718		        ...SC,
1719		        repeat_interval: parseInt(newEvent.data('ri')),
1720		        ux_val: CAL.evo_cal_event_get_uxval(SC, newEventTrigger),
1721		        event_id: eventId,
1722		        ajax_eventtop_show_content: true,
1723		        evortl: newEvent.find('.eventon_events_list').hasClass('evortl') ? 'yes' : 'no',			
1724		        additional_class: CAL.attr('class').match(/etttc_\w+/)?.[0] || '',
1725		    };
1726
1727		    const newLbClass = "evo_eventcard_"+eventId;
1728		    LB.removeClass(LB.data('lbc')).addClass(newLbClass).data('lbc', newLbClass);
1729
1730		    setTimeout(() => CAL.evo_cal_lightbox_trigger(updatedSC, newEventTrigger, CAL, LB), 1000);
1731
1732		});
1733
1734	// Calendar Interaction
1735		// event bubbles
1736			$('.ajde_evcal_calendar.bub').on('mouseover','.eventon_list_event', function(){
1737				O = $(this);
1738				LIST = O.closest('.eventon_events_list');
1739				title = O.find('.evoet_dayblock').data('bub');
1740
1741				p = O.position();
1742
1743				LIST.append('<span class="evo_bub_box" style="">'+ title +"</span>");
1744				B = LIST.find('.evo_bub_box');
1745
1746				l = p.left;
1747				t = p.top- B.height() -30;
1748
1749				// adjust bubble to left if event on right edge
1750				LM = LIST.width();
1751				tl = p.left + B.width() + O.width();
1752				if(   tl > LM){
1753					l = l - B.width() +O.width()-20;
1754				}
1755
1756				B.css({'top':t, 'left':l});
1757
1758				LIST.find('.evo_bub_box').addClass('show');
1759			}).on('mouseout',function(){
1760				B = $(this).find('.evo_bub_box').remove();
1761			});
1762
1763	// MONTH jumper
1764		$('.ajde_evcal_calendar').on('click','.evo-jumper-btn', function(){
1765			$(this).closest('.calendar_header').find('.evo_j_container').toggle();
1766			$(this).toggleClass('vis');
1767		});
1768
1769		// select a new time from jumper
1770		$('.evo_j_dates').on('click','a',function(){
1771			var val = $(this).attr('data-val'),
1772				type = $(this).parent().parent().attr('data-val'),
1773				CAL = $(this).closest('.ajde_evcal_calendar');
1774				SC = CAL.evo_shortcode_data();
1775
1776			if(type=='m'){ // change month
1777				CAL.evo_update_cal_sc({F:'fixed_month', V: val });
1778			}else{
1779				CAL.evo_update_cal_sc({F:'fixed_year', V: val });
1780			}
1781
1782			run_cal_ajax( CAL.attr('id') ,'none','jumper');
1783			
1784			// hide month jumper if not set to leave expanded
1785			if(SC.expj =='no')	container.delay(2000).slideUp();
1786		});
1787
1788	// RESET general calendar
1789		// @U 2.8.9
1790		BODY.on('evo_trigger_cal_reset', function(event, cal){
1791			cal_resets( cal );
1792		});
1793		function cal_resets(calOBJ){
1794			calargs = $(calOBJ).find('.cal_arguments');
1795			calargs.attr('data-show_limit_paged', 1 );
1796
1797			calOBJ.evo_update_cal_sc({
1798				F:'show_limit_paged',V:'1'
1799			});
1800		}
1801	
1802	// Tab view switcher
1803		$('body').find('.evo_tab_container').each(function(){
1804			$(this).find('.evo_tab_section').each(function(){
1805				if(!$(this).hasClass('visible')){
1806					$(this).addClass('hidden');
1807				}
1808			});
1809		});
1810		$('body').on('click','.evo_tab',function(){
1811			tab = $(this).data('tab');
1812			tabsection = $(this).closest('.evo_tab_view').find('.evo_tab_container');
1813			tabsection.find('.evo_tab_section').addClass('hidden').removeClass('visible');
1814			tabsection.find('.'+tab).addClass('visible').removeClass('hidden');
1815
1816			$(this).parent().find('.evo_tab').removeClass('selected');
1817			$(this).addClass('selected');
1818
1819			$('body').trigger('evo_tabs_newtab_selected',[ $(this)]);
1820		});
1821
1822	// layout view changer - legacy
1823		if($('body').find('.evo_layout_changer').length>0){
1824			// menu button focus adjust
1825			$('body').find('.evo_layout_changer').each(function(item){
1826				if($(this).parent().hasClass('boxy')){
1827					$(this).find('.fa-th-large').addClass('on');
1828				}else{
1829					$(this).find('.fa-reorder').addClass('on');
1830				}
1831			});
1832
1833			// interaction
1834			$('.evo_layout_changer').on('click','i',function(){
1835				const CAL = $(this).closest('.ajde_evcal_calendar');
1836				TYPE = $(this).data('type');
1837				$(this).parent().find('i').removeClass('on');
1838				$(this).addClass('on');
1839
1840				//console.log(TYPE);
1841				
1842				if(TYPE=='row'){
1843					CAL.attr('class','ajde_evcal_calendar');
1844					// set tile colors
1845					CAL.find('.eventon_list_event').each(function(){
1846						$(this).find('.desc_trig').css('background-color',  '');
1847						$(this).find('.desc_trig_outter').css('background-color',  '');
1848					});
1849				}else if(TYPE =='bar'){
1850					CAL.attr('class','ajde_evcal_calendar  box_2 sev cev');
1851					
1852					// set tile colors
1853					CAL.find('.eventon_list_event').each(function(){
1854						const color = $(this).data('colr');
1855						$(this).find('.desc_trig').css('background-color',  color);
1856					});
1857				}else{
1858
1859					// set tile colors
1860					CAL.find('.eventon_list_event').each(function(){
1861						const color = $(this).data('colr');
1862						$(this).find('.desc_trig_outter').css('background-color',  color);
1863					});
1864
1865					CAL.attr('class','ajde_evcal_calendar boxy boxstyle0 box_2');
1866				}				
1867			});
1868		}
1869	
1870
1871	// v4.0 view switcher
1872		BODY.on('click', '.evo_vSW',function(){
1873			const O = elm = $(this);
1874			var DATA = O.data('d');
1875			if(O.hasClass('focusX')) return;
1876
1877			//console.log(DATA);
1878			CAL = O.closest('.ajde_evcal_calendar');
1879
1880			// remove other additions from other views
1881			CAL.find('.evoADDS').hide().delay(200).queue(function(){
1882				$(this).remove();
1883			});
1884
1885			var SC = CAL.evo_shortcode_data();
1886			const cal_tz = CAL.evo_get_global({S1:'cal_def',S2:'cal_tz'});
1887			var reload_cal_data = false;
1888			
1889			// Create date object
1890				_M1 = moment().set({'year': SC.fixed_year, 'month': ( SC.fixed_month -1 ), 'date':SC.fixed_day}).tz( cal_tz );
1891				_M1.set('date',1).startOf('date');
1892				_start = _M1.unix();
1893				_M1.endOf('month').endOf('date'); // move to end of month
1894				_end = _M1.unix();
1895
1896			// DEP
1897				var DD = new Date(SC.fixed_year,SC.fixed_month -1 , SC.fixed_day, 0,0,0 );
1898				DD.setUTCHours(0);
1899				DD.setUTCFullYear( SC.fixed_year );
1900				DD.setUTCMonth( SC.fixed_month -1 );
1901				DD.setUTCDate( SC.fixed_day );
1902
1903			// switch to normal
1904				O.siblings('.evo_vSW').removeClass('focusX select');					
1905				O.addClass('focusX select');
1906				CAL.find('.evo-viewswitcher-btn em').html( O.html() );
1907				O.closest('.evo_cal_view_switcher').removeClass('show');
1908
1909			// ux_val for specific cal
1910				if( DATA && 'ux_val' in DATA)	CAL.evo_update_cal_sc({F:'ux_val', V: DATA.ux_val });
1911
1912			// calendar class toggling
1913				O.siblings('.evo_vSW').each(function(){
1914					var _d = $(this).data('d');
1915					if( _d && 'c' in _d )	CAL.removeClass( _d['c'] ); // remove other cls
1916				});
1917				if( DATA && 'c' in DATA)	CAL.addClass( DATA.c );
1918		
1919
1920			// process date times block
1921				CAL.find('.evoet_dayblock span').hide();
1922				CAL.find('.evoet_dayblock span.evo_start').show();
1923				CAL.find('.evoet_dayblock span.evo_end').show();
1924				CAL.find('.evoet_dayblock span.evo_end.only_time').hide();
1925
1926			// if current date range is not a month load those unix
1927			if( SC.focus_start_date_range != _start && SC.focus_end_date_range != _end ){
1928				reload_cal_data = true;
1929				CAL.evo_update_cal_sc({F:'focus_start_date_range',V: _start });
1930				CAL.evo_update_cal_sc({F:'focus_end_date_range', V: _end });
1931			}
1932
1933			// treating events list based on dif preferences--  vals el_visibility = hide_events, show_events
1934				if( 'el_visibility' in DATA){
1935					el_visibility = DATA.el_visibility;
1936
1937					if( el_visibility =='show_events') CAL.find('.eventon_list_event').show();
1938					if( el_visibility =='hide_events') CAL.find('.eventon_list_event').hide();
1939					if( el_visibility =='hide_list') CAL.find('#evcal_list').addClass('evo_hide').hide();
1940					if( el_visibility =='show_all'){
1941						CAL.find('#evcal_list').removeClass('evo_hide').show();
1942						CAL.find('.eventon_list_event').show();
1943					} 
1944				}				
1945
1946			CAL.evo_update_cal_sc({F:'calendar_type', V: 'default'});
1947			
1948			$('body').trigger('evo_vSW_clicked_before_ajax', [ O, CAL, DD, reload_cal_data ]);
1949
1950			// run ajax to load new events in the range
1951				if( reload_cal_data ){
1952					$('body').trigger('evo_run_cal_ajax',[CAL.attr('id'),'none','filering']);
1953				}else{
1954					$('body').trigger('evo_vSW_clicked_noajax', [ O, CAL ]); // @s4.6
1955				}
1956									
1957			$('body').trigger('evo_vSW_clicked', [ O, CAL, DD, reload_cal_data]);
1958
1959			// switching to and from tiles view
1960				if( elm.hasClass('evoti')){
1961					CAL.find('.eventon_list_event').each(function(){
1962						color = $(this).data('colr');
1963						$(this).find('a.desc_trig').css({'background-color': color});
1964					});
1965					CAL.addClass('color').removeClass('sev').data('oC', 'sev');
1966				}else{
1967					if( CAL.hasClass('esty_0') || CAL.hasClass('esty_4') ){
1968						CAL.removeClass('color');
1969						CAL.find('.eventon_list_event').each(function(){
1970							$(this).find('a.desc_trig').css({'background-color': ''});
1971						});
1972						if( CAL.data('oC') !== undefined) CAL.addClass( CAL.data('oC'));
1973					}
1974				}
1975
1976		});
1977	
1978	// SORTING & FILTERING		
1979		// Sorting	
1980			// update calendar based on the sorting selection
1981				$('body').on('click', '.evo_sort_option',function(){
1982					O = $(this);
1983					var CAL = O.closest('.ajde_evcal_calendar');
1984					var sort_by = O.data('val');
1985					
1986					// update new values everywhere
1987					CAL.evo_update_cal_sc({F:'sort_by',V:sort_by});
1988
1989					O.parent().find('p').removeClass('select');
1990					O.addClass('select');	
1991
1992					run_cal_ajax(CAL.attr('id'),'none','sorting');						
1993				});		
1994
1995		// close filter menus on click outside
1996			BODY.on('clicked_on_page',function( ev, obj, ee){
1997
1998				// hide filter menu when clicked outside 4.6.2
1999				if( !(obj.hasClass('eventon_filter')) && 
2000					!(obj.hasClass('filtering_set_val')) &&
2001					!(obj.hasClass('evo_filter_val')) &&
2002					!(obj.hasClass('evofp_filter_search_i')) &&
2003					obj.parents('.filtering_set_val').length == 0 
2004				){
2005					//console.log(obj);
2006					BODY.find('.evo_filter_menu').html('');
2007					BODY.find('.evo_filter_tax_box.vis').removeClass('vis');
2008				}
2009			});
2010
2011		// Filtering
2012			$.fn.evo_cal_filtering = function(O){
2013				
2014				var opt = $.extend({}, O);
2015
2016				var el = this; // cal
2017				const sortbox = el.find('.eventon_sorting_section'),
2018					filter_container = sortbox.find('.evo_filter_container_in'),
2019					filter_line = sortbox.find('.eventon_filter_line'),
2020					fmenu = sortbox.find('.evo_filter_menu'),
2021					all_cal_filter_data = el.evo_get_filter_data(),
2022					SC = el.evo_shortcode_data();
2023				var tterms = [];
2024
2025
2026				var init = function(){
2027
2028					if( el.hasClass('filters_go'))	return;
2029
2030					el.addClass('filters_go');
2031					
2032					draw_filter_bar();
2033					filter_actions();
2034					run_filter_nav_check();
2035
2036				}
2037
2038				// draw the filter bar
2039				var draw_filter_bar = function(){
2040					//console.log(all_cal_filter_data);
2041
2042					BODY.trigger('evo_filter_before_draw', [ el ]);
2043
2044					html = '';
2045					$.each( all_cal_filter_data , function( index, value){
2046
2047						// skip fast filter items
2048						if( SC.fast_filter == 'yes' && SC.ff_tax != '' && SC.ff_tax !== undefined ){
2049							__t = SC.ff_tax.split(',');
2050							if( __t.includes( index ) ) return;
2051						}
2052
2053						html += "<div class='eventon_filter evo_filter_tax_box evo_hideshow_st "+index+"' data-tax='"+ value.__tax +"' data-filter_type='"+ value.__filter_type +"'>";
2054						html += "<div class='eventon_filter_selection'>";
2055							html += "<p class='filtering_set_val'><i class='fa fa-check'></i> "+ value.__name +"<em class='fa fa-caret-down'></em></p>";							
2056						html += "</div>";
2057						html += "</div>";
2058					});
2059
2060					filter_line.html( html );
2061
2062					BODY.trigger('evo_filter_drawn', [ el ]);
2063				}
2064
2065
2066				// filter all actions
2067				var filter_actions = function(){
2068
2069					el.off('click', '.evo-filter-btn');
2070
2071					// show/hide filter bar
2072						el.on('click','.evo-filter-btn',function(){
2073							const CAL = $(this).closest('.ajde_evcal_calendar');
2074							
2075							BODY.trigger('evo_filter_btn_trig', [ CAL , O ]);
2076							if( CAL.hasClass('fp_lb')) return; // PLUG 4.6.4
2077
2078							if( !( $(this).hasClass('vis') ) ){
2079								sortbox.addClass('vis');
2080								run_filter_nav_check();
2081							}else{
2082								sortbox.removeClass('vis');
2083							}
2084
2085						});
2086
2087						// close filter when other sibling buttons clicked 4.6.4
2088						BODY.on('evo_cal_header_btn_clicked',function(event, O){	
2089							if( O.hasClass('evo-sort-btn') || O.hasClass('evo-search')  ){
2090								const CAL = O.closest('.ajde_evcal_calendar');
2091								CAL.find('.eventon_sorting_section').removeClass('vis');								
2092							}
2093						});
2094						
2095						
2096					// show hide menu
2097					el.on('click','.filtering_set_val',function(){
2098
2099						O = $(this);
2100						const filterbox = O.closest('.evo_filter_tax_box'),
2101						filter_tax = filterbox.data('tax');
2102						selected_terms = el.evo_cal_get_filter_sub_data( filter_tax , 'tterms' );
2103
2104						// close sort menu
2105							el.find('.eventon_sort_line').hide();
2106
2107						// hide already opened menus
2108							if( filterbox.hasClass('vis')){
2109								filterbox.removeClass('vis');							
2110								close_filter_menu();
2111								return;
2112							}
2113							if( fmenu.data('tax') == filter_tax ){	
2114								filterbox.removeClass('vis');							
2115								close_filter_menu();
2116								return;
2117							}else{
2118								sortbox.find('.filtering_set_val').removeClass('show');
2119								sortbox.find('.evo_filter_tax_box').removeClass('vis');
2120								filterbox.addClass('vis');	
2121							}
2122
2123						// build the filter menu from data
2124							var filter_item_data = all_cal_filter_data[ filter_tax ].__list;
2125
2126							//console.log(all_cal_filter_data);
2127							//console.log(selected_terms);
2128							
2129							var __menu_html = '<div class="evo_filter_inside evo_filter_menu_in" data-tax="'+filter_tax+'"><div class="eventon_filter_dropdown">';
2130							
2131							// each term
2132							$.each(filter_item_data, function (index, val){
2133
2134								var icon_html = '';
2135								var _class = filter_tax+'_'+ val[0] + ' '+ val[0];
2136								
2137								// parent or child term
2138								if( val[3] !== undefined && val[3] != '' && val[3] == 'n') _class += ' np';
2139
2140								//console.log(selected_terms);
2141								// select or not
2142								if( selected_terms == 'all' )  _class += ' select';
2143								if( selected_terms.includes( val[0] ) )  _class += ' select';
2144
2145								// icon
2146								if( val[2] != '' && val[2] !== undefined ){
2147									_class += ' has_icon'; icon_html = val[2];
2148								} 
2149
2150								__menu_html += '<p class="evo_filter_val '+ _class +'" data-id="'+ val[0] +'">'+ icon_html + val[1]+'</p>'
2151							});
2152							__menu_html += "</div></div>";
2153
2154							// 4.6.4
2155							BODY.trigger('evo_filter_menu_html_ready', [ el , __menu_html , O , filterbox, filter_tax]);
2156
2157
2158							if( el.hasClass('fp_side')) return; // PLUG
2159							
2160
2161							
2162						// set new menu with correct location
2163							const scrolled_width = filter_container.scrollLeft();
2164							fmenu.html( __menu_html );
2165
2166							// pluggable
2167							BODY.trigger('evo_filter_menu_built', [ el , fmenu , filter_tax ]);
2168							
2169
2170							__left_margin = filterbox.position().left + 10 - scrolled_width;
2171							__menu_width = fmenu.find('.evo_filter_inside').width();
2172
2173							__cal_left_margin = el.position().left;
2174
2175							//console.log(__cal_left_margin + ' '+ __left_margin +' '+ __menu_width + ' '+ $(window).width());
2176
2177							if( __left_margin + __menu_width + __cal_left_margin > $(window).width()  ){
2178								
2179								if(  ( __left_margin + __menu_width ) > el.width() ){
2180									new_left = el.width() - __menu_width - 10;
2181								}else{
2182									new_left = ( el.width() - __menu_width ) / 2;
2183								}								
2184								fmenu.css('left', new_left );
2185							}else{
2186								fmenu.css('left', __left_margin);
2187							}
2188					});
2189
2190					// select a static filter menu item
2191						el.on('click','p.filtering_static_val',function(){
2192
2193							BODY.trigger('evo_filter_static_clicked', [ el , $(this) ]);
2194												
2195						});
2196
2197					// select terms in filter menu
2198						el.on('click','p.evo_filter_val',function (){
2199
2200							var O = $(this);
2201							const filter_menuIN = O.closest('.evo_filter_inside'),
2202								filter_tax = filter_menuIN.data('tax'),
2203								filterbox = sortbox.find('.evo_filter_tax_box.'+ filter_tax),
2204								all_terms_obj = filter_menuIN.find('p'),
2205								new_term_id = O.data('id'),
2206								old_terms = el.evo_cal_get_filter_sub_data( filter_tax , 'terms' )
2207								;
2208							var tterms = el.evo_cal_get_filter_sub_data( filter_tax , 'nterms' );
2209
2210							var new_terms = [];
2211
2212
2213							// select filter type
2214							if( SC.filter_type == 'select' ){
2215
2216								// all value
2217								if( new_term_id == 'all' ){
2218									if( O.hasClass('select') ){
2219										all_terms_obj.removeClass('select');
2220									}else{
2221										all_terms_obj.addClass('select');
2222										new_terms.push('all');
2223									}
2224								}else{
2225									// unselect all value
2226									filter_menuIN.find('p.all').removeClass('select');
2227									O.toggleClass('select');	
2228
2229									var unselect_count = 0;
2230									all_terms_obj.each(function(){
2231										if( $(this).hasClass('select')){
2232											new_terms.push( $(this).data('id') )
2233										}else{
2234											// not select
2235											if(!$(this).hasClass('all')) unselect_count++;
2236										}
2237									});	
2238
2239									// all selected
2240									if(unselect_count == 0){
2241										filter_menuIN.find('p.all').addClass('select');
2242										new_terms.push('all');
2243									}	
2244
2245									// if all field is not visible; nothing selected = all
2246									if( new_terms.length == 0 && O.parent().find('p.all').length == 0) 
2247										new_terms.push('all');
2248								}							
2249
2250							// non select type
2251							}else{ 
2252								// all value
2253								if( new_term_id == 'all' ){
2254									// if all is already selected
2255									if( O.hasClass('select')){
2256										new_terms.push('NOT-all');
2257										all_terms_obj.removeClass('select');
2258									}else{
2259										all_terms_obj.addClass('select');
2260										new_terms.push( new_term_id );
2261									}	
2262								}else{
2263									all_terms_obj.removeClass('select');
2264									O.addClass('select');
2265									new_terms.push( new_term_id );
2266								}
2267
2268								update_filter_data( filter_tax, new_terms );
2269
2270								// process selection @4.6.6
2271									if( tterms == new_terms ){
2272										close_filter_menu();
2273									}else{					
2274										cal_resets( el );
2275												
2276										el.evo_update_sc_from_filters();					
2277
2278										run_cal_ajax( el.attr('id') ,'none','filering');
2279																								
2280										close_filter_menu();
2281										O.removeClass('show');
2282									}
2283
2284								close_filter_menu();
2285								// mark hide of menu
2286								filterbox.removeClass('vis');
2287							}
2288							
2289							// show and hide apply filter button
2290								// if new terms = temp terms
2291									if( compare_terms( new_terms, tterms) ){
2292										filterbox.removeClass('chg');										
2293									}else{
2294										filterbox.addClass('chg');			
2295									}
2296									if( compare_terms( old_terms, new_terms) ){
2297										filterbox.removeClass('set');	
2298									}else{
2299										filterbox.addClass('set');
2300									}								
2301									
2302
2303								// changed filters
2304								var chg_filters = sortbox.find('.evo_filter_tax_box.chg').length;
2305								var set_count = sortbox.find('.evo_filter_tax_box.set').length;
2306								if( SC.filter_type == 'select' ) 
2307									( chg_filters > 0 ) ? show_apply_btns() : hide_apply_btns();
2308
2309
2310							// Filter highlighted indicator 
2311								if( !( el.hasClass('flhi') ) ){
2312
2313									const filter_btn = el.find('.evo-filter-btn');	
2314
2315									if( set_count > 0){
2316										filter_btn.find('em').html( set_count ).addClass('o');	
2317									}else{
2318										filter_btn.find('em').removeClass('o');			
2319									}			
2320								}
2321
2322
2323
2324							update_filter_data( filter_tax, new_terms , 'tterms');
2325
2326							run_filter_nav_check();
2327
2328						});
2329													
2330					// apply filters button
2331						el.on('click','.evo_filter_submit',function(){
2332
2333							el.evo_filters_update_from_temp( filter_line, el );
2334							
2335							cal_resets( el);
2336
2337							close_filter_menu(); // hide filter menu
2338
2339							// update filter item button
2340							sortbox.find('.filtering_set_val').removeClass('show');
2341
2342							el.evo_update_sc_from_filters();	// update shortcode from filters
2343							
2344							run_cal_ajax( el.attr('id'),'none','filering');
2345
2346							run_filter_nav_check();
2347						});
2348
2349					// clear filters
2350						el.on('click','.evo_filter_clear',function(){
2351								
2352							el.find('.evo_filter_tax_box').each(function(){
2353								const O = $(this),
2354									tax = O.data('tax'),
2355									terms = O.data('terms');
2356
2357								O.removeClass('set');
2358								O.find('.filtering_set_val').removeClass('set show');
2359								el.find('.evo-filter-btn em').removeClass('o');
2360
2361								close_filter_menu();
2362							});
2363
2364							// update all filters with default/ onload values @4.6.1
2365							$.each( all_cal_filter_data, function( tax, tdata){
2366								update_filter_data( tax, tdata.terms );
2367							} );
2368
2369
2370							hide_apply_btns(); // hide filter action buttons
2371							
2372							// update shortcode and run new ajax for events
2373							el.evo_update_sc_from_filters();					
2374							run_cal_ajax( el.attr('id'),'none','filering');
2375
2376							run_filter_nav_check();
2377						});
2378
2379					// click on filter navs
2380						el.on('click','.evo_filter_nav',function(){
2381							O = $(this);
2382
2383							_filter_bar = O.closest('.evo_filter_bar');
2384							_filter_container = _filter_bar.find('.evo_filter_container_in');
2385							_filter_line_width = _filter_bar.find('.eventon_filter_line')[0].scrollWidth;
2386							_filter_container_width = parseInt( _filter_container.width() ) + 0;
2387							_leftPos = _filter_container.scrollLeft();
2388							_scrollable_legth = _filter_line_width - _filter_container_width;
2389
2390							const scroll_length = _filter_container_width /2;
2391							
2392							// move right
2393							if( O.hasClass('evo_filter_r') ){
2394																		
2395								_filter_container.animate({scrollLeft:_leftPos + scroll_length},200);
2396								_filter_bar.find('.evo_filter_l').addClass('vis');
2397							// move left
2398							}else{
2399								sleft = (_leftPos - scroll_length < scroll_length) ? 0 :  _leftPos - scroll_length;
2400								_filter_container.animate({scrollLeft: sleft },200);											
2401							}
2402
2403							close_filter_menu();
2404
2405							setTimeout(function(){
2406								var _leftPos = _filter_container.scrollLeft();
2407								//console.log(_leftPos);
2408								if( _leftPos < 10){
2409									_filter_bar.find('.evo_filter_l').removeClass('vis');
2410									_filter_bar.find('.evo_filter_r').addClass('vis');
2411								}
2412
2413								if( _leftPos > ( _scrollable_legth - 5 ) ){
2414									_filter_bar.find('.evo_filter_r').removeClass('vis');
2415								}
2416							},200);
2417												
2418						});
2419
2420					// on window size change
2421					$(window).on('resize',function(){
2422						run_filter_nav_check();
2423					});
2424				}
2425
2426				var compare_terms = function(a, b){
2427					if (a === b) return true;
2428					if (a == null || b == null) return false;
2429					if (a.length !== b.length) return false;
2430
2431					for (var i = 0; i < a.length; ++i) {
2432					   if (a[i] !== b[i]) return false;
2433					}
2434					return true;
2435				}
2436				var close_filter_menu = function(){
2437					fmenu.html('').data('tax','');
2438				}
2439
2440				var show_apply_btns = function(){
2441					sortbox.find('.evo_filter_aply_btns').addClass('vis');	
2442				}
2443				var hide_apply_btns = function(){
2444					sortbox.find('.evo_filter_aply_btns').removeClass('vis');		
2445				}
2446
2447				var update_filter_data = function(tax, new_val, key){
2448
2449					el.evo_cal_update_filter_data( tax , new_val , key );					
2450				}
2451
2452
2453				// adjust and position filter nav buttons
2454				var run_filter_nav_check = function(){
2455
2456					$.each( el.find('.evo_filter_bar') , function(event){
2457						_filter_bar = $(this);
2458						_filter_container = _filter_bar.find('.evo_filter_container_in');
2459						_filter_line_width = _filter_bar.find('.eventon_filter_line')[0].scrollWidth;
2460						_filter_container_width = parseInt( _filter_container.width() ) + 3;
2461						var leftPos = _filter_container.scrollLeft();
2462
2463						//console.log(_filter_line_width +' '+ _filter_container_width +' '+leftPos);
2464
2465						// filter line is not showing full
2466						if( _filter_line_width > _filter_container_width ){
2467
2468							// if some of filter line is hidden on right
2469							if( ( _filter_container_width + leftPos  ) < _filter_line_width )
2470								_filter_bar.find('.evo_filter_r').addClass('vis');
2471
2472							// if filter has been scrolled
2473							if( leftPos > 0 ){
2474								_filter_bar.find('.evo_filter_l').addClass('vis');
2475							}else{
2476								_filter_bar.find('.evo_filter_r').addClass('vis');
2477							}
2478						}else{
2479							_filter_bar.find('.evo_filter_l').removeClass('vis');
2480							_filter_bar.find('.evo_filter_r').removeClass('vis');
2481						}
2482
2483					});
2484
2485					//console.log(filter_line_width +' '+ filter_container_width +' '+leftPos);					
2486				}
2487
2488				init();
2489			}
2490
2491			// for each tax move tterms value to nterms / before sending ajax
2492			$.fn.evo_filters_update_from_temp = function(filter_line, cal){
2493				// move temp term values into new terms
2494					filter_line.find('.evo_filter_tax_box').each(function(){
2495						var taxonomy = $(this).data('tax');
2496						const tterms = cal.evo_cal_get_filter_sub_data( taxonomy , 'tterms');
2497
2498						cal.evo_cal_update_filter_data( taxonomy , tterms, 'nterms');
2499
2500						$(this).removeClass('chg');
2501					});
2502			}
2503				
2504
2505	// PRIMARY hook to get content	 
2506		// MAIN AJAX for calendar events v2.8
2507		function run_cal_ajax( cal_id, direction, ajaxtype){
2508			
2509			// identify the calendar and its elements.
2510			var CAL = ev_cal = $('#'+cal_id); 
2511
2512			// check if ajax post content should run for this calendar or not			
2513			if(CAL.attr('data-runajax')!='0'){
2514
2515				// category filtering for the calendar
2516				var cat = CAL.find('.evcal_sort').attr('cat');
2517
2518				// reset paged values for switching months
2519				if(ajaxtype=='switchmonth'){
2520					CAL.find('.cal_arguments').attr('data-show_limit_paged',1);
2521					CAL.evo_update_cal_sc({F:'show_limit_paged', V: '1'});
2522				}	
2523
2524				SC = CAL.evo_cal_functions({action:'load_shortcodes'});
2525
2526				$('body').trigger('evo_main_ajax_before', [CAL, ajaxtype, direction, SC]);		
2527
2528				var data_arg = {
2529					//action: 		'eventon_get_events',
2530					direction: 		direction,
2531					shortcode: 		SC,
2532					ajaxtype: 		ajaxtype,
2533					nonce: 			evo_general_params.n,
2534					nonceX: 		evo_general_params.nonce
2535				};	
2536
2537				EVENTS_LIST = CAL.find('.eventon_events_list');
2538
2539				$.ajax({
2540					// preload actions
2541					beforeSend: function(xhr){
2542						xhr.setRequestHeader('X-WP-Nonce', evo_general_params.nonce );
2543
2544						CAL.addClass('evo_loading');
2545
2546						// paged -- adding events to end
2547						if(ajaxtype == 'paged'){
2548							txt = EVENTS_LIST.find('.evoShow_more_events').html();
2549							EVENTS_LIST.find('.evoShow_more_events').html('. . .').data('txt',txt);
2550						}else{
2551
2552							html = evo_general_params.html.preload_events;
2553							if( SC.tiles == 'yes') html = evo_general_params.html.preload_event_tiles;
2554
2555							EVENTS_LIST.html( html );
2556							//EVENTS_LIST.slideUp('fast');
2557						}	
2558
2559						// maintain scrolltop location 4.6
2560						if( CAL.hasClass('nav_from_foot')){
2561							
2562							scrolltop = (CAL.find('.evo_footer_nav').offset().top) - CAL.data('viewport_top');
2563							$('html, body').animate({	scrollTop: scrolltop	},20);
2564						}	
2565
2566						$('body').trigger('evo_main_ajax_before_fnc',[CAL, ajaxtype, data_arg ]);	//s4.6			
2567					},
2568					type: 'POST', url: get_ajax_url('eventon_get_events'),data: data_arg,dataType:'json',
2569					success:function(data){
2570						if(!data) return false;
2571
2572						// paged calendar
2573						if(ajaxtype == 'paged'){	
2574							EVENTS_LIST.find('.evoShow_more_events').remove();
2575							EVENTS_LIST.find('.clear').remove();
2576
2577
2578							EVENTS_LIST.append( data.html + "<div class='clear'></div>");
2579
2580							// hide show more events if all events loaded
2581							var events_in_list = EVENTS_LIST.find('.eventon_list_event').length;
2582							if( 'total_events' in data && data.total_events == events_in_list){
2583								EVENTS_LIST.find('.evoShow_more_events').hide();
2584							}	
2585
2586							// for month lists duplicate headers // @+2.8.1
2587							var T = {};
2588							EVENTS_LIST.find('.evcal_month_line').each(function(){
2589								d = $(this).data('d');
2590								if( T[d]) 
2591									$(this).remove();
2592								else
2593									T[d] = true;
2594							});
2595
2596							var T = {};
2597							EVENTS_LIST.find('.sep_month_events').each(function(){
2598								d = $(this).data('d');
2599								if( T[d]){
2600									var H = $(this).html();
2601									EVENTS_LIST.find('.sep_month_events[data-d="'+d+'"]').append( H );
2602									$(this).remove();
2603								}else{T[d] = true;}
2604							});
2605							
2606						}else{
2607							EVENTS_LIST.html(data.html);
2608						}
2609
2610						
2611						// update calendar data
2612						animate_month_switch(data.cal_month_title, CAL.find('.evo_month_title'));
2613						CAL.evo_cal_functions({action:'update_shortcodes',SC: data.SC});
2614						CAL.evo_cal_functions({action:'update_json',json: data.json});
2615
2616						// run cal process code
2617						CAL.evo_calendar({
2618							SC: data.SC,
2619							json: data.json
2620						});
2621							
2622
2623						$('body').trigger('calendar_month_changed',[CAL, data]);
2624						
2625						$('body').trigger('evo_main_ajax_success', [CAL, ajaxtype, data, data_arg]);
2626															
2627					},complete:function(data){
2628
2629						// show events list events if not set to hide on load
2630						if(! EVENTS_LIST.hasClass('evo_hide')) EVENTS_LIST.delay(300).slideDown('slow');
2631						
2632						// maintain scrolltop location 4.6
2633						if( CAL.hasClass('nav_from_foot')){
2634							
2635							setTimeout(function(){
2636								scrolltop = (CAL.find('.evo_footer_nav').offset().top) - CAL.data('viewport_top');
2637								$('html, body').animate({	scrollTop: scrolltop	},20);
2638								CAL.removeClass('nav_from_foot');
2639							},302);														
2640						}					
2641
2642						// pluggable
2643						$('body').trigger('evo_main_ajax_complete', [CAL, ajaxtype, data.responseJSON , data_arg]);
2644						CAL.removeClass('evo_loading');
2645					}
2646				});
2647			}			
2648		}
2649
2650		$('body').on('evo_run_cal_ajax',function(event,cal_id, direction, ajaxtype){
2651			run_cal_ajax( cal_id, direction, ajaxtype);
2652		});
2653
2654		// deprecated bridge function for sortby value 
2655		function ajax_post_content(sortby, cal_id, direction, ajaxtype){
2656			run_cal_ajax( cal_id, direction, ajaxtype);
2657		}
2658
2659	// Click events listener - 4.6
2660		$(document).on('click', function(event) {
2661			//event.stopPropagation(); 
2662			//console.log($(event.target));
2663			BODY.trigger('clicked_on_page', [ $(event.target) , event ]);
2664		    
2665		    //console.log(event);
2666		});
2667
2668	// subtle animation when switching months
2669		function animate_month_switch(new_data, title_element){			
2670			var current_text = title_element.html();
2671			var CAL = title_element.closest('.ajde_evcal_calendar');
2672
2673			title_element.html(new_data);
2674			return;
2675		}
2676	
2677	// event location archive card page
2678		// @u 2.8.6
2679		$('body').find('.evo_location_map').each(function(){			
2680			$(this).evo_load_gmap();
2681		});
2682
2683		// on event card lightbox load -> taxonomy details @since 4.2 u4.6
2684		$('body').on('evo_ajax_complete_eventon_get_tax_card_content', function(event,  OO){
2685			
2686			LB = $('body').find('.'+ OO.lightbox_key);
2687
2688			setTimeout(function(){
2689
2690				// run map load
2691				if( LB.find('.evo_trigger_map').length > 0 ){
2692					map_id_elm = LB.find('.evo_trigger_map');			
2693					map_id_elm.evo_load_gmap();
2694					console.log('Loading Event Map');
2695				}
2696				
2697				// run countdown timers
2698				LB.find('.evo_countdowner').each(function(){
2699					$(this).evo_countdown();
2700				});
2701
2702				// run calendar filtering function
2703				CAL = LB.find('.ajde_evcal_calendar');
2704				CAL.evo_cal_filtering();
2705
2706			},500);
2707
2708
2709			
2710			
2711		});
2712		
2713	// SINGLE EVENTS
2714		// Loading single event json based content
2715			$('body').on('evo_load_single_event_content', function(event, eid, obj){
2716				var ajaxdataa = {};
2717				ajaxdataa['eid'] = eid;
2718				ajaxdataa['nonce'] = the_ajax_script.postnonce;	
2719
2720				// pass on other event values
2721				if(obj.data('j')){
2722					$.each(obj.data('j'), function(index,val){
2723						ajaxdataa[ index] = val;
2724					});
2725				}			
2726				
2727				$.ajax({
2728					beforeSend: function(){ 	},	
2729					url:	get_ajax_url('eventon_load_event_content'),
2730					data: 	ajaxdataa,	dataType:'json', type: 	'POST',
2731					success:function(data){
2732						$('body').trigger('evo_single_event_content_loaded', [data, obj]);
2733					},complete:function(){ 	}
2734				});
2735			});
2736	
2737		if(BODY.evo_is_mobile()){
2738			if($('body').find('.fb.evo_ss').length != 0){
2739				$('body').find('.fb.evo_ss').each(function(){
2740					obj = $(this);
2741					obj.attr({'href':'http://m.facebook.com/sharer.php?u='+obj.attr('data-url')});
2742				});
2743			}
2744		}
2745
2746		// on single event page
2747		if($('body').find('.evo_sin_page').length>0){
2748			$('.evo_sin_page').each(function(){
2749				$('body').trigger('evo_load_single_event_content',[ $(this).data('eid'), $(this)]);
2750				$(this).find('.desc_trig ').attr({'data-ux_val':'none'});
2751			});
2752		}
2753		
2754		// Single events box
2755			// Click on single event box
2756				$('.eventon_single_event').on('click', '.evcal_list_a',function(event){
2757					var obj = $(this);				
2758					var CAL = obj.closest('.ajde_evcal_calendar');
2759					var SC = CAL.evo_shortcode_data();
2760
2761					event.preventDefault();
2762
2763					// open in event page
2764					if(SC.ux_val == 4){ 
2765						var url = obj.parent().siblings('.evo_event_schema').find('[itemprop=url]').attr('href');
2766						window.location.href= url;
2767					}else if(SC.ux_val == '2'){ // External Link
2768						var url = SC.exturl;
2769						window.location.href= url;
2770					}else if(SC.ux_val == 'X'){ // do not do anything
2771						return false;
2772					}
2773				});
2774			// each single event box
2775				$('body').find('.eventon_single_event').each(function(){
2776					var _this = $(this);
2777
2778					var CAL = _this.closest('.ajde_evcal_calendar');
2779					var SC = CAL.evo_shortcode_data();	
2780					var evObj = CAL.find('.eventon_list_event');									
2781
2782					// show expanded eventCard
2783					if( SC.expanded =='yes'){
2784						_this.find('.evcal_eventcard').show();
2785						var idd = _this.find('.evcal_gmaps');						
2786
2787						// close button
2788						_this.find('.evcal_close').parent().css({'padding-right':0});
2789						_this.find('.evcal_close').hide();
2790
2791						//console.log(idd);
2792						var obj = _this.find('.desc_trig');
2793
2794						// Google Map
2795						_this.find('.evo_metarow_gmap').evo_load_gmap();
2796					
2797						// mark as eventcard open @since 4.4
2798						evObj.find('.event_description').addClass('open');
2799
2800					// open eventBox and lightbox	
2801					}else if(SC.uxval =='3'){
2802
2803						var obj = _this.find('.desc_trig');
2804						// remove other attr - that cause to redirect
2805						obj.removeAttr('data-exlk').attr({'data-ux_val':'3'});
2806					}
2807
2808					// show event excerpt
2809					var ev_excerpt = CAL.find('.event_excerpt').html();
2810					
2811					if(ev_excerpt!='' && ev_excerpt!== undefined && SC.excerpt =='yes' ){
2812						var appendation = '<div class="event_excerpt_in">'+ev_excerpt+'</div>'
2813						evObj.append(appendation);
2814					}
2815
2816					// trigger support @since 4.4
2817					var obj = evObj.find('.desc_trig');
2818					var event_id = evObj.data('event_id');
2819
2820
2821					$('body').trigger('evo_slidedown_eventcard_complete',[ event_id, obj]);	
2822				});
2823
2824
2825// Search Scripts
2826	// Enter key detection for pc
2827		$.fn.evo_enterKey = function (fnc) {
2828		    return this.each(function () {
2829		        $(this).keypress(function (ev) {
2830		            var keycode = (ev.keyCode ? ev.keyCode : ev.which);
2831		            if (keycode == '13') {
2832		                fnc.call(this, ev);
2833		            }
2834		        })
2835		    })
2836		}
2837
2838	// when a header button is clicked
2839	BODY.on('evo_cal_header_btn_clicked',function(event, O, CAL){
2840
2841		var SC = CAL.evo_shortcode_data();	
2842
2843		// if search is open on init > return
2844		if( evo_general_params.cal.search_openoninit ) return;
2845
2846		if( O.hasClass('evo-search')){
2847			if( O.hasClass('vis')){
2848				CAL.find('.evo_search_bar').show(1, function(){
2849					$(this).find('input').focus();
2850				});
2851			}else{
2852				CAL.find('.evo_search_bar').hide();
2853			}
2854		}
2855
2856		// hide the search
2857		if( O.hasClass('evo-sort-btn') || O.hasClass('evo-filter-btn')){
2858			CAL.find('.evo_search_bar').hide();
2859		}
2860
2861	});
2862		
2863
2864
2865	// Submit search from search box u 4.5.8
2866		$('body').on('click','.evo_do_search',function(){
2867			do_search_box( $(this) );
2868		});
2869
2870		// dynamic enter key press on the search input field @4.2
2871		$(".evo_search_field").evo_enterKey(function () {
2872			do_search_box( $(this).siblings('.evo_do_search') );
2873		});
2874			
2875
2876		// primary search function
2877		function do_search_box(OBJ){
2878			SearchVal = OBJ.closest('.evosr_search_box').find('input').val();
2879			Evosearch = OBJ.closest('.EVOSR_section');
2880			OBJ.closest('.evo_search_entry').find('.evosr_msg').hide();
2881
2882			//console.log(SearchVal);
2883
2884			if( SearchVal === undefined || SearchVal == ''){
2885				OBJ.closest('.evo_search_entry').find('.evosr_msg').show();
2886				return false;
2887			}
2888
2889			$('body')
2890			.on('evo_ajax_beforesend_evo_get_search_results', function (event, uid){
2891				Evosearch.find('.evo_search_results_count').hide();
2892				Evosearch.addClass('searching');
2893			}).on('evo_ajax_complete_evo_get_search_results', function (event, uid){
2894				Evosearch.removeClass('searching');
2895			}).on('evo_ajax_success_evo_get_search_results', function (event, uid, data){
2896				Evosearch.find('.evo_search_results').html( data.content);
2897
2898				if(Evosearch.find('.no_events').length==0){
2899					// find event count
2900					Events = Evosearch.find('.evo_search_results').find('.eventon_list_event').length;
2901					Evosearch.find('.evo_search_results_count span').html( Events);
2902					Evosearch.find('.evo_search_results_count').fadeIn();
2903				}
2904			});
2905
2906			var ajax_results = OBJ.evo_admin_get_ajax({
2907				'ajaxdata': {
2908					//action: 		'eventon_search_evo_events',
2909					search: 		SearchVal,
2910					shortcode:  	Evosearch.find('span.data').data('sc'),
2911					nonce: 			evo_general_params.n				
2912				},
2913				ajax_type:'endpoint',
2914				ajax_action:'eventon_search_evo_events',
2915				'uid':'evo_get_search_results',
2916				end: 'client'
2917			});
2918
2919		}
2920
2921	// submit search from calendar
2922		$('body').on('click','.evosr_search_btn',function(){	
2923			search_within_calendar( $(this).siblings('input') );		});
2924		$(".evo_search_bar_in input").evo_enterKey(function () {	
2925			search_within_calendar( $(this) );		});
2926
2927		function search_within_calendar(obj){
2928
2929			var ev_cal = obj.closest('.ajde_evcal_calendar');
2930			
2931			ev_cal.evo_update_cal_sc({F:'show_limit_paged',V: '1' });
2932			ev_cal.evo_update_cal_sc({F:'s',V: obj.val() });
2933
2934			run_cal_ajax( ev_cal.attr('id'),'none','search');
2935			
2936		   	return false;	
2937		}	
2938
2939		// reset search field @since 4.5
2940		$('body').on('evo_main_ajax_complete',function(event,CAL, ajaxtype, responseJSON , data_arg ){
2941
2942			if(ajaxtype == 'search' ){
2943				if( data_arg.shortcode['s'] != '' ){
2944					CAL.find('.evosr_search_clear_btn').addClass('show');
2945				}					
2946			}
2947		}).on('click','.evosr_search_clear_btn',function(event){
2948			event.preventDefault();
2949			const obj = $(this);
2950			var ev_cal = obj.closest('.ajde_evcal_calendar');
2951			ev_cal.evo_update_cal_sc({F:'s',V: '' });
2952			run_cal_ajax( ev_cal.attr('id'),'none','search');
2953
2954			obj.removeClass('show');
2955			obj.siblings('input').val('');
2956		});
2957
2958
2959// supportive
2960	// ajax url function  @u 4.5.5
2961		function get_ajax_url(action){
2962			var ajax_type = 'endpoint';
2963			if('ajax_method' in evo_general_params ) ajax_type = evo_general_params.ajax_method;
2964			return $('body').evo_get_ajax_url({a:action, type: 	ajax_type });
2965		}
2966	// handlebar additions
2967		function handlebar_additional_arguments(){
2968			Handlebars.registerHelper('ifE',function(v1, options){
2969				return (v1 !== undefined && v1 != '' && v1)
2970                    ? options.fn(this)
2971                    : options.inverse(this);
2972			});
2973
2974			Handlebars.registerHelper('ifEQ',function(v1, v2, options){
2975				return ( v1 == v2)? options.fn(this): options.inverse(this);
2976			});
2977			Handlebars.registerHelper('ifNEQ',function(v1, v2, options){
2978				return ( v1 != v2)? options.fn(this): options.inverse(this);
2979			});
2980			Handlebars.registerHelper('BUStxt',function(V, options){	
2981				if( !( V in BUS.txt) ) return V;
2982				return BUS.txt[V];
2983			});
2984			Handlebars.registerHelper('GetDMnames',function(V, U, options){				
2985				return BUS.dms[U][ V ];
2986			});
2987			// get total of increments
2988			Handlebars.registerHelper('forAdds',function(count, add_val, options){	
2989				O = '';
2990				for(x=1; x<= count; x++){	O += add_val;	}			
2991				return O;
2992			});
2993			Handlebars.registerHelper('GetEvProp',function(EID, PROP, CALID){
2994				EID = EID.split('-');	
2995				EV = $('#'+ CALID).find('.evo_cal_events').data('events');
2996				
2997				var O = '';
2998				$.each(EV, function(i,d){
2999					if( d.ID == EID[0] && d.ri == EID[1]){
3000						if( !(PROP in d.event_pmv)) return;
3001						O = d.event_pmv[PROP][0];
3002					}
3003				});
3004				return O;
3005			});
3006			Handlebars.registerHelper('GetEvV',function(EID, PROP, CALID){
3007				EID = EID.split('-');	
3008				EV = $('#'+ CALID).find('.evo_cal_events').data('events');
3009				
3010				var O = '';
3011				$.each(EV, function(i,d){
3012					if( d.ID == EID[0] && d.ri == EID[1]){
3013						O = d[PROP];
3014					}
3015				});
3016				return O;
3017			});
3018			Handlebars.registerHelper('COUNT',function( V){		
3019				return Object.keys(V).length;
3020			});
3021			Handlebars.registerHelper('CountlimitLess',function( AR, C,options){		
3022				var L= Object.keys(AR).length;
3023				return ( L < C)? options.inverse(this): options.fn(this);
3024			});
3025			Handlebars.registerHelper('ifCOND',function(v1, operator, v2, options){
3026				return checkCondition(v1, operator, v2)
3027	                ? options.fn(this)
3028	                : options.inverse(this);
3029			});
3030			Handlebars.registerHelper('toJSON', function(obj) {
3031			    return new Handlebars.SafeString(JSON.stringify(obj));
3032			});
3033			Handlebars.registerHelper('Cal_def_check',function(V, options){		
3034				if( BUS.cal_def && BUS.cal_def[V] ) return options.fn(this);
3035				return options.inverse(this);
3036			});
3037			Handlebars.registerHelper('TypeCheck',function(V, options){		
3038				if( options.type == V ) return options.fn(this);
3039				return options.inverse(this);
3040			});
3041		}
3042		function checkCondition(v1, operator, v2) {
3043	        switch(operator) {
3044	            case '==':
3045	                return (v1 == v2);
3046	            case '===':
3047	                return (v1 === v2);
3048	            case '!==':
3049	                return (v1 !== v2);
3050	            case '<':
3051	                return (v1 < v2);
3052	            case '<=':
3053	                return (v1 <= v2);
3054	            case '>':
3055	                return (v1 > v2);
3056	            case '>=':
3057	                return (v1 >= v2);
3058	            case '&&':
3059	                return (v1 && v2);
3060	            case '||':
3061	                return (v1 || v2);
3062	            default:
3063	                return false;
3064	        }
3065	    }
3066	// @2.9.1
3067	// increase and reduce quantity
3068	    $('body').on('click','.evo_qty_change', function(event){
3069	        var OBJ = $(this);
3070	        var QTY = oQTY = parseInt(OBJ.siblings('em').html());
3071	        var MAX = OBJ.siblings('input').attr('max');
3072	        var BOX = OBJ.closest('.evo_purchase_box');
3073
3074	        var pfd = BOX.find('.evo_purchase_box_data').data('pfd');
3075	        
3076
3077	        (OBJ.hasClass('plu'))?  QTY++: QTY--;
3078
3079	        QTY =(QTY==0)? 1: QTY;
3080	        QTY = (MAX!='' && QTY > MAX)? MAX: QTY;
3081
3082	        // new total price
3083	        var sin_price = OBJ.parent().data('p');
3084	        new_price = sin_price * QTY;
3085
3086	        new_price = get_format_price( new_price, pfd);
3087
3088	        BOX.find('.total .value').html( new_price);
3089
3090	        OBJ.siblings('em').html(QTY);
3091	        OBJ.siblings('input').val(QTY);
3092
3093	        $('body').trigger('evo_qty_changed',[QTY,oQTY, new_price,OBJ ]);
3094	    });
3095
3096    // Total formating
3097        function get_format_price(price, data){
3098
3099            // price format data
3100            PF = data;
3101           
3102            totalPrice = price.toFixed(PF.numDec); // number of decimals
3103            htmlPrice = totalPrice.toString().replace('.', PF.decSep);
3104
3105            if(PF.thoSep.length > 0) {
3106                htmlPrice = _addThousandSep(htmlPrice, PF.thoSep);
3107            }
3108            if(PF.curPos == 'right') {
3109                htmlPrice = htmlPrice + PF.currencySymbol;
3110            }
3111            else if(PF.curPos == 'right_space') {
3112                htmlPrice = htmlPrice + ' ' + PF.currencySymbol;
3113            }
3114            else if(PF.curPos == 'left_space') {
3115                htmlPrice = PF.currencySymbol + ' ' + htmlPrice;
3116            }
3117            else {
3118                htmlPrice = PF.currencySymbol + htmlPrice;
3119            }
3120            return htmlPrice;
3121        }
3122        function _addThousandSep(n, thoSep){
3123            var rx=  /(\d+)(\d{3})/;
3124            return String(n).replace(/^\d+/, function(w){
3125                while(rx.test(w)){
3126                    w= w.replace(rx, '$1'+thoSep+'$2');
3127                }
3128                return w;
3129            });
3130        };
3131
3132// DEPRECATING 
3133	// LIGHTBOX		
3134		// since 4.2 moving to functions
3135		// open lightbox @2.9
3136			BODY.on('evo_open_lightbox',function(event, lb_class, content){
3137				const LIGHTBOX = $('.evo_lightbox.'+lb_class).eq(0);
3138
3139				// if already open
3140				if(LIGHTBOX.is("visible")===true) return false;
3141
3142				if( content != ''){
3143					LIGHTBOX.find('.evo_lightbox_body').html( content );
3144				}
3145				BODY.trigger('evolightbox_show', [ lb_class ]);
3146			});
3147
3148		// click outside close LB
3149			BODY.on('clicked_on_page', function(event, obj, ev ){
3150				if( obj.hasClass('evo_content_inin')){
3151					closing_lightbox( obj.closest('.evo_lightbox') );
3152				}
3153			});
3154
3155		// close popup
3156			BODY.on('click','.evolbclose', function(){	
3157				if( $(this).hasClass('evolb_close_btn')) return;
3158				LIGHTBOX = 	$(this).closest('.evo_lightbox');
3159				closing_lightbox( LIGHTBOX );				
3160			});
3161
3162		// close with click outside popup box when pop is shown						
3163			function closing_lightbox( lightboxELM){
3164				
3165				if(! lightboxELM.hasClass('show')) return false;
3166				Close = (lightboxELM.parent().find('.evo_lightbox.show').length == 1)? true: false;
3167				lightboxELM.removeClass('show');
3168
3169				$('body').trigger('lightbox_before_event_closing', [lightboxELM]);
3170
3171				setTimeout( function(){ 
3172					lightboxELM.find('.evo_lightbox_body').html('');
3173					
3174					if(Close){
3175						$('body').removeClass('evo_overflow');
3176						$('html').removeClass('evo_overflow');
3177					}
3178					
3179					// trigger action to hook in at this stage
3180						$('body').trigger('lightbox_event_closing', [lightboxELM]);
3181				}, 100);
3182			}
3183
3184		// when lightbox open triggered
3185			$('body').on('evolightbox_show',function(event, lb_class){
3186				$('.evo_lightboxes').show();
3187				$('body').addClass('evo_overflow');
3188				$('html').addClass('evo_overflow');
3189
3190				$('body').trigger('evolightbox_opened',[ lb_class ]);
3191			});
3192
3193
3194});

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.