PageSourceSearch

https://www.tunefm.net/content/plugins/eventon-lite/assets/js/eventon_script.js?ver=2.3.2

js tunefm.net collected 2026-10-02 15:01:07 UTC 67,186 bytes, 2,317 lines download raw bytes

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

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.