PageSourceSearch

https://projectprotech.ca/wp-content/plugins/eventON/assets/js/eventon_script.js?ver=4.1.3

js projectprotech.ca collected 2026-09-29 00:08:11 UTC 76,645 bytes, 2,536 lines download raw bytes

1/**
2 * Javascript code that is associated with the front end of the calendar
3 * @version 4.1.1
4 */
5
6jQuery(document).ready(function($){
7		
8	var BODY = $('body');
9	var BUS = ''; // initial eventon calendar data
10	var ajax_url = '';
11
12	init();
13	
14// EventON calendar main function
15// 2.8.6
16	$.fn.evo_calendar = function (options) {
17
18		el = this;
19		var cal = {};
20		var defaults = {
21			'SC': {},
22			'json':{}
23		};
24		var calO = {};
25
26		var init = function(){
27			calO = el.O = $.extend({},defaults, options);
28
29			// load shortcodes to calendar
30			if( calO.SC !== undefined){
31				el.evo_cal_functions({action:'update_shortcodes',SC: calO.SC});
32			}
33
34			// load events json to calednar
35			if( calO.json !== undefined){
36				el.find('.evo_cal_events').data('events', calO.json);
37			}
38
39			load_maps();
40			interactions();			
41		};
42
43		var load_maps = function(){
44			if(calO.SC.evc_open == 'yes'){
45				el.find('.desc_trig').each(function(index){
46					var self = this;
47					setTimeout(function(){
48						$(self).evoGenmaps({'fnt':2,'cal': el});
49					},index*600);					
50				});
51			}
52		};
53		
54		var interactions = function(){
55			close_eventcard();
56			counters();
57			live_now_cal();
58		}
59
60
61		var live_now_cal = function(){
62			$(el).find('.evo_img_time').each(function(){
63				if( $(this).closest('a.desc_trig').find('em.evcal_time').length ){
64					_html = $(this).closest('a.desc_trig').find('em.evcal_time')[0].outerHTML;
65					$(this).html( _html );
66				}				
67			});
68		}
69
70		var counters = function(){
71			$(el).find('.evo_countdowner').each(function(){
72				$(this).evo_countdown();
73			});
74		}
75
76		var close_eventcard = function(){
77			$(el).on('click','.evcal_close',function(){
78				$(this).closest('.evcal_eventcard').slideUp().removeClass('open');
79			});
80		}
81		
82
83		init();	
84	};
85
86// localize event time function
87	$.fn.evo_local_time = function( options){
88		el = this;
89
90		$(el).find('.evo_mytime').each(function(){
91			const obj = $(this);
92			const event_obj = obj.closest('.eventon_list_event');
93			var time  = obj.data('times');
94			var tformat = obj.data('tform');
95
96			new_time = time.split('-');
97			
98			utc_offset = $(this).data('tzo');
99
100			start = parseInt(new_time[0]);
101			end = parseInt(new_time[1]);
102			offset_start = start + utc_offset;
103
104			// end
105			var Me = moment.unix( end + utc_offset ).utc().local();
106			var M1 = moment.unix( offset_start ).utc().local();
107
108			var _html = '';
109
110			if( Me.format('YYYY/M') != M1.format('YYYY/M')){
111				_html = M1.format( tformat ) +' - '+ Me.format( tformat );
112			}else{
113				_html = M1.format( tformat );
114			}
115
116			event_obj.find('.evo_mytime').find('b').html( _html );
117			
118
119			event_obj.find('.evo_mytime').removeClass('tzo_trig');
120			
121		});
122
123	};
124	// user local time		
125		BODY.on('click','.tzo_trig',function(event){
126			event.preventDefault();
127			event.stopPropagation();			
128			$(this).parent().evo_local_time();
129			return;
130		});
131
132		BODY.on('calendar_month_changed',function(event, CAL){
133			//CAL.evo_local_time();
134		});
135
136
137// RUN on Page load
138	function init(){
139
140		ajax_url = the_ajax_script.ajax_method=='ajax' ?
141			evo_general_params.ajaxurl: 
142			the_ajax_script.rurl + 'eventon/v1/data?action=init';
143
144		init_run_gmap_openevc();
145		fullheight_img_reset();	
146
147
148		init_load_cal_data();
149
150		handlebar_additional_arguments();
151
152		// run basic countdown timers
153		BODY.find('.evo_countdowner').each(function(){
154			$(this).evo_countdown();
155		});
156
157
158		jitsi();
159	}
160
161// Virtual Events & jitsi
162	function jitsi(mod_refresh){
163		
164		const domain = 'meet.jit.si';
165	    const api = [];
166
167	    jQuery('.evo-jitsi-wrapper').each(function(index, element) {
168	    	const O = $(this);
169	    	const eventO = O.closest('.eventon_list_event');
170
171	    	// check if mod refresh is set or no
172	    	if( mod_refresh != '' && mod_refresh == 'mod_refresh_no' && O.hasClass('mod')) return;
173
174	        var roomName = jQuery(element).data('n'),
175	            width = jQuery(element).data('width'),
176	            height = jQuery(element).data('height'),
177	            audioMuted = jQuery(element).data('audiomute'),
178	            videoMuted = jQuery(element).data('videomute'),
179	            screenSharing = jQuery(element).data('screen');
180	           
181
182	        const myOverwrite =
183			{
184			 	'TOOLBAR_BUTTONS': $(element).data('d'),
185			    "DEFAULT_BACKGROUND": '#494a4e',
186			    'MOBILE_APP_PROMO': false,
187			    'SETTINGS_SECTIONS':['devices', 'language', 'profile', 'calendar'],
188			};
189
190
191	        const options = {
192	            roomName,
193	            width,
194	            height,
195	            parentNode: element,	            
196	            configOverwrite: { 
197	            	startWithAudioMuted: audioMuted,
198	                startWithVideoMuted: videoMuted,
199	                startScreenSharing: false,	  
200	                disableInviteFunctions: false,             
201	            },
202	            interfaceConfigOverwrite: myOverwrite,     
203	        };
204
205
206	        const api = new JitsiMeetExternalAPI(domain, options);      
207
208	        api.addEventListener('participantRoleChanged', function(event){
209
210	        	// record moderator joined
211	        	if (event.role === "moderator"){	        		
212	        		_record_moderator_join( 'yes', eventO.data('event_id'), eventO.data('ri'));
213	        	}
214
215	        	const pp = jQuery(element).data('p');
216	        	if (event.role === "moderator" && pp != '__') {
217	        		ppp = pp.replace('_','');
218			        api.executeCommand('password', ppp);
219			    }	        	
220	        });	
221
222	        // moderator leave	        
223	        api.addEventListener('videoConferenceLeft', function(event){
224	        	if( eventO.find('.evo_vir_data').data('ismod') =='y'){
225	        		_record_moderator_join( 'no', eventO.data('event_id'), eventO.data('ri'));
226	        		O.siblings('.evo_vir_mod_left').show();
227	        		O.hide();
228	        	}
229	        });
230	    });
231	}
232	// record moderator logins for jitsi
233		function _record_moderator_join(joined, eid, ri){
234			var data_arg = {
235				'action': 'eventon_record_mod_joined',
236				'eid': eid,
237				'ri': ri,
238				'joined': joined,
239				'nonce': evo_general_params.n,				
240			};
241
242			$.ajax({
243				beforeSend: function(){},
244				type: 'POST',url: ajax_url,data: data_arg,dataType:'json',
245				success:function(data){	}
246			});
247		}
248	
249
250	// refresh event card elements  - evo_reload_virtual_events
251	// @+ 3.1
252		$('body').on('evo_refresh_elements',function(event, send_data ){
253
254			if( send_data.length <= 0 || !send_data) return;
255
256			send_data['action'] = 'eventon_refresh_elm';
257			send_data['nonce'] = evo_general_params.n;
258
259			$.ajax({
260				beforeSend: function(){	
261					if( 'evo_data' in send_data){
262						$.each(send_data.evo_data, function(ekey, eclasses){
263							$.each(eclasses, function(classnm, val){	
264								if(val && 'loader' in val && val['loader'] && 'loader_class' in val){
265									$('#event_'+ekey).find('.'+val['loader_class']).addClass('evoloading');	
266								}
267							});
268						});	
269					}
270				},
271				type: 'POST',url: ajax_url,data: send_data,dataType:'json',
272				success:function(data){
273					if( data.status == 'good' ){
274						evo_apply_refresh_content( data );
275					}
276				},complete: function(){	
277					if( 'evo_data' in send_data){
278						$.each(send_data.evo_data, function(ekey, eclasses){
279							$.each(eclasses, function(classnm, val){
280								if(val && 'loader' in val && val['loader'] && 'loader_class' in val){
281									$('#event_'+ekey).find('.'+val['loader_class']).removeClass('evoloading');	
282								}
283							});
284						});	
285					}
286				}
287			});
288		});
289
290		// refresh the closest hearbeat run parent
291		$('body').on('evo_refresh_designated_elm', function(ee, elm, elm_class, extra_data){
292
293			//get closest event object
294			const event = $(elm).closest('.eventon_list_event');
295
296			if( !event ) return;
297			if( event.find('.'+elm_class).length == 0 ) return;
298
299			const refresh_elm = event.find('.'+elm_class);
300
301			var send_data = {};		
302
303			send_data['evo_data'] = build_elm_refresh_data( refresh_elm , extra_data);
304			
305			$('body').trigger('evo_refresh_elements',[ send_data ]);
306		});
307
308	// record sign in - virtual plus
309		// @+3.1
310		$('body').on('click','.evo_vir_signin_btn',function(){
311						
312			extra_data = {};
313			extra_data['signin'] = 'y';
314			extra_data['refresh_main'] = 'y';
315			extra_data['loader'] = true;
316			extra_data['loader_class'] = 'evo_vir_main_content';
317
318			$('body').trigger('evo_refresh_designated_elm',[ $(this) , 'evo_vir_data',extra_data]);
319		});
320
321
322	// apply refresh event element content with matching data that is sent
323		function evo_apply_refresh_content(data){
324
325			if( 'evo_data' in data ){
326
327				$.each(data.evo_data, function(eclass, boxes){
328					// if event exists in the page
329
330					var vir_data_vals = false;
331					if( 'evo_vir_data' in boxes) vir_data_vals = boxes.evo_vir_data.data;
332
333					$('body').find('.'+eclass).each(function(){
334						const event_elm = $(this);
335
336						// set html
337						$.each(boxes, function(boxclass, boxdata){
338							if( !('html' in boxdata) ) return;
339							if( boxdata.html == '' ) return;
340							if( event_elm.find('.'+boxclass).legnth <= 0 ) return;
341
342							event_elm.find( '.'+boxclass ).html( boxdata.html );
343						});
344
345						// only for virtual event update
346						if( vir_data_vals ){
347
348							// reload jitsi for main content - if main content html is sent it will refresh
349								if( vir_data_vals && ('vir_type' in vir_data_vals) 
350									&& vir_data_vals.vir_type == 'jitsi' 
351									&& ('evo_vir_main_content' in boxes) 
352									&& ('html' in boxes.evo_vir_main_content)  
353									&& boxes.evo_vir_main_content.html != ''
354								){
355									jitsi('mod_refresh_no');
356								}
357
358							// update data for sent object
359								$.each(boxes, function(boxclass, boxdata){
360									if( boxdata.data == '' || boxdata.data === undefined) return;
361
362									// for jitsi if mod left --> force refresh main
363									if( boxdata !== undefined && vir_data_vals.vir_type == 'jitsi' && vir_data_vals.mod_joined =='left'){
364										
365										// force refresh main
366										boxdata.data['refresh_main'] = 'yy';
367									}	
368
369									event_elm.find( '.'+boxclass ).data( boxdata.data );
370								});
371						}
372
373					});
374				});
375			}
376		}
377	// get refresh data for specified elem
378		function build_elm_refresh_data( elm , extra_data){
379
380			dataObj = {};
381
382			// get closest event element and event id/ri from it
383				const event = $(elm).closest('.eventon_list_event');
384
385				dataObj = {}
386				const ekey = event.data('event_id')+'_'+ parseInt(event.data('ri'));
387				dataObj[ ekey ] = {};
388
389			const key2 = elm.data('key');
390
391			// append new data to the element
392			dataObj[ ekey ][ key2 ] = elm.data();
393
394			// check if awaitmod need checked
395				if( elm.data('check_awaitmod')){
396
397					// if waiting for mod element is on page -> set as user awaiting mod
398					if( ( event.find('.evo_vir_jitsi_waitmod').length>0) )
399						dataObj[ ekey ][ key2 ]['refresh_main'] = 'yy';
400
401					// if jitsi is loaded on page & mod is still in --> stop refreshing main
402					if( event.find('.evo-jitsi-wrapper').length>0 && dataObj[ ekey ][ key2 ]['mod_joined'] !='left') 
403						dataObj[ ekey ][ key2 ]['refresh_main'] =  '';
404				}
405
406			// append extra data
407			if( extra_data && extra_data !== undefined){
408				$.each( extra_data, function (index,val){
409					dataObj[ ekey ][ key2 ][index] = val;
410				});
411			}
412
413			return dataObj;
414		}	
415
416	// mark as virtual event ended
417		$(document)
418		.on('evo_before_trig_ajax',function(event, obj){
419			if(!obj.hasClass('evo_trig_vir_end')) return;
420			
421			var new_ajax_data = $(document).data( 'evo_data');
422			new_ajax_data['fnct'] = 'mark_event_ended';
423			$(document).data( 'evo_data', new_ajax_data );
424			
425		})
426		.on('evo_beforesend_trig_ajax',function( event, obj, new_ajax_data){
427			if(!obj.hasClass('evo_trig_vir_end')) return;
428
429			obj.closest('.evo_vir_mod_box').addClass('evoloading');
430		})
431		.on('evo_success_trig_ajax',function( event, obj, new_ajax_data, return_data){
432			if(!obj.hasClass('evo_trig_vir_end')) return;
433
434			// if virtual events were marked as ended
435			if(!('_vir_ended' in return_data)) return;
436
437			// refresh the virtual main content
438			extra_data = {};
439			extra_data['refresh_main'] = 'yy';
440			extra_data['loader'] = true;
441			extra_data['loader_class'] = 'evo_vir_main_content';
442
443			//console.log(extra_data);
444
445			$('body').trigger('evo_refresh_designated_elm',[ obj , 'evo_vir_data',extra_data]);
446		})
447		.on('evo_complete_trig_ajax',function( event, obj, new_ajax_data){
448
449			if(!obj.hasClass('evo_trig_vir_end')) return;
450			obj.closest('.evo_vir_mod_box').removeClass('evoloading');
451		})
452		;
453
454// Heartbeat - added 3.1
455	//hook into heartbeat-send
456	jQuery(document).on('heartbeat-send', function(e, data) {
457
458		// if there is run heartbeat items
459		if( $('body').find('.evo_refresh_on_heartbeat').length>0 ){
460			
461			$('body').find('.evo_refresh_on_heartbeat').each(function(){
462				if( $(this).closest('.eventon_list_event').length <= 0) return;
463				if( $(this).data('refresh')!== undefined && !$(this).data('refresh') ) return;
464
465				data['evo_data'] = build_elm_refresh_data( $(this) );
466			});			
467		}
468	});
469	
470	//hook into heartbeat-tick
471	jQuery(document).on('heartbeat-tick', function(e, data) {	
472		evo_apply_refresh_content( data );
473	});
474
475// Schedule View - 4.0
476	$('body')
477	.on('evo_init_ajax_success_each_cal',function(event, data, i, v, CAL){
478		$('body').find('.ajde_evcal_calendar.evoSV').each(function(){
479			evosv_populate( $(this) );
480		});
481	})
482	.on('evo_main_ajax_complete', function(event, CAL,  ajaxtype, data , data_arg){
483		SC = data_arg.shortcode;
484		if( SC.calendar_type == 'schedule'){
485			evosv_populate( CAL );
486		}
487	})
488	// view switching
489	.on('evo_vSW_clicked_before_ajax',function(event, O, CAL, DD, reload_cal_data){
490		if(!(O.hasClass('evosv'))) return;
491		var SC = CAL.evo_shortcode_data();
492
493		CAL.evo_update_cal_sc({F:'calendar_type', V: 'schedule'});
494		CAL.evo_update_cal_sc({F:'fixed_day', V: SC.fixed_day });
495
496	})
497	.on('evo_vSW_clicked',function(event, OBJ, CAL, DD, reload_cal_data){
498		if(!(OBJ.hasClass('evosv'))) return;
499
500		//if( reload_cal_data) return;
501				
502		var _reload_cal_data = false;
503		var SC = CAL.evo_shortcode_data();
504
505		DD.setUTCDate( 1 );
506
507		if( SC.focus_start_date_range != Math.floor(DD.getTime()/1000) )
508			_reload_cal_data = true;
509
510		CAL.evo_update_cal_sc({F:'focus_start_date_range',V: Math.floor(DD.getTime()/1000) });
511
512		DD.setUTCMonth( DD.getUTCMonth() + 1);
513		DD.setUTCDate( -1);
514
515		CAL.evo_update_cal_sc({F:'focus_end_date_range', 
516			V: Math.floor(DD.getTime()/1000) });
517
518
519		DD.setUTCDate( SC.fixed_day ); // adjust date to fixed date
520
521		CAL.evo_update_cal_sc({F:'calendar_type', V: 'schedule'});
522		CAL.evo_update_cal_sc({F:'fixed_day', V: SC.fixed_day });
523		
524		if( _reload_cal_data ){
525			$('body').trigger('evo_run_cal_ajax',[CAL.attr('id'),'none','filering']);
526		}else{
527			evosv_populate( CAL );
528		}
529
530		
531	})
532	// open events from schedule view
533		.on('click','.evosv_items',function(event, elm){
534			O = $(this);
535			CAL = O.closest('.ajde_evcal_calendar');
536			var e_cl = 'event_'+O.data('id');
537
538			const clicked_event_uxval = O.data('uxval');
539
540			// if event is set to slide down .. switch to lightbox
541			if( clicked_event_uxval == '1' ){
542				CAL.find('.'+e_cl).find('.desc_trig').data('ux_val', 3);
543			}
544
545			CAL.find('.'+e_cl).find('.desc_trig').trigger('click');
546		});
547
548	function evosv_populate(CAL){
549		var SC = CAL.evo_shortcode_data();
550		var cal_events = CAL.find('.eventon_list_event');
551		days_in_month = CAL.evo_day_in_month({M: SC.fixed_month, Y: SC.fixed_year});
552		time_format = CAL.evo_get_global({S1:'cal_def',S2:'wp_time_format'});
553		_txt = CAL.evo_get_txt({V:'no_events'});
554		_txt2 = CAL.evo_get_txt({V:'until'});
555		_txt3 = CAL.evo_get_txt({V:'from'});
556		_txt4 = CAL.evo_get_txt({V:'all_day'});
557
558		var html = "<div class='evosv_grid evoADDS'>";
559		CAL.find('#evcal_list').addClass('evo_hide');
560
561		var has_events = false;
562
563
564
565		// go through each day in month
566		for(var x=1; x<= days_in_month; x++){
567			var SU = parseInt(SC.focus_start_date_range) + ( (x-1) * 86400);
568			var EU = SU + 86399;
569			var DD = new Date( SU *1000);
570			var month_name = CAL.evo_get_dms_vals({ V: (DD.getUTCMonth() +1), type:'m3'});
571			var day_name = CAL.evo_get_dms_vals({ V:DD.getUTCDay(), type:'d3'});
572			var DN = '<b>'+DD.getUTCDate()+'</b> '+ month_name+' '+day_name;
573
574
575			// run through each event and get events in this date
576			var events = {};
577
578			cal_events.each(function(index, elm){
579				ED = $(elm).evo_cal_get_basic_eventdata();
580				if( !ED) return;
581
582
583				var inrange = CAL.evo_is_in_range({
584					'S': SU,	'E': EU,	'start': ED.event_start_unix,
585					'end':ED.event_end_unix
586				});
587				if(!inrange) return;
588
589				has_events = true;
590
591				start = ED.event_start_unix;
592				end = ED.event_end_unix;
593				m = moment.unix( start ).utc();
594				me = moment.unix( end ).utc();
595
596				var all_day = $(elm).find('a.desc_trig').hasClass('allday') ? true: false;
597
598				// get event time
599				// all day
600				if( all_day ){
601					ED['t'] = _txt4;
602				}else{
603					if( start <= SU ){
604						if( end >= EU) ED['t'] = _txt4;
605						if( end < EU ) ED['t'] = _txt2+' ' + me.format( time_format);		
606					}else if(start > SU){
607						if( end >= EU)  ED['t'] = _txt3+' '+ m.format( time_format);
608						if( end < EU ) ED['t'] = m.format( time_format) +' - '+ me.format( time_format);
609					}	
610				}
611						
612
613				// hide end time
614				if( ED.hide_et == 'y'){
615					ED['t'] = m.format( time_format);
616				}
617
618				events[index] = ED;
619			});			
620
621			if( events && Object.keys(events).length > 0){
622				html += "<div class='date_row'>";
623				$.each(events, function(index, item){	
624					//console.log(item);				
625					html += "<div class='row'>"+
626						"<div class='evosv_date'>"+DN+"</div>"+
627						"<div class='evosv_items' data-id='"+item.uID+"' data-uxval='"+ item.ux_val+"'>"+
628							"<div class='evosv_clr llxvl' style='background-color:"+item.hex_color+"'></div>"+
629							"<div class='evosv_time llxvl'>"+item.t+"</div>"+
630							"<div class='evosv_event llxvl'>"+ item.event_title+"</div>"+
631						"</div>"+
632					"</div>";
633				});
634				html+= "</div>";
635			}
636		}
637
638		// if no events
639		if( !has_events){
640			html += "<div class='date_row'><div class='row'>"+_txt+"</div></div>";
641		}
642
643		html += '</div>';
644
645		if( CAL.find('.evosv_grid').length > 0){
646			CAL.find('.evosv_grid').replaceWith( html);
647		}else{
648			ELM = CAL.find('#eventon_loadbar_section');
649			ELM.after( html );
650		}
651		
652	}
653
654
655// General AJAX trigger - added 3.1
656	$(document).on('click','.evo_trig_ajax',function(event ){
657		var ajax_data = {};
658		const obj = $(this);
659
660		ajax_data = obj.data();
661		$(document).data( 'evo_data', ajax_data );
662
663		$(document).trigger('evo_before_trig_ajax', [obj]);
664
665		var new_ajax_data = $(document).data( 'evo_data');
666		new_ajax_data['action'] = 'eventon_gen_trig_ajax';
667		new_ajax_data['nn'] = the_ajax_script.postnonce;
668
669		$.ajax({
670			beforeSend: function(){
671				$(document).trigger('evo_beforesend_trig_ajax', [obj, new_ajax_data]);
672			},
673			type: 'POST',url: ajax_url ,data: new_ajax_data,dataType:'json',
674			success:function(return_data){
675				$(document).trigger('evo_success_trig_ajax', [obj, new_ajax_data, return_data]);
676			},complete:function(){
677				$(document).trigger('evo_complete_trig_ajax', [obj, new_ajax_data]);
678			}
679		});
680
681	});
682
683// Initial load data via ajax
684	function init_load_cal_data(){
685
686		//return;
687
688		// check if calendars are present in the page
689			var run_initload = false;
690
691			if( $('body').find('.ajde_evcal_calendar').length > 0 ) run_initload = true;
692			if( $('body').find('.ajax_loading_cal').length > 0 ) run_initload = true;
693			if( $('body').find('.eventon_single_event').length > 0 ) run_initload = true;
694
695			if(run_initload == false) return false;
696
697
698			var data_arg = {action: 'eventon_init_load'};	
699
700			BODY = $('body');
701			BODY.trigger('evo_global_page_run');
702
703			data_arg['global'] = $('#evo_global_data').data('d');
704			data_arg['cals'] ={};			
705
706		// pass ajax loading calendar shortcodes
707			$('body').find('.ajax_loading_cal').each(function(){
708				CAL = $(this);
709				SC = CAL.find('.evo_cal_data').data('sc');
710
711				data_arg['cals'][ CAL.attr('id')] = {};
712				data_arg['cals'][ CAL.attr('id')]['sc'] = SC;
713			});
714		
715		$.ajax({
716			beforeSend: function(){},
717			type: 'POST',url: ajax_url ,data: data_arg,dataType:'json',
718			success:function(data){
719				$('#evo_global_data').data('d', data);
720
721				BUS = data;
722
723				// append html to calendars if present
724				if('cals' in data){
725					var time = 300;
726					$.each(data.cals, function(i,v){
727
728						setTimeout( function(){
729
730							CAL = BODY.find('#'+ i);
731
732							if(CAL.length === 0) return;
733
734							
735							if('html' in v){						
736								CAL.find('#evcal_list').html( v.html );
737								CAL.removeClass('ajax_loading_cal');
738								CAL.find('.evo_ajax_load_events').remove();
739
740								//CAL.evo_local_time();
741							}							
742
743							CAL.evo_calendar({
744								SC:v.sc,
745								json: v.json
746							});
747
748							$('body').trigger('evo_init_ajax_success_each_cal', [data, i, v, CAL]);
749
750						}, time);
751						time += 300;
752					});
753				}
754
755				$('body').trigger('evo_init_ajax_success', [data]);
756
757			},complete:function(data){					
758				// process all calendars in the page
759				$('body').find('.ajde_evcal_calendar').each(function(){
760					if($(this).hasClass('.ajax_loading_cal')) return;					
761					$(this).evo_calendar();
762				});
763
764				$('body').trigger('evo_init_ajax_completed', [data]);
765			}
766		});
767
768	}
769
770// ELEMENTS
771// tooltips
772	$('body').on('mouseover','.ajdeToolTip',function(event){
773		event.stopPropagation();
774		if($(this).hasClass('show')) return;
775
776		const t = $(this).data('d');
777		var p = $(this).position();
778		
779		var cor = getCoords(event.target);
780
781		$('.evo_tooltip_box').removeClass('show').removeClass('L').html(t);
782		var box_height = $('.evo_tooltip_box').height();
783		var box_width = $('.evo_tooltip_box').width();
784
785		$('.evo_tooltip_box').css({'top': (cor.top - 55 - box_height), 'left': ( cor.left + 5 ) })
786			.addClass('show');
787
788		// left align
789		if( $(this).hasClass('L')){
790			$('.evo_tooltip_box').css({'left': (cor.left - box_width - 15) }).addClass('L');			
791		}
792	})
793	.on('mouseout','.ajdeToolTip',function(){	
794		$('.evo_tooltip_box').removeClass('show');
795	});
796
797	function getCoords(elem) { // crossbrowser version
798	    var box = elem.getBoundingClientRect();
799	    //console.log(box);
800
801	    var body = document.body;
802	    var docEl = document.documentElement;
803
804	    var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
805	    var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
806
807	    var clientTop = docEl.clientTop || body.clientTop || 0;
808	    var clientLeft = docEl.clientLeft || body.clientLeft || 0;
809
810	    var top  = box.top +  scrollTop - clientTop;
811	    var left = box.left + scrollLeft - clientLeft;
812
813	    return { top: Math.round(top), left: Math.round(left) };
814	}
815	
816// Other
817	// LIGHTBOX		
818		// open lightbox @2.9
819		$('body').on('evo_open_lightbox',function(event, lb_class, content){
820			const LIGHTBOX = $('.evo_lightbox.'+lb_class).eq(0);
821
822			// if already open
823			if(LIGHTBOX.is("visible")===true) return false;
824
825			if( content != ''){
826				LIGHTBOX.find('.evo_lightbox_body').html( content );
827			}
828			$('body').trigger('evolightbox_show', [ lb_class ]);
829		});
830		// close popup
831			BODY.on('click','.evolbclose', function(){	
832				LIGHTBOX = 	$(this).closest('.evo_lightbox');
833				closing_lightbox( LIGHTBOX );				
834			});
835
836		// close with click outside popup box when pop is shown	
837			$(document).on('click', function(event) {
838				//event.stopPropagation(); 
839				//console.log($(event.target));
840			    if( 
841			    	$(event.target).hasClass('evo_content_inin')
842			    ){
843			    	closing_lightbox( $(event.target).closest('.evo_lightbox') );
844			       	//console.log('5');
845			    }
846			});		
847			function closing_lightbox( lightboxELM){
848				
849				if(! lightboxELM.hasClass('show')) return false;
850				Close = (lightboxELM.parent().find('.evo_lightbox.show').length == 1)? true: false;
851				lightboxELM.removeClass('show');
852
853				$('body').trigger('lightbox_before_event_closing', [lightboxELM]);
854
855				setTimeout( function(){ 
856					lightboxELM.find('.evo_lightbox_body').html('');
857					
858					if(Close){
859						$('body').removeClass('evo_overflow');
860						$('html').removeClass('evo_overflow');
861					}
862					
863					// trigger action to hook in at this stage
864						$('body').trigger('lightbox_event_closing', [lightboxELM]);
865				}, 100);
866			}
867
868		// when lightbox open triggered
869		$('body').on('evolightbox_show',function(event, lb_class){
870			$('.evo_lightboxes').show();
871			$('body').addClass('evo_overflow');
872			$('html').addClass('evo_overflow');
873
874			$('body').trigger('evolightbox_opened',[ lb_class ]);
875		});
876		
877	// OPENING event card -- USER INTREACTION and loading google maps
878		//event full description\		
879		$('body').on('click','.eventon_events_list .desc_trig', function(event){
880
881			var obj = $(this);					
882			
883			var attr = obj.closest('.evo_lightbox').attr('data-cal_id');
884			if(typeof attr !== typeof undefined && attr !== false){
885				var cal_id = attr;
886				var CAL = cal = $('#'+cal_id);
887			}else{
888				var CAL = cal = obj.closest('.ajde_evcal_calendar');
889			}
890
891			SC = CAL.evo_shortcode_data();
892
893			var evodata = cal.find('.evo-data');
894
895			click_sinev_box = (obj.closest('.eventon_single_event').length>0 && evodata.data('exturl')) ? true: false;
896			const event_id = obj.closest('.eventon_list_event').data('event_id');
897			var event_list = obj.closest('.eventon_events_list');
898						
899			
900			// whole calendar specific values
901			var cal_ux_val = SC.ux_val;
902						
903			// event specific values
904			var ux_val = obj.data('ux_val');
905			var exlk = obj.data('exlk');			
906			
907			// override overall calendar user intereaction OVER individual event UX
908			if(cal_ux_val!='' && cal_ux_val!== undefined && cal_ux_val!='0'){
909				ux_val = cal_ux_val;
910			}
911
912			//console.log(ux_val);
913
914			// open as lightbox
915			if(ux_val=='3' || ux_val == '3a'){
916				event.preventDefault();
917
918				repeat_interval = parseInt(obj.closest('.eventon_list_event').data('ri'));
919				repeat_interval = (repeat_interval)? repeat_interval: '0';
920
921				SC['repeat_interval'] = repeat_interval;
922				SC['ux_val'] = ux_val;
923				SC['evortl'] = event_list.hasClass('evortl')? 'yes':'no';
924				SC['event_id'] = parseInt(event_id);
925				SC['ajax_eventtop_show_content'] = true;
926
927				eventon_open_event_lightbox( SC , obj, CAL);
928				
929				return false;
930
931			// open in single events page 
932			}else if(ux_val=='4'){		
933				
934				var url = obj.attr('href');
935				
936				if( url =='' ||  url === undefined){
937
938					url = obj.parent().siblings('.evo_event_schema').find('a').attr('href');
939					window.open(url, '_self');		
940				}
941
942				if(obj.attr('target') != '_blank')	window.open(url, '_self');
943
944				return;
945
946			// open in single events page  in new window
947			}else if(ux_val=='4a'){
948				
949				if( obj.attr('href')!='' &&  obj.attr('href')!== undefined){
950					return;
951				}else{
952					var url = obj.parent().siblings('.evo_event_schema').find('a').attr('href');
953					window.open(url);
954					return false;
955				}
956
957			// open as external link
958			}else if(ux_val=='2'){
959				//var url = obj.parent().siblings('.evo_event_schema').find('a').attr('href');
960				var url = obj.attr('href');
961
962				// if the click is coming from single event box
963				if( click_sinev_box ){
964					event.preventDefault();
965					return false;
966				}
967
968				//console.log(url);
969				if(url !== undefined && url != ''){
970					if(obj.attr('target') == '_blank'){  
971						var win = window.open(url, '_blank');
972						win.focus();
973					}else{
974						window.open(url, '_self');
975					}	
976
977					event.preventDefault();				
978				}
979				return true;
980
981			// do not do anything
982			}else if(ux_val=='X'){
983				return false;
984			}else if(ux_val=='none'){
985				return false;
986			}else{
987				
988				// redirecting to external link
989				if(exlk=='1' && ux_val!='1'){
990					// if there is no href
991					if( obj.attr('href')!='' &&  obj.attr('href')!== undefined){
992						return;
993					}else{
994						var url = obj.siblings('.evo_event_schema').find('a').attr('href');
995						if(obj.attr('target') == '_blank'){  window.open(url);}else{ window.open(url, '_self');}
996
997						event.preventDefault();								
998						return false;
999					}
1000				// SLIDE DOWN eventcard
1001				}else{
1002
1003					var event_box = obj.closest('.eventon_list_event');			
1004					var click_item = event_box.find('.event_description');
1005
1006					if(click_item.hasClass('open')){
1007						event_box.removeClass('open');
1008						click_item.slideUp().removeClass('open');
1009					}else{
1010						// accordion
1011						if( SC.accord == 'yes'){
1012							cal.find('.eventon_list_event').removeClass('open');
1013							cal.find('.event_description').slideUp().removeClass('open');
1014						}
1015						event_box.addClass('open');
1016						click_item.slideDown().addClass('open');						
1017					}
1018					
1019					// This will make sure markers and gmaps run once and not multiples			
1020					if( obj.attr('data-gmstat')!= '1'){	
1021
1022						obj.attr({'data-gmstat':'1'});						
1023						obj.evoGenmaps({
1024							'fnt':2 ,
1025							'cal':cal,
1026						});
1027					}	
1028
1029					// trigger 
1030					if( obj.data('runjs')){
1031						$('body').trigger('evo_load_single_event_content',[ event_id, obj]);
1032					}	
1033
1034					$('body').trigger('evo_slidedown_eventcard_complete',[ event_id, obj]);			
1035
1036					return false;
1037				}
1038			}
1039		});	
1040
1041		// open event as lightbox
1042		function eventon_open_event_lightbox( data,obj, CAL){
1043			// set elements
1044			EVO_LIGHTBOX = $('.evo_lightbox.eventcard');
1045			LIGHTBOX_body = EVO_LIGHTBOX.find('.evo_lightbox_body');
1046
1047			// resets
1048				EVO_LIGHTBOX.find('.evo_pop_body').show();
1049				fullheight_img_reset();
1050				LIGHTBOX_body.html('');
1051
1052			// RTL
1053				if( data.evortl =='yes'){	
1054					EVO_LIGHTBOX.find('.evo_popin').addClass('evortl');	
1055					EVO_LIGHTBOX.addClass('evortl');
1056				}
1057
1058				
1059			// AJAX via lightbox
1060			if(data.ux_val == '3a'){
1061
1062				var new_content = '';
1063				new_content += '<div class="evo_cardlb" style="padding:10px 10px 0 10px">';
1064				new_content += '<div style="margin-bottom:20px; width:100%; height:200px" class="evo_preloading"></div>';
1065				const box = '<div style="display:flex;justify-content: space-between;margin-bottom:10px"><div style="width:40px;height:40px; margin-right:20px" class="evo_preloading"></div> <div style="flex:1 0 auto"> <div class="evo_preloading" style="width:70%; height:20px; margin-bottom:10px"></div><div class="evo_preloading" style="width:100%; height:80px; margin-bottom:10px"></div>  </div> </div>';
1066				new_content += box + box + box;
1067				new_content += '</div>';
1068
1069				// eventtop initial content
1070				if( data.ajax_eventtop_show_content){
1071					LIGHTBOX_body.append('<div class="evopop_top">'+ obj.html() +'</div>');
1072				}else{
1073					LIGHTBOX_body.append('<div class="evopop_top"></div>')
1074				}
1075				
1076				LIGHTBOX_body.append( new_content );
1077
1078				LIGHTBOX_body.attr('class','evo_lightbox_body eventon_list_event evo_pop_body evcal_eventcard event_'+data.event_id +'_'+ data.repeat_interval);
1079
1080
1081				var data_arg = {};
1082				data_arg['event_id'] = data.event_id;
1083				data_arg['ri'] = data.repeat_interval;
1084				data_arg['SC'] = data;
1085				data_arg['action'] = 'eventon_load_single_eventcard_content';
1086
1087				
1088				//reset view to match
1089					if( data_arg.SC.tile_style == '2') data_arg.SC.eventtop_style = '0';
1090					data_arg.SC.tile_style = '0';
1091					data_arg.SC.tile_bg = '0';
1092					data_arg.SC.tiles = 'no';
1093
1094
1095				var ra = true;
1096
1097				// load event content via ajax
1098				if(ra){
1099					$.ajax({
1100						beforeSend: function(){},
1101						type: 'POST',
1102						url:the_ajax_script.ajaxurl,
1103						data: data_arg,
1104						dataType:'json',
1105						success:function(data){
1106
1107							if(data. status == 'good'){
1108								LIGHTBOX_body.html( data.html );
1109
1110								LIGHTBOX_body.find('.evo_eventtop')
1111									.evoGenmaps({ 
1112										'fnt':2 ,
1113										'SC': data,
1114										'cal': CAL,											
1115									});
1116									
1117								fullheight_img_reset(); 
1118
1119								// trigger 
1120								if( obj.data('runjs'))	$('body').trigger('evo_load_single_event_content',[ data.event_id, obj]);
1121
1122								LIGHTBOX_body.evo_local_time();
1123								
1124							}
1125
1126						},complete:function(){
1127							$('body').trigger('evo_single_event_load_end');
1128						}
1129					});
1130				}
1131
1132			}else{
1133
1134				var content = obj.closest('.eventon_list_event').find('.event_description').html();
1135				var _content = $(content).not('.evcal_close');
1136
1137				const cancel_class = ( obj.hasClass('cancel_event')) ? ' cancel_event':'';
1138				
1139				LIGHTBOX_body.append('<div class="evopop_top">'+ obj.html() +'</div>').append(_content);
1140				LIGHTBOX_body.attr('class','evo_lightbox_body eventon_list_event evo_pop_body evcal_eventcard event_'+data.event_id +'_'+ data.repeat_interval + cancel_class);
1141
1142				LIGHTBOX_body.find('.evopop_top').attr('data-text', obj.data('text') );
1143				LIGHTBOX_body.find('.evopop_top')
1144					.evoGenmaps({	'fnt':2 ,'cal':CAL });
1145			}
1146			
1147			
1148			
1149			EVO_LIGHTBOX.addClass('show');
1150			$('body').trigger('evolightbox_show');
1151			
1152			fullheight_img_reset();    // added second reset
1153
1154			// update border color and eventtop color
1155				bgcolor = $('.evo_pop_body').find('.evcal_cblock').data('bgcolor');
1156
1157				// if tiles and eventtop style set to clean
1158				var show_lightbox_color = data.tiles == 'yes' && ( data.eventtop_style == '0' || data.eventtop_style == '4') ? false: true;
1159				
1160				if( (CAL && CAL.hasClass('color') && show_lightbox_color) ||
1161					(!CAL && show_lightbox_color)
1162
1163				){
1164					LIGHTBOX_body.addClass('color');
1165					LIGHTBOX_body.find('.evopop_top').css({'background-color':bgcolor});
1166				}else{
1167					LIGHTBOX_body.find('.evopop_top').css({'border-left':'3px solid '+bgcolor});
1168				}
1169
1170			// trigger 
1171			if( obj.data('runjs')){
1172				$('body').trigger('evo_load_single_event_content',[ data.event_id, obj]);
1173			}
1174			
1175			// countdown
1176			EVO_LIGHTBOX.find('.evo_countdowner').each(function(){
1177				obj.removeClass('evo_cd_on');
1178				obj.evo_countdown();
1179			});
1180
1181			$('body').trigger('evolightbox_end');
1182		}	
1183
1184	// load eventon event anywhere via lightbox ajax
1185		$('body').on('click','.eventon_anywhere.evoajax', function(event){
1186			var obj = $(this);
1187			var data = obj.data('sc');
1188
1189			if( data.ev_uxval == '4') return;
1190
1191			event.preventDefault();
1192
1193			data['evortl'] = 'no';
1194			data['event_id'] = data.id;
1195			data['ux_val'] = '3a';
1196			data['ajax_eventtop_show_content'] = false;
1197
1198			console.log(data);
1199			eventon_open_event_lightbox( data, obj, false);
1200		});
1201
1202		// call to run google maps on load
1203			function init_run_gmap_openevc(delay){
1204				$('.ajde_evcal_calendar').each(function(){
1205			
1206					var CAL = $(this);
1207					var SC = CAL.evo_shortcode_data();
1208
1209					if( SC === undefined || SC === null) return;
1210
1211					if( typeof SC !== 'object' ){
1212						SC = JSON.parse(SC);
1213					}
1214
1215					if( 'evc_open' in SC && SC.evc_open =='yes'){
1216
1217						$(this).find('.desc_trig').each(function(){
1218							if(delay!='' && delay !== undefined){							
1219								$(this).evoGenmaps({'fnt':2, 'cal': CAL, 'delay':delay});
1220							}else{
1221								$(this).evoGenmaps({'fnt':2,'cal': CAL });							
1222							}
1223						});
1224					}
1225				});
1226			}
1227	
1228	// Calendar Interaction
1229		// event bubbles
1230		$('.ajde_evcal_calendar.bub').on('mouseover','.eventon_list_event', function(){
1231			O = $(this);
1232			LIST = O.closest('.eventon_events_list');
1233			title = O.find('.evoet_dayblock').data('bub');
1234
1235			p = O.position();
1236
1237			LIST.append('<span class="evo_bub_box" style="">'+ title +"</span>");
1238			B = LIST.find('.evo_bub_box');
1239
1240			l = p.left;
1241			t = p.top- B.height() -30;
1242
1243			// adjust bubble to left if event on right edge
1244			LM = LIST.width();
1245			tl = p.left + B.width() + O.width();
1246			if(   tl > LM){
1247				l = l - B.width() +O.width()-20;
1248			}
1249
1250			B.css({'top':t, 'left':l});
1251
1252			LIST.find('.evo_bub_box').addClass('show');
1253		}).on('mouseout',function(){
1254			B = $(this).find('.evo_bub_box').remove();
1255		});
1256
1257	// Click on eventtop items
1258		$('body').on('click','.evocmd_button', function(event){
1259			event.preventDefault();
1260			event.stopPropagation();
1261
1262			href = $(this).data('href');			
1263			if( $(this).data('target')=='yes'){
1264				window.open(href,'_blank');
1265			}else{
1266				window.location = href;
1267			}
1268
1269		});
1270
1271	// GO TO TODAY
1272	// @+ 2.3 @up 2.8
1273		$('body').on('click','.evo-gototoday-btn', function(){
1274			var obj = $(this);
1275			CAL = obj.closest('.ajde_evcal_calendar');			
1276			var calid = CAL.attr('id');
1277
1278			CAL.evo_update_cal_sc({F:'fixed_month', V: obj.data('mo')});
1279			CAL.evo_update_cal_sc({F:'fixed_year', V: obj.data('yr')});
1280			
1281			run_cal_ajax( calid,'none','today');
1282			obj.fadeOut();
1283		});
1284
1285		$('body').on('evo_main_ajax_before', function(event, CAL, ajaxtype){
1286			if(ajaxtype == 'switchmonth')	CAL.find('.evo-gototoday-btn').fadeIn();
1287		});
1288		$('body').on('evo_main_ajax_complete', function(event, CAL,ajaxtype, D , data_arg){
1289			// if focused month and year are same as current month and year hide the current month button
1290			var N = moment().utc();
1291			SC = CAL.evo_shortcode_data();
1292
1293			var SU = parseInt( SC.focus_start_date_range);				
1294			var M = moment.unix(SU).utc();	
1295
1296			if( N.format('YYYY M') == M.format('YYYY M')){				
1297				CAL.find('.evo-gototoday-btn').fadeOut();
1298			}
1299
1300			// load countdown timers
1301			BODY.find('.evo_countdowner').each(function(){
1302				$(this).evo_countdown();
1303			});
1304			
1305		});
1306
1307	// MONTH jumper
1308		$('.ajde_evcal_calendar').on('click','.evo-jumper-btn', function(){
1309			$(this).parent().siblings().find('.evo_j_container').slideToggle();
1310		});
1311
1312		// select a new time from jumper
1313		$('.evo_j_dates').on('click','a',function(){
1314			var val = $(this).attr('data-val'),
1315				type = $(this).parent().parent().attr('data-val'),
1316				CAL = $(this).closest('.ajde_evcal_calendar');
1317				SC = CAL.evo_shortcode_data();
1318
1319			if(type=='m'){ // change month
1320				CAL.evo_update_cal_sc({F:'fixed_month', V: val });
1321			}else{
1322				CAL.evo_update_cal_sc({F:'fixed_year', V: val });
1323			}
1324
1325			run_cal_ajax( CAL.attr('id') ,'none','jumper');
1326			
1327			// hide month jumper if not set to leave expanded
1328			if(SC.expj =='no')	container.delay(2000).slideUp();
1329		});
1330
1331	// RESET general calendar
1332		// @U 2.8.9
1333		function cal_resets(calOBJ){
1334			calargs = $(calOBJ).find('.cal_arguments');
1335			calargs.attr('data-show_limit_paged', 1 );
1336
1337			calOBJ.evo_update_cal_sc({
1338				F:'show_limit_paged',V:'1'
1339			});
1340		}
1341				
1342	// change IDs for map section for eventon widgets
1343		if( $('.ajde_evcal_calendar').hasClass('evcal_widget')){
1344			cal.find('.evcal_gmaps').each(function(){
1345				var gmap_id = obj.attr('id');
1346				var new_gmal_id =gmap_id+'_widget'; 
1347				obj.attr({'id':new_gmal_id})
1348			});
1349		}
1350	
1351	// Tab view switcher
1352		$('body').find('.evo_tab_container').each(function(){
1353			$(this).find('.evo_tab_section').each(function(){
1354				if(!$(this).hasClass('visible')){
1355					$(this).addClass('hidden');
1356				}
1357			});
1358		});
1359		$('body').on('click','.evo_tab',function(){
1360			tab = $(this).data('tab');
1361			tabsection = $(this).closest('.evo_tab_view').find('.evo_tab_container');
1362			tabsection.find('.evo_tab_section').addClass('hidden').removeClass('visible');
1363			tabsection.find('.'+tab).addClass('visible').removeClass('hidden');
1364
1365			$(this).parent().find('.evo_tab').removeClass('selected');
1366			$(this).addClass('selected');
1367
1368			$('body').trigger('evo_tabs_newtab_selected',[ $(this)]);
1369		});
1370
1371	// layout view changer - legacy
1372		if($('body').find('.evo_layout_changer').length>0){
1373			// menu button focus adjust
1374			$('body').find('.evo_layout_changer').each(function(item){
1375				if($(this).parent().hasClass('boxy')){
1376					$(this).find('.fa-th-large').addClass('on');
1377				}else{
1378					$(this).find('.fa-reorder').addClass('on');
1379				}
1380			});
1381
1382			// interaction
1383			$('.evo_layout_changer').on('click','i',function(){
1384				const CAL = $(this).closest('.ajde_evcal_calendar');
1385				TYPE = $(this).data('type');
1386				$(this).parent().find('i').removeClass('on');
1387				$(this).addClass('on');
1388
1389				//console.log(TYPE);
1390				
1391				if(TYPE=='row'){
1392					CAL.attr('class','ajde_evcal_calendar');
1393					// set tile colors
1394					CAL.find('.eventon_list_event').each(function(){
1395						$(this).find('.desc_trig').css('background-color',  '');
1396						$(this).find('.desc_trig_outter').css('background-color',  '');
1397					});
1398				}else if(TYPE =='bar'){
1399					CAL.attr('class','ajde_evcal_calendar  box_2 sev cev');
1400					
1401					// set tile colors
1402					CAL.find('.eventon_list_event').each(function(){
1403						const color = $(this).data('colr');
1404						$(this).find('.desc_trig').css('background-color',  color);
1405					});
1406				}else{
1407
1408					// set tile colors
1409					CAL.find('.eventon_list_event').each(function(){
1410						const color = $(this).data('colr');
1411						$(this).find('.desc_trig_outter').css('background-color',  color);
1412					});
1413
1414					CAL.attr('class','ajde_evcal_calendar boxy boxstyle0 box_2');
1415				}				
1416			});
1417		}
1418	
1419	// v4.0 view switcher
1420		$('body').on('click', '.evo_cal_view_switcher_cur',function(){
1421					$(this).parent().toggleClass('SH');
1422			})
1423			.on('click', '.evo_vSW',function(){
1424				O = $(this);
1425				var DATA = O.data('d');
1426				if(O.hasClass('focusX')) return;
1427								
1428				CAL = O.closest('.ajde_evcal_calendar');
1429
1430				// remove other additions from other views
1431				CAL.find('.evoADDS').fadeOut().delay(200).queue(function(){
1432					$(this).remove();
1433				});
1434
1435				var SC = CAL.evo_shortcode_data();
1436				var reload_cal_data = false;
1437				
1438				// Create date object
1439					var DD = new Date(SC.fixed_year,SC.fixed_month -1 , SC.fixed_day, 0,0,0 );
1440					DD.setUTCHours(0);
1441					DD.setUTCFullYear( SC.fixed_year );
1442					DD.setUTCMonth( SC.fixed_month -1 );
1443					DD.setUTCDate( SC.fixed_day );
1444
1445				// switch to normal
1446					O.siblings('.evo_vSW').removeClass('focusX');					
1447					O.addClass('focusX');
1448					CAL.find('.evo_cal_view_switcher_cur').html( O.html() );
1449					O.closest('.evo_cal_view_switcher').removeClass('SH');
1450
1451				// calendar class toggling
1452					O.siblings('.evo_vSW').each(function(){
1453						var _d = $(this).data('d');
1454						if( _d && 'c' in _d )	CAL.removeClass( _d['c'] ); // remove other cls
1455					});
1456					if( DATA && 'c' in DATA)	CAL.addClass( DATA.c );
1457
1458				$('body').trigger('evo_vSW_clicked_before_ajax', [ O, CAL, DD, reload_cal_data]);
1459				
1460				// switching to calendars that need 1 month of events
1461				if( !(O.hasClass('evowv')) ){
1462
1463					DD.setUTCDate( 1 );
1464
1465					if( SC.focus_start_date_range != Math.floor(DD.getTime()/1000) )
1466						reload_cal_data = true;
1467
1468					CAL.evo_update_cal_sc({F:'focus_start_date_range',V: Math.floor(DD.getTime()/1000) });
1469
1470					DD.setUTCMonth( DD.getUTCMonth() + 1);
1471					DD.setUTCDate( -1);
1472
1473					CAL.evo_update_cal_sc({F:'focus_end_date_range', 
1474						V: Math.floor(DD.getTime()/1000) });
1475
1476					CAL.evo_update_cal_sc({F:'calendar_type', V: 'default'});
1477
1478					// treating events list based on dif preferences
1479					// vals el_visibility = hide_events, show_events
1480					if( 'el_visibility' in DATA){
1481						el_visibility = DATA.el_visibility;
1482
1483						if( el_visibility =='show_events') CAL.find('.eventon_list_event').show();
1484						if( el_visibility =='hide_events') CAL.find('.eventon_list_event').hide();
1485						if( el_visibility =='hide_list') CAL.find('#evcal_list').addClass('evo_hide');
1486						if( el_visibility =='show_all'){
1487							CAL.find('#evcal_list').removeClass('evo_hide');
1488							CAL.find('.eventon_list_event').show();
1489						} 
1490					}
1491
1492					
1493					//CAL.find('.eventon_list_event').show();
1494
1495					// run ajax to load new events in the range
1496					if( reload_cal_data ){
1497						$('body').trigger('evo_run_cal_ajax',[CAL.attr('id'),'none','filering']);
1498					}
1499				}
1500
1501							
1502				$('body').trigger('evo_vSW_clicked', [ O, CAL, DD, reload_cal_data]);
1503
1504			});
1505	
1506	// SORTING & FILTERING
1507		// display sort section
1508		$('.evo-filter-btn').click(function(){
1509			CAL = $(this).closest('.ajde_evcal_calendar');
1510			line = CAL.find('.eventon_sorting_section');
1511			if(line.is(':visible')){
1512				line.hide();
1513				$(this).removeClass('show');
1514			}else{
1515				line.show();
1516				$(this).addClass('show');
1517			}
1518			// hide sort menu
1519			CAL.find('.eventon_sort_line').hide();
1520		});	
1521		
1522		// SORTing
1523			$('.evo-sort-btn').click(function(){
1524				line = $(this).find('.eventon_sort_line');
1525				if(line.is(':visible')){
1526					line.hide();
1527					$(this).removeClass('show');
1528				}else{
1529					line.show();
1530					$(this).addClass('show');
1531				}
1532			});
1533		
1534			// update calendar based on the sorting selection
1535				$('.eventon_sort_line').on('click','p',function(){
1536					O = $(this);
1537					var CAL = O.closest('.ajde_evcal_calendar');
1538					var sort_by = O.data('val');
1539					
1540					// update new values everywhere
1541					CAL.evo_update_cal_sc({F:'sort_by',V:sort_by});
1542
1543					O.parent().find('p').removeClass('select');
1544					O.addClass('select');	
1545
1546					run_cal_ajax(CAL.attr('id'),'none','sorting');						
1547				});		
1548		
1549		// filtering section open and close menu
1550			$('.filtering_set_val').click(function(){
1551				// close sorting
1552					sortSelect = $(this).closest('.eventon_sorting_section').find('.evo_srt_options');
1553					if(sortSelect.is(':visible') == true) sortSelect.fadeToggle();
1554
1555				var obj = $(this);
1556				var current_Drop = obj.siblings('.eventon_filter_dropdown');
1557				var current_drop_pare = obj.closest('.eventon_filter');
1558
1559				current_drop_pare.siblings('.eventon_filter').find('.eventon_filter_dropdown').each(function(){
1560					if($(this).is(':visible')== true ){
1561						$(this).hide();
1562						$(this).siblings('p').removeClass('show');
1563					}				
1564				});
1565
1566				if(current_Drop.is(':visible')== true){
1567					obj.siblings('.eventon_filter_dropdown').fadeOut('fast');	
1568					obj.removeClass('show');	
1569				}else{
1570					obj.siblings('.eventon_filter_dropdown').fadeIn('fast');
1571					obj.addClass('show');
1572				}			
1573			});	
1574		
1575		// selection on filter dropdown list
1576			$('.eventon_filter_dropdown').on('click','p',function(){
1577				var new_filter_val = $(this).data('filter_val'),
1578					O = $(this),
1579					filter_section = $(this).closest('.eventon_filter_line');
1580				var filter = $(this).closest('.eventon_filter');
1581				var filter_current_set_val = filter.data('filter_val');
1582				var select_filter_type = filter_section.hasClass('selecttype')? true:false;
1583				FILTER_DROPDOWN = $(this).parent();
1584				CAL = $(this).closest('.ajde_evcal_calendar');	
1585
1586				//console.log(new_filter_val);
1587
1588
1589				// for filter values with checkboxes
1590				if(select_filter_type){	
1591					val = '';
1592
1593					// NOT all
1594					if( new_filter_val != 'all'){
1595						O.parent().find('p.all').removeClass('select');
1596						O.toggleClass('select');	
1597
1598						var unselect_count = 0;
1599						O.parent().find('p').each(function(){
1600							if( $(this).hasClass('select')){
1601								val += $(this).data('filter_val')+',';
1602							}else{
1603								if(!$(this).hasClass('all')) unselect_count++;
1604							}
1605						});	
1606
1607						// all selected
1608						if(unselect_count == 0){
1609							O.parent().find('p.all').addClass('select');
1610							val = 'all';
1611						}	
1612
1613						// remove comma at the end
1614						val = ( val.slice(-1) == ',')? val.slice(0,-1): val;
1615
1616						// if all field is not visible; nothing selected = all
1617						if(val == '' && O.parent().find('p.all').length == 0) val='all';
1618
1619					// == all
1620					}else{ 
1621						if( O.hasClass('select')){
1622							O.parent().find('p').removeClass('select');
1623						}else{
1624							O.parent().find('p').addClass('select');
1625							val = 'all';
1626						}						
1627					}
1628					
1629					filter.data('filter_val',val); // v 2.7.4
1630				
1631				// regular selecting
1632				}else{					
1633					if( new_filter_val == 'all'){
1634						O.parent().find('p').addClass('select');
1635					}else{
1636						O.parent().find('p').removeClass('select');
1637						O.addClass('select');
1638					}
1639				}
1640
1641				// if select filter type 
1642				if(select_filter_type) return;
1643
1644				
1645				// For non checkbox select options
1646				if(filter_current_set_val == new_filter_val){
1647					$(this).parent().fadeOut();
1648				}else{					
1649					cal_resets( CAL );
1650							
1651					// make changes					
1652					filter.data('filter_val', new_filter_val);
1653
1654					CAL.evo_update_sc_from_filters();					
1655
1656					run_cal_ajax( CAL.attr('id') ,'none','filering');
1657										
1658					// reset the new values				
1659					var new_filter_name = $(this).html();
1660					
1661					O.parent().fadeOut();
1662					O.parent().siblings('.filtering_set_val').removeClass('show');
1663				}
1664			});
1665			
1666			// apply filters via button to the calendar
1667				$('.eventon_filter_dropdown').on('change','input',function(event){
1668					FILTER = $(this).closest('.eventon_filter');
1669
1670					val = '';
1671					FILTER.find('input').each(function(){
1672						val = ($(this).is(':checked'))? val + $(this).data('filter_val') +',': val;
1673					});
1674					val = (val=='')? '':val; // v2.5.2
1675					FILTER.data('filter_val',val); // v 2.7.4
1676				});
1677			// apply filters
1678				$('body').on('click','.evo_filter_submit',function(){
1679					// fadeout any open filter dropdowns
1680						$(this).closest('.eventon_filter_line').find('.eventon_filter_dropdown').fadeOut();
1681						$(this).closest('.eventon_filter_line').find('.filtering_set_val').removeClass('show');
1682
1683					CAL = $(this).closest('.ajde_evcal_calendar');	
1684					cal_resets( CAL);
1685
1686					CAL.evo_update_sc_from_filters();	// update shortcode from filters
1687					
1688					run_cal_ajax(CAL.attr('id'),'none','filering');
1689				});
1690		
1691	// CAL BODY Listeners
1692		$('body')
1693			// Show more events on list
1694				.on('click','.evoShow_more_events',  function(){
1695					CAL = $(this).closest('.ajde_evcal_calendar');
1696					SC = CAL.evo_shortcode_data();
1697
1698					OBJ = $(this);
1699
1700					// redirect to an external link 
1701						if(SC.show_limit_redir !== ''){
1702							window.location = SC.show_limit_redir;	return false;
1703						}
1704
1705					// ajax pagination
1706					if( SC.show_limit_ajax =='yes'){
1707						CURRENT_PAGED = parseInt(SC.show_limit_paged);				
1708						CAL.evo_update_cal_sc({F:'show_limit_paged', V: CURRENT_PAGED+1});
1709						run_cal_ajax( CAL.attr('id'), 'none','paged');
1710
1711					}else{
1712						var event_count = parseInt( SC.event_count );
1713						
1714						var eventList = OBJ.parent();
1715						var allEvents = eventList.find('.eventon_list_event').length;
1716
1717						var currentShowing = eventList.find('.eventon_list_event:visible').length;
1718
1719						for(x=1; x<=event_count ; x++ ){
1720							var inde = currentShowing+x-1;
1721							eventList.find('.eventon_list_event:eq('+ inde+')').slideDown();
1722						}
1723
1724						// hide view more button
1725						if(allEvents > currentShowing && allEvents<=  (currentShowing+event_count)){
1726							$(this).fadeOut();
1727						}
1728					}		
1729
1730				})
1731			// MONTH switch
1732				.on('click','.evcal_btn_prev', function(){
1733					var cal_id = $(this).closest('.ajde_evcal_calendar').attr('id');
1734					var direction = $(this).closest('.ajde_evcal_calendar').hasClass('evortl')? 'next': 'prev';
1735					run_cal_ajax(cal_id, direction ,'switchmonth');
1736				})
1737				.on('click','.evcal_btn_next',function(){					
1738					var cal_id = $(this).closest('.ajde_evcal_calendar').attr('id');			
1739					var direction = $(this).closest('.ajde_evcal_calendar').hasClass('evortl')? 'prev': 'next';
1740					run_cal_ajax(cal_id, direction ,'switchmonth');
1741				})
1742
1743			// JUMPER switch
1744				.on('calendar_month_changed',function(event, CAL){
1745					SC = CAL.evo_shortcode_data();
1746
1747					var O = CAL.find('.evo_j_container');
1748					O.find('.evo_j_months a').removeClass('set');
1749					O.find('.evo_j_months a[data-val="'+ SC.fixed_month +'"]').addClass('set');
1750
1751					O.find('.evo_j_years a').removeClass('set');
1752					O.find('.evo_j_years a[data-val="'+ SC.fixed_year +'"]').addClass('set');
1753
1754					// show go to today 
1755					B = CAL.find('.evo-gototoday-btn');
1756					if( SC.fixed_month != B.data('mo') || SC.fixed_year != B.data('yr')){
1757						B.show();
1758					}
1759				})
1760			
1761			// show more/less event details
1762				.on('click','.evobtn_details_show_more',function(){		
1763					control_more_less( $(this));	
1764				})
1765			// refresh now calendar
1766				.on('runajax_refresh_now_cal',function(e, OBJ, nonce){
1767
1768					const section = OBJ.closest('.evo_eventon_live_now_section');
1769					const CAL = section.find('.ajde_evcal_calendar').eq(0);
1770
1771					var dataA = {
1772						action: 'eventon_refresh_now_cal',
1773						nonce: nonce,
1774						other: OBJ.data(),
1775						SC: CAL.evo_shortcode_data()
1776					};
1777
1778					
1779
1780					$.ajax({
1781						beforeSend: function(){
1782							section.addClass('evoloading');
1783						},
1784						type: 'POST',url:ajax_url,data: dataA,dataType:'json',
1785						success:function(data){
1786							if( data.status == 'good'){
1787								section.html( data.html);
1788
1789								$('body').trigger('evo_refresh_designated_elm',[ OBJ, 'evo_vir_data']);
1790							}
1791
1792						},complete:function(data){
1793							section.removeClass('evoloading');
1794
1795							BODY.find('.evo_countdowner').each(function(){
1796								$(this).evo_countdown();
1797							});
1798						}
1799					});
1800				})
1801
1802			// refresh event top
1803				.on('runajax_refresh_eventtop',function(e, OBJ, nonce){
1804
1805				});
1806		
1807
1808	// PRIMARY hook to get content	
1809		// MAIN AJAC for calendar events v2.8
1810		function run_cal_ajax( cal_id, direction, ajaxtype){
1811			
1812			// identify the calendar and its elements.
1813			var CAL = ev_cal = $('#'+cal_id); 
1814
1815			// check if ajax post content should run for this calendar or not			
1816			if(CAL.attr('data-runajax')!='0'){
1817
1818				// category filtering for the calendar
1819				var cat = CAL.find('.evcal_sort').attr('cat');
1820
1821				// reset paged values for switching months
1822				if(ajaxtype=='switchmonth'){
1823					CAL.find('.cal_arguments').attr('data-show_limit_paged',1);
1824					CAL.evo_update_cal_sc({F:'show_limit_paged', V: '1'});
1825				}	
1826
1827				SC = CAL.evo_shortcode_data();
1828
1829				$('body').trigger('evo_main_ajax_before', [CAL, ajaxtype, direction, SC]);		
1830
1831				var data_arg = {
1832					action: 		'the_ajax_hook',
1833					direction: 		direction,
1834					shortcode: 		SC,
1835					ajaxtype: 		ajaxtype,
1836				};	
1837
1838				EVENTS_LIST = ev_cal.find('.eventon_events_list');
1839
1840				$.ajax({
1841					beforeSend: function(){
1842						ev_cal.addClass('evo_loading');
1843						if(ajaxtype != 'paged')	EVENTS_LIST.slideUp('fast');
1844
1845						if(ajaxtype == 'paged'){
1846							txt = EVENTS_LIST.find('.evoShow_more_events').html();
1847							EVENTS_LIST.find('.evoShow_more_events').html('. . .').data('txt',txt);
1848						}
1849						ev_cal.evo_loader_animation();					
1850					},
1851					type: 'POST',url:ajax_url,data: data_arg,dataType:'json',
1852					success:function(data){
1853						if(!data) return false;
1854						if(ajaxtype == 'paged'){	
1855							EVENTS_LIST.find('.evoShow_more_events').remove();
1856							EVENTS_LIST.find('.clear').remove();
1857
1858
1859							EVENTS_LIST.append( data.html + "<div class='clear'></div>");
1860
1861							// hide show more events if all events loaded
1862							var events_in_list = EVENTS_LIST.find('.eventon_list_event').length;
1863							if( 'total_events' in data && data.total_events == events_in_list){
1864								EVENTS_LIST.find('.evoShow_more_events').hide();
1865							}	
1866
1867							// for month lists duplicate headers // @+2.8.1
1868							var T = {};
1869							EVENTS_LIST.find('.evcal_month_line').each(function(){
1870								d = $(this).data('d');
1871								if( T[d]) 
1872									$(this).remove();
1873								else
1874									T[d] = true;
1875							});
1876
1877							var T = {};
1878							EVENTS_LIST.find('.sep_month_events').each(function(){
1879								d = $(this).data('d');
1880								if( T[d]){
1881									var H = $(this).html();
1882									EVENTS_LIST.find('.sep_month_events[data-d="'+d+'"]').append( H );
1883									$(this).remove();
1884								}else{T[d] = true;}
1885							});
1886							
1887						}else{
1888							EVENTS_LIST.html(data.html);
1889						}
1890						
1891						// update calednar month title
1892						animate_month_switch(data.cal_month_title, ev_cal.find('.evo_month_title'));
1893							
1894						// update calendar shortcode values after ajax
1895						ev_cal.evo_update_all_cal_sc({SC: data.SC});
1896
1897						// update events list to calendar footer data
1898						ev_cal.find('.evo_cal_events').data('events', data.json);
1899
1900						$('body').trigger('calendar_month_changed',[CAL]);
1901						
1902						$('body').trigger('evo_main_ajax_success', [CAL, ajaxtype, data, data_arg]);
1903															
1904					},complete:function(data){
1905						ev_cal.evo_loader_animation({direction:'end'});
1906
1907						// show events list events if not set to hide on load
1908						if(! EVENTS_LIST.hasClass('evo_hide')) EVENTS_LIST.delay(300).slideDown('slow');
1909						
1910						ev_cal.evoGenmaps({'delay':400});
1911						init_run_gmap_openevc(600);
1912						fullheight_img_reset(cal_id);
1913
1914						// pluggable
1915						$('body').trigger('evo_main_ajax_complete', [CAL, ajaxtype, data.responseJSON , data_arg]);
1916						ev_cal.removeClass('evo_loading');
1917					}
1918				});
1919			}			
1920		}
1921
1922		$('body').on('evo_run_cal_ajax',function(event,cal_id, direction, ajaxtype){
1923			run_cal_ajax( cal_id, direction, ajaxtype);
1924		});
1925
1926		// deprecated bridge function for sortby value 
1927		function ajax_post_content(sortby, cal_id, direction, ajaxtype){
1928			run_cal_ajax( cal_id, direction, ajaxtype);
1929		}
1930
1931	// subtle animation when switching months
1932		function animate_month_switch(new_data, title_element){			
1933			var current_text = title_element.html();
1934			var CAL = title_element.closest('.ajde_evcal_calendar');
1935
1936			// for RTL not do the animation
1937			if(CAL.hasClass('evortl')){
1938				title_element.html(new_data);
1939				return;
1940			}
1941
1942			var hei = title_element.height();
1943			var wid= title_element.width();
1944			
1945			
1946			title_element.html("<span style='position:absolute; width:"+wid+"; height:"+hei+" ;'>"+current_text+"</span><span style='position:absolute; display:none;'>"+new_data+"</span>").width(wid);
1947
1948			var LC_w = title_element.find('span:last-child').width()+5;
1949						
1950			title_element.find('span:first-child').fadeOut(800); 
1951			title_element.find('span:last-child').fadeIn(800, function(){
1952				title_element.html(new_data);
1953			});
1954			title_element.animate({width: LC_w},800);
1955		}
1956	
1957	// actual animation/function for more/less button
1958		function control_more_less(obj){
1959			var content = obj.attr('content');
1960			var current_text = obj.find('.ev_more_text').html();
1961			var changeTo_text = obj.find('.ev_more_text').attr('data-txt');
1962			const cell = obj.closest('.evcal_evdata_cell');
1963
1964				
1965			// show more
1966			if(content =='less'){			
1967				
1968				obj.closest('.evcal_evdata_cell').removeClass('shorter_desc');
1969						
1970
1971				obj.attr({'content':'more'});
1972				obj.find('.ev_more_arrow').removeClass('ard');
1973				obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text);
1974				
1975			}else{
1976				obj.closest('.evcal_evdata_cell').addClass('shorter_desc');
1977				
1978				obj.attr({'content':'less'});
1979				obj.find('.ev_more_arrow').addClass('ard');
1980				obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text);
1981			}
1982		}
1983		
1984	// expand and shrink featured image		
1985		$('body').on('click','.evcal_evdata_img',function(){
1986			if(!$(this).hasClass('evo_noclick')){		
1987				feature_image_expansion($(this), 'click');
1988			}
1989		});		
1990	
1991	// featured image height processing
1992		function feature_image_expansion(image, type){
1993			img = image;
1994			
1995			var img_status = img.attr('data-status');
1996			var img_style = img.attr('data-imgstyle');
1997			
1998			// if image already expanded
1999			if(img_status=='open' ){
2000				img.attr({'data-status':'close'}).css({'height':''});			
2001			}else{	
2002				var img_full_height = parseInt(img.attr('data-imgheight'));
2003				var cal_width = parseInt(img.closest('.ajde_evcal_calendar').width());
2004					cal_width = (cal_width)? cal_width: img.width();
2005				var img_full_width = parseInt(img.attr('data-imgwidth'));
2006
2007
2008				// show at minimized height
2009				if(img_style=='100per'){
2010					relative_height = img_full_height;
2011				}else if(img_style=='full'){
2012					relative_height = parseInt(img_full_height * (cal_width/img_full_width)) ;
2013				}else{
2014					// minimized version
2015					if(type=='click'){
2016						relative_height = parseInt(img_full_height * (cal_width/img_full_width));
2017						relative_height = (relative_height)? relative_height: img_full_height;
2018						
2019						relative_height = parseInt((cal_width * img_full_height) /img_full_width);
2020						
2021						//console.log(relative_height+ ' '+img_full_height+' '+cal_width);
2022
2023					}else{
2024						relative_height = img.attr('data-minheight');
2025					}					
2026				}
2027				
2028				// when to set the status as open for images
2029				if(img_status=='' && img_style=='minmized'){
2030					img.attr({'data-status':'close'}).removeClass('expanded');
2031				}else{
2032					img.attr({'data-status':'open'}).addClass('expanded');
2033				}
2034				img.css({'height':relative_height});
2035			}			
2036		}
2037
2038	// reset featured images based on settings
2039		function fullheight_img_reset(calid){
2040			if(calid){
2041				$('#'+calid).find('.eventon_list_event .evo_metarow_fimg').each(function(){
2042					feature_image_expansion($(this));
2043				});
2044			}else{
2045				$('.evo_metarow_fimg').each(function(){					
2046					feature_image_expansion($(this));					
2047				});
2048			}
2049		}
2050			
2051	// treatments for calendar events upon load
2052		function treat_events(calid){
2053			if(calid!=''){
2054				if(is_mobile()){
2055					$('#'+calid).find('.evo_metarow_getDr form').attr({'target':'_self'});
2056				}
2057			}
2058		}
2059
2060		// if mobile check
2061		function is_mobile(){
2062			return ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )? true: false;
2063		}
2064
2065	// edit event button redirect
2066		$('body').on('click','.editEventBtnET', function(event){
2067			event.stopPropagation();
2068
2069			href = $(this).attr('href');
2070			//console.log(href);
2071			window.open(href);
2072		});
2073
2074	// repeat events series
2075	// @u 2.6.9
2076		$('body').on('click','.evo_repeat_series_date',function(){
2077			if( $(this).parent().data('click') ){
2078				URL =  $(this).data('l');
2079				window.location = URL;
2080			}
2081		});
2082
2083	// event location archive card page
2084		// @u 2.8.6
2085		$('body').find('.evo_location_map').each(function(){
2086			THIS = $(this);
2087			MAPID = THIS.attr('id');
2088
2089			var location_type = THIS.attr('data-location_type');
2090			if(location_type=='add'){
2091				var address = THIS.attr('data-address');
2092				var location_type = 'add';
2093			}else{			
2094				var address = THIS.attr('data-latlng');
2095				var location_type = 'latlng';				
2096			}
2097
2098			// zoomlevel
2099				zoom = parseInt(THIS.data('zoom'));
2100				scrollwheel = THIS.data('scroll') == 'yes'? true: false;
2101
2102			THIS.evoGenmaps({
2103				'fnt':5,
2104				map_canvas_id:	MAPID,
2105				location_type: 	location_type,
2106				address:address,
2107				zoomlevel: 		zoom,
2108				mapformat: 		THIS.data('mty'),
2109				scroll: 		scrollwheel,
2110			});
2111		});
2112		
2113	// SINGLE EVENTS
2114		// Loading single event json based content
2115			$('body').on('evo_load_single_event_content', function(event, eid, obj){
2116				var ajaxdataa = {};
2117				ajaxdataa['action']='eventon_load_event_content';
2118				ajaxdataa['eid'] = eid;
2119				ajaxdataa['nonce'] = the_ajax_script.postnonce;	
2120
2121				// pass on other event values
2122				if(obj.data('j')){
2123					$.each(obj.data('j'), function(index,val){
2124						ajaxdataa[ index] = val;
2125					});
2126				}			
2127				
2128				$.ajax({
2129					beforeSend: function(){ 	},	
2130					url:	the_ajax_script.ajaxurl,
2131					data: 	ajaxdataa,	dataType:'json', type: 	'POST',
2132					success:function(data){
2133						$('body').trigger('evo_single_event_content_loaded', [data, obj]);
2134					},complete:function(){ 	}
2135				});
2136			});
2137	
2138		if(is_mobile()){
2139			if($('body').find('.fb.evo_ss').length != 0){
2140				$('body').find('.fb.evo_ss').each(function(){
2141					obj = $(this);
2142					obj.attr({'href':'http://m.facebook.com/sharer.php?u='+obj.attr('data-url')});
2143				});
2144			}
2145		}
2146
2147		// on single event page
2148		if($('body').find('.evo_sin_page').length>0){
2149			$('.evo_sin_page').each(function(){
2150				$('body').trigger('evo_load_single_event_content',[ $(this).data('eid'), $(this)]);
2151				$(this).find('.desc_trig ').attr({'data-ux_val':'none'});
2152			});
2153		}
2154		
2155		// Single events box
2156			// Click on single event box
2157				$('.eventon_single_event').on('click', '.evcal_list_a',function(event){
2158					var obj = $(this);				
2159					var CAL = obj.closest('.ajde_evcal_calendar');
2160					var SC = CAL.evo_shortcode_data();
2161
2162					event.preventDefault();
2163
2164					// open in event page
2165					if(SC.ux_val == 4){ 
2166						var url = obj.parent().siblings('.evo_event_schema').find('[itemprop=url]').attr('href');
2167						window.location.href= url;
2168					}else if(SC.ux_val == '2'){ // External Link
2169						var url = SC.exturl;
2170						window.location.href= url;
2171					}else if(SC.ux_val == 'X'){ // do not do anything
2172						return false;
2173					}
2174				});
2175			// each single event box
2176				$('body').find('.eventon_single_event').each(function(){
2177					var _this = $(this);
2178
2179					var CAL = _this.closest('.ajde_evcal_calendar');
2180					var SC = CAL.evo_shortcode_data();	
2181					var evObj = CAL.find('.eventon_list_event');									
2182
2183					// show expanded eventCard
2184					if( SC.expanded =='yes'){
2185						_this.find('.evcal_eventcard').show();
2186						var idd = _this.find('.evcal_gmaps');						
2187
2188						// close button
2189						_this.find('.evcal_close').parent().css({'padding-right':0});
2190						_this.find('.evcal_close').hide();
2191
2192						//console.log(idd);
2193						var obj = _this.find('.desc_trig');
2194
2195						// Google Map
2196						obj.evoGenmaps({
2197							'fnt':2, 
2198							'cal':CAL,
2199						});
2200
2201					// open eventBox and lightbox	
2202					}else if(SC.uxval =='3'){
2203
2204						var obj = _this.find('.desc_trig');
2205						// remove other attr - that cause to redirect
2206						obj.removeAttr('data-exlk').attr({'data-ux_val':'3'});
2207					}
2208
2209					// show event excerpt
2210					var ev_excerpt = CAL.find('.event_excerpt').html();
2211					
2212					if(ev_excerpt!='' && ev_excerpt!== undefined && SC.excerpt =='yes' ){
2213						var appendation = '<div class="event_excerpt_in">'+ev_excerpt+'</div>'
2214						evObj.append(appendation);
2215					}
2216				});
2217
2218
2219	// HELPER items script
2220		// yes no button		
2221			$('body').on('click','.ajde_yn_btn ', function(event){
2222
2223				// stop this code from working on wp-admin
2224				if($('body').hasClass('wp-admin')) return false; 
2225				
2226				var obj = $(this);
2227				var afterstatement = obj.attr('afterstatement');
2228					afterstatement = (afterstatement === undefined)? obj.attr('data-afterstatement'): afterstatement;	
2229				var uid = '';
2230
2231				// yes
2232				if(obj.hasClass('NO')){					
2233					obj.removeClass('NO');
2234					obj.siblings('input').val('yes');
2235
2236					// afterstatment
2237					if(afterstatement!=''){
2238						var type = (obj.attr('as_type')=='class')? '.':'#';
2239						if( obj.data('uid') !== undefined) uid = obj.data('uid');
2240						$(type+ afterstatement).slideDown('fast');						
2241					}
2242
2243				}else{//no
2244					obj.addClass('NO');
2245					obj.siblings('input').val('no');
2246					
2247					if(afterstatement!=''){
2248						var type = (obj.attr('as_type')=='class')? '.':'#';
2249						$(type+ afterstatement ).slideUp('fast');
2250					}
2251				}
2252			});
2253
2254// Search Scripts
2255	// Enter key detection for pc
2256		$.fn.evo_enterKey = function (fnc) {
2257		    return this.each(function () {
2258		        $(this).keypress(function (ev) {
2259		            var keycode = (ev.keyCode ? ev.keyCode : ev.which);
2260		            if (keycode == '13') {
2261		                fnc.call(this, ev);
2262		            }
2263		        })
2264		    })
2265		}
2266		
2267	$('.evo-search').on('click',function(){
2268		var section = $(this).closest('.calendar_header');
2269		var item = section.find('.evo_search_bar');
2270
2271		item.slideToggle('fast', function(){
2272			if(item.is(':visible'))  item.find('input').focus();
2273		});
2274	});
2275
2276	// Submit search from search box
2277		$('body').on('click','.evo_do_search',function(){
2278			do_search_box( $(this) );
2279		});
2280
2281		$(".evosr_search_box input").evo_enterKey(function () {
2282			do_search_box( $(this).siblings('.evo_do_search') );
2283		});
2284
2285		function do_search_box(OBJ){
2286			SearchVal = OBJ.closest('.evosr_search_box').find('input').val();
2287			Evosearch = OBJ.closest('.EVOSR_section');
2288			OBJ.closest('.evo_search_entry').find('.evosr_msg').hide();
2289			//console.log(SearchVal);
2290
2291			if( SearchVal === undefined || SearchVal == ''){
2292				OBJ.closest('.evo_search_entry').find('.evosr_msg').show();
2293				return false;
2294			}
2295
2296
2297			SC = Evosearch.find('span.data').data('sc');
2298
2299			
2300			var data_arg = {
2301				action: 		'eventon_search_evo_events',
2302				search: 		SearchVal,
2303				shortcode: SC
2304			};
2305			$.ajax({
2306				beforeSend: function(){
2307					Evosearch.find('.evo_search_results_count').hide();
2308					Evosearch.addClass('searching');
2309				},
2310				type: 'POST',
2311				url:the_ajax_script.ajaxurl,
2312				data: data_arg,
2313				dataType:'json',
2314				success:function(data){
2315					Evosearch.find('.evo_search_results').html( data.content);
2316
2317					if(Evosearch.find('.no_events').length>0){
2318
2319					}else{
2320						// find event count
2321						Events = Evosearch.find('.evo_search_results').find('.eventon_list_event').length;
2322						Evosearch.find('.evo_search_results_count span').html( Events);
2323						Evosearch.find('.evo_search_results_count').fadeIn();
2324					}
2325					
2326				},complete: function(){
2327					Evosearch.removeClass('searching');
2328				}
2329			});
2330		}
2331
2332	// submit search from calendar
2333		$('body').on('click','.evosr_search_btn',function(){	search_within_calendar( $(this).siblings('input') );		});
2334		$(".evo_search_bar_in input").evo_enterKey(function () {	search_within_calendar( $(this) );		});
2335
2336		function search_within_calendar(obj){
2337
2338			var ev_cal = obj.closest('.ajde_evcal_calendar');
2339
2340
2341			
2342			ev_cal.evo_update_cal_sc({F:'show_limit_paged',V: '1' });
2343			ev_cal.evo_update_cal_sc({F:'s',V: obj.val() });
2344
2345			run_cal_ajax( ev_cal.attr('id'),'none','search');
2346			
2347		   	return false;	
2348		}	
2349
2350
2351	// More event images interaction
2352		$('body').on('click','.evo_event_more_img',function(){
2353			var O = $(this);
2354			var eCARD = O.closest('.evcal_eventcard');
2355			var fIMG = O.find('img');
2356			var fURL = fIMG.data('f');
2357
2358			O.parent().find('span').removeClass('select'); O.addClass('select');
2359
2360			eCARD.find('img.evo_event_main_img').attr({'src': fURL});
2361
2362			relIMG = eCARD.find('.evo_metarow_fimg');
2363			relIMG.css('background-image', 'url('+ fURL +')' );
2364			relIMG.data('imgheight', fIMG.data('h'));
2365		});	
2366
2367// supportive
2368	// handlebar additions
2369		function handlebar_additional_arguments(){
2370			Handlebars.registerHelper('ifE',function(v1, options){
2371				return (v1 !== undefined && v1 != '' && v1)
2372                    ? options.fn(this)
2373                    : options.inverse(this);
2374			});
2375
2376			Handlebars.registerHelper('ifEQ',function(v1, v2, options){
2377				return ( v1 == v2)? options.fn(this): options.inverse(this);
2378			});
2379			Handlebars.registerHelper('ifNEQ',function(v1, v2, options){
2380				return ( v1 != v2)? options.fn(this): options.inverse(this);
2381			});
2382			Handlebars.registerHelper('BUStxt',function(V, options){	
2383				if( !( V in BUS.txt) ) return V;
2384				return BUS.txt[V];
2385			});
2386			Handlebars.registerHelper('GetDMnames',function(V, U, options){				
2387				return BUS.dms[U][ V ];
2388			});
2389			// get total of increments
2390			Handlebars.registerHelper('forAdds',function(count, add_val, options){	
2391				O = '';
2392				for(x=1; x<= count; x++){	O += add_val;	}			
2393				return O;
2394			});
2395			Handlebars.registerHelper('GetEvProp',function(EID, PROP, CALID){
2396				EID = EID.split('-');	
2397				EV = $('#'+ CALID).find('.evo_cal_events').data('events');
2398				
2399				var O = '';
2400				$.each(EV, function(i,d){
2401					if( d.ID == EID[0] && d.ri == EID[1]){
2402						if( !(PROP in d.event_pmv)) return;
2403						O = d.event_pmv[PROP][0];
2404					}
2405				});
2406				return O;
2407			});
2408			Handlebars.registerHelper('GetEvV',function(EID, PROP, CALID){
2409				EID = EID.split('-');	
2410				EV = $('#'+ CALID).find('.evo_cal_events').data('events');
2411				
2412				var O = '';
2413				$.each(EV, function(i,d){
2414					if( d.ID == EID[0] && d.ri == EID[1]){
2415						O = d[PROP];
2416					}
2417				});
2418				return O;
2419			});
2420			Handlebars.registerHelper('COUNT',function( V){		
2421				return Object.keys(V).length;
2422			});
2423			Handlebars.registerHelper('CountlimitLess',function( AR, C,options){		
2424				var L= Object.keys(AR).length;
2425				return ( L < C)? options.inverse(this): options.fn(this);
2426			});
2427			Handlebars.registerHelper('ifCOND',function(v1, operator, v2, options){
2428				return checkCondition(v1, operator, v2)
2429	                ? options.fn(this)
2430	                : options.inverse(this);
2431			});
2432			Handlebars.registerHelper('toJSON', function(obj) {
2433			    return new Handlebars.SafeString(JSON.stringify(obj));
2434			});
2435			Handlebars.registerHelper('Cal_def_check',function(V, options){		
2436				if( BUS.cal_def && BUS.cal_def[V] ) return options.fn(this);
2437				return options.inverse(this);
2438			});
2439			Handlebars.registerHelper('TypeCheck',function(V, options){		
2440				if( options.type == V ) return options.fn(this);
2441				return options.inverse(this);
2442			});
2443		}
2444		function checkCondition(v1, operator, v2) {
2445	        switch(operator) {
2446	            case '==':
2447	                return (v1 == v2);
2448	            case '===':
2449	                return (v1 === v2);
2450	            case '!==':
2451	                return (v1 !== v2);
2452	            case '<':
2453	                return (v1 < v2);
2454	            case '<=':
2455	                return (v1 <= v2);
2456	            case '>':
2457	                return (v1 > v2);
2458	            case '>=':
2459	                return (v1 >= v2);
2460	            case '&&':
2461	                return (v1 && v2);
2462	            case '||':
2463	                return (v1 || v2);
2464	            default:
2465	                return false;
2466	        }
2467	    }
2468	// @2.9.1
2469	// increase and reduce quantity
2470	    $('body').on('click','.evo_qty_change', function(event){
2471	        var OBJ = $(this);
2472	        var QTY = oQTY = parseInt(OBJ.siblings('em').html());
2473	        var MAX = OBJ.siblings('input').attr('max');
2474	        var BOX = OBJ.closest('.evo_purchase_box');
2475
2476	        var pfd = BOX.find('.evo_purchase_box_data').data('pfd');
2477	        
2478
2479	        (OBJ.hasClass('plu'))?  QTY++: QTY--;
2480
2481	        QTY =(QTY==0)? 1: QTY;
2482	        QTY = (MAX!='' && QTY > MAX)? MAX: QTY;
2483
2484	        // new total price
2485	        var sin_price = OBJ.parent().data('p');
2486	        new_price = sin_price * QTY;
2487
2488	        new_price = get_format_price( new_price, pfd);
2489
2490	        BOX.find('.total .value').html( new_price);
2491
2492	        OBJ.siblings('em').html(QTY);
2493	        OBJ.siblings('input').val(QTY);
2494
2495	        $('body').trigger('evo_qty_changed',[QTY,oQTY, new_price,OBJ ]);
2496	    });
2497
2498    // Total formating
2499        function get_format_price(price, data){
2500
2501            // price format data
2502            PF = data;
2503           
2504            totalPrice = price.toFixed(PF.numDec); // number of decimals
2505            htmlPrice = totalPrice.toString().replace('.', PF.decSep);
2506
2507            if(PF.thoSep.length > 0) {
2508                htmlPrice = _addThousandSep(htmlPrice, PF.thoSep);
2509            }
2510            if(PF.curPos == 'right') {
2511                htmlPrice = htmlPrice + PF.currencySymbol;
2512            }
2513            else if(PF.curPos == 'right_space') {
2514                htmlPrice = htmlPrice + ' ' + PF.currencySymbol;
2515            }
2516            else if(PF.curPos == 'left_space') {
2517                htmlPrice = PF.currencySymbol + ' ' + htmlPrice;
2518            }
2519            else {
2520                htmlPrice = PF.currencySymbol + htmlPrice;
2521            }
2522            return htmlPrice;
2523        }
2524        function _addThousandSep(n, thoSep){
2525            var rx=  /(\d+)(\d{3})/;
2526            return String(n).replace(/^\d+/, function(w){
2527                while(rx.test(w)){
2528                    w= w.replace(rx, '$1'+thoSep+'$2');
2529                }
2530                return w;
2531            });
2532        };
2533
2534
2535
2536});

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.