PageSourceSearch

https://bioparcvalencia.es/wp-content/plugins/eventon-full-cal/assets/fc_script.js?ver=2.1.2

js bioparcvalencia.es collected 2026-09-24 09:01:11 UTC 19,376 bytes, 648 lines download raw bytes

1/**
2 * Main javascript for fullCal addon for eventon
3 * @version 2.1.2
4 */
5jQuery(document).ready(function($){	
6	//init();	
7
8	$.fn.evo_fullcal = function(){
9		el = this;
10		var B = $(this).evo_cal_functions({return:'load_shortcodes'});		
11	};
12
13
14	// EVO INIT AJAX - success
15		$('body').on('evo_init_ajax_success_each_cal', function(event, data, calid, v){
16			CAL = $('body').find('#'+ calid);
17
18			if(!CAL.hasClass('evoFC')) return;
19			SC = CAL.evo_shortcode_data();
20
21			CAL.evo_fullcal();
22			
23			if(SC.evc_open == 'no' && SC.load_fullmonth=='no'){
24				CAL.find('#evcal_list').addClass('evo_hide');
25			}
26
27			draw_fullcal( CAL ,'init');
28
29			// load only fixed day events
30			//if(SC.load_fullmonth=='no')	load_correct_events( CAL, 'init');
31		});
32
33		$('body').on('evo_init_ajax_success',function(event, data){
34			$('body').find('.ajde_evcal_calendar.noiajx.evoFC').each(function(){
35				draw_fullcal( $(this), 'init' );
36				populate_grid_boxes_with_events( $(this) ,'init_ajax');
37			});
38		});
39		// COMPLETE
40		$('body').on('evo_main_ajax_complete', function(event, CAL, ajaxtype, data , data_arg){		
41			var SC = data_arg.shortcode;
42			if(  SC.calendar_type == 'fullcal'){
43					populate_grid_boxes_with_events( CAL ,'main_ajax_complete');
44			}
45		});	
46		
47
48	// DRAW FullCal grid
49		function draw_fullcal( CAL, type ){
50
51
52			BUS = $('#evo_global_data').data('d');
53			var eJSON = CAL.find('.evo_cal_events').data('events');
54			SC = CAL.evo_shortcode_data();
55			const cal_tz = CAL.evo_get_global({S1:'cal_def',S2:'cal_tz'}); 
56			var template_data = {};
57			template_data['days'] = {};
58
59			var days_in_month = CAL.evo_day_in_month({M: SC.fixed_month, Y: SC.fixed_year});
60
61			
62			// day names
63				day_names = {};
64				_z = start_of_week = BUS.cal_def.start_of_week;
65				for(z=0; z<=6; z++){
66					day_names[z]= BUS.dms.d3[_z];
67					_z++;
68					_z = (_z>6)? 0: _z;
69				}
70
71			first_day_index = CAL.evo_get_day_name_index({D:1,M: SC.fixed_month, Y: SC.fixed_year});				
72			boxes = ( first_day_index < start_of_week)? 
73						((7 - start_of_week) +first_day_index): (first_day_index- start_of_week);
74
75			// NOW - current user time
76			M = moment();
77
78			var SU = parseInt( SC.focus_start_date_range);	
79			var MM = moment.unix( SU ).tz( cal_tz );			
80
81			//window.alert(first_day_index + ' '+boxes);
82
83			template_data['blanks'] = boxes;			
84			template_data['day_names'] = day_names;
85			template_data['month'] = SC.fixed_month;
86
87			// month strip class name additions
88				_class_adds_mo = '';
89				if(SC.style == 'names') _class_adds_mo += ' names';
90				if(SC.style == 'nobox') _class_adds_mo += ' nobox';
91				if(SC.heat == 'yes') _class_adds_mo += ' heatmap';
92					template_data['months_strip_classes'] = _class_adds_mo;
93
94
95			var boxcount = boxes;
96			var row = 1;
97			var calrows = Math.ceil( (boxes+days_in_month)/7);
98			var boxsin_lastrow = (boxes+days_in_month)%7;
99
100			
101			// each day in month
102			for(var x=1; x<= days_in_month; x++){
103				
104				boxcount++;
105
106				_class_adds = '';
107				_class_adds += ' '+boxcount;
108
109				if(x == M.get('date') && M.get('month') == (MM.get('month')) && SC.fixed_year == MM.year() ) _class_adds += ' today';
110				if(x == SC.fixed_day ) _class_adds += ' on_focus';
111				if(x > (days_in_month-7)) _class_adds += ' bb';
112
113				// before last row
114				if(boxsin_lastrow != 0 && row == calrows-1 && x <= (days_in_month-7)) _class_adds += ' blsr';
115
116
117				// last row cell
118				if( boxcount> 21 && calrows == 4 && boxsin_lastrow != 0) _class_adds += ' nobrt';
119				if( boxcount> 28 && calrows == 5 && boxsin_lastrow != 0) _class_adds += ' nobrt';
120				if( boxcount> 35 && calrows == 6 && boxsin_lastrow != 0) _class_adds += ' nobrt';
121
122				
123				// last day of the week
124				if( boxcount %7 == 0){
125					_class_adds += ' lstdw';
126					row++;
127				}
128
129				// right bottom box
130				if( boxcount %7 == 0 && row == calrows && boxsin_lastrow != 0) _class_adds += ' rb';
131				
132				// bottom left box
133				if( boxcount  == 29 && row == calrows) _class_adds += ' lb';
134
135				template_data['days'][x] = {};
136				template_data['days'][x]['cls'] = _class_adds;
137				template_data['days'][x]['su'] = MM.unix();				
138				template_data['days'][x]['e'] = {};
139
140				MM.add(1,'d');	
141
142				template_data['days'][x]['eu'] = MM.unix() - 1;
143			}
144
145			_html_grid = get_evo_temp_processed_html( template_data , 'evofc_grid');
146
147			// replace or insert HTML
148			if(type == 'replace'){
149				return _html_grid;
150			
151			}else{
152				_html_base = get_evo_temp_processed_html( template_data , 'evofc_base');				
153
154				ELM = CAL.find('#eventon_loadbar_section');
155				ELM.after( _html_base );
156				CAL.find('.evofc_months_strip').html( _html_grid );
157			}
158			CAL.find('.evofc_month_grid').fadeIn();
159
160			// remove pre laoder section
161			CAL.find('.evofc_pre_loader').remove();
162
163
164			if( type != 'replace') populate_grid_boxes_with_events( CAL , type);
165		}	
166			function get_evo_temp_processed_html( template_data, part){
167				BUS = $('#evo_global_data').data('d');
168				template = Handlebars.compile( BUS.temp[ part ] );
169				return template( template_data );
170			}
171
172		// populate the grid boxes with events JSON
173		function populate_grid_boxes_with_events(CAL, type){
174			var eJSON = CAL.find('.evo_cal_events').data('events');
175			grid = CAL.find('.evofc_month_grid');
176			SC = CAL.evo_shortcode_data();
177			var cal_events = CAL.find('.eventon_list_event');
178			
179			var _txt_more = CAL.evo_get_txt({V:'more'});
180
181			// EACH DAY
182			max_events = 0; days = {};
183			grid.find('.evofc_day').each(function(index){	
184				O = $(this);
185
186				EC = 0;
187				O_span = O.find('span.day_evs');
188				O_span.html('');
189				O.removeClass('has_events');
190
191				// each day unix
192				SU = parseInt(O.data('su'));
193				EU = parseInt(O.data('eu'));
194
195				// record events for this date
196					var this_events = [];
197
198				// run thru each event in calendar month
199				cal_events.each(function(index, elm){
200					var ED = $(elm).evo_cal_get_basic_eventdata();
201					if(!ED) return;
202
203					ESU = ED.unix_start; EEU = ED.unix_end;
204
205					var inrange = CAL.evo_is_in_range({
206						'S': SU,	'E': EU,	'start': ESU,'end':EEU
207					});					
208
209					// if event is not in range --> skip
210					if(!inrange) return;
211
212					// record this event for the date
213					this_events.push( $(elm).attr('id') );
214
215					_color = parseInt( ED.hex_color, 16) > 0xffffff/2 ? '#000':'#fff';
216
217					EC++;
218					O.addClass('has_events');
219					O.removeClass('noE');
220
221					// Names in the grid
222					if( SC.style == 'names'){
223						if(EC <3){							
224
225							var _day_class = '';
226
227							if(ESU < SU && SU < EEU && EEU <=EU) _day_class = 'muld_e';
228							if(ESU < SU && EU < EEU ) _day_class = 'muld_m';
229							if(SU <= ESU && EU < EEU ) _day_class = 'muld_s';
230
231							if(ESU < SU && O.hasClass('d_1')) _day_class += ' strpr';
232
233							var _event_title = ED.event_title;		
234
235							var _content = "<i class='"+ ED.uID +" "+_day_class+"' style='background-color:"+ ED.hex_color +"; color:"+_color+"' title='"+ _event_title +"'>"+ _event_title +"</i>";
236
237							// if previous date has same event
238							if(O.prev().find('i.'+ ED.uID ).length>0){
239								prev_ind = O.prev().find('i.'+ ED.uID).index();
240								if( prev_ind == 0){
241									O_span.prepend( _content);	
242								}else{
243								// prev ind = 1
244									if( O_span.find('i').length==0){
245										var prev_i = O.prev().find('i.'+ ED.uID);
246										O.prev().find('span.day_evs').prepend( prev_i);
247									}
248									O_span.append( _content);											
249								}
250							}else{
251								O_span.append( _content);	
252							}
253						}else{
254							if(O.find('b').length == 0) O.find('span.day_evs').append( "<b>+ "+_txt_more+"</b>");
255						}					
256					}else{
257						if(EC >=5 ){
258							O_span.html( "<b>"+EC+" "+_txt_more+"</b>");
259						}else{
260
261							title = ED.event_title;
262							title2 = title.split('<i');
263
264							//console.log(ED);
265							O_span.append( "<i class='"+ ED.uID +"' style='background-color:"+ ED.hex_color +"; color:"+_color+"' title='"+ title2[0] +"'></i>");	
266						}
267					}
268					if( EC> max_events) max_events = EC;
269
270				});
271
272				O.data('e', this_events);
273
274				if( EC == 0) O.addClass('noE');
275				days[index] = EC;
276			});
277
278			// heat map coloring
279			if( SC.heat =='yes'){
280				grid_data = grid.data('d');
281				color = 'heat_c' in grid_data && grid_data.heat_c ? grid_data.heat_c : '4ccdea';
282
283				grid.find('.evofc_day').each(function(index){
284					events = days[index];						
285					opacity = ( events/ max_events).toFixed(2) ;
286					
287					
288					if(events>0){
289						if( $(this).find('em.hm').length> 0){
290							$(this).find('em.hm').css({
291								'background-color': '#'+ color,
292								'opacity': opacity
293							});	
294						}else{
295							$(this).append('<em class="hm" style="'+ 'background-color:#'+ color +'; opacity:'+ opacity +'"></em>');	
296						}											
297					}else{
298						$(this).find('em.hm').remove();
299					}				
300				});
301			}
302
303			if(SC.load_fullmonth=='no') load_correct_events( CAL, type);
304
305			// trigger
306			$('body').trigger('evofc_calendar_populated',[ CAL , type]);
307
308		}
309
310	
311		
312	// GENERAL Interactions
313		// fix ratios for resizing the calendar size
314			$( window ).resize(function() {	$('body').trigger('evofc_resize_cal_grid');	});
315		// CLICK on a day	
316			$('body').on( 'click','.evofc_day',function(){	clickon_day($(this));	});	
317
318			function clickon_day(obj){
319				if( obj.hasClass('evo_fc_empty')) return;
320
321				CAL = obj.closest('.ajde_evcal_calendar');
322				SC = CAL.evo_shortcode_data();
323				CAL.evo_update_cal_sc({		F:'fixed_day', V:obj.data('d')	});
324			
325				load_correct_events( CAL ,'click');
326			}
327
328		// load correct events in event list based on fixed day
329		function load_correct_events(CAL, type){
330			SC = CAL.evo_shortcode_data();
331			const OD = CAL.evo_get_OD();
332
333			if(type == 'init' && SC.grid_ux==2) return;
334			
335			fixed_day = parseInt(SC.fixed_day);
336
337			var box_obj = CAL.find('.evofc_day.d_'+fixed_day);
338			box_obj.siblings('.evofc_day').removeClass('on_focus');
339			box_obj.addClass('on_focus');
340			
341			// clicked day unix
342			SU = parseInt(box_obj.data('su'));
343			EU = parseInt(box_obj.data('eu'));
344
345			// get in range events from calendar
346				R = CAL.evo_cal_events_in_range({
347					S: SU,
348					E: EU,
349					closeEC: (SC.evc_open=='yes'? false:true),
350				});
351			
352			// grid interaction
353				if( SC.grid_ux == 1){
354					$([document.documentElement, document.body]).animate({
355				        scrollTop: CAL.find('#evcal_list').offset().top - 50
356				    }, 200);
357				}
358
359			// if no events
360			var inside_content = '';
361			if( R.count == 0){
362				txt = CAL.evo_get_global({S1:'txt',S2:'no_events'});
363				inside_content = "<div class='eventon_list_event no_events'><p class='no_events' >"+ txt +"</p></div>";
364			}
365
366			// load events in lightbox
367			if(SC.grid_ux==2 && type != 'init' && type != 'main_ajax_complete') {
368
369				const LB = $('.evofc_lightbox');
370				LB.evo_prepare_lb();	
371
372				if( 'count' in R && R.count > 0){
373					$('.evofc_lightbox').evo_append_lb({C: R.html, CAL: CAL});
374				}else{
375					$('.evofc_lightbox').evo_append_lb({C: inside_content, CAL: CAL });
376				}			
377				
378				$('.evofc_lightbox').evo_show_lb({calid: CAL.attr('id')});
379				
380				// show event content on lightbox
381				$('.evofc_lightbox').find('.eventon_list_event').show();
382
383				$('body').trigger('evolightbox_end', [ LB , CAL ]);	// @2.1.2
384
385			// show events as list below calendar
386			}else{
387				eList = CAL.find('#evcal_list');
388				if(R.count == 0){				
389
390					if(eList.has('.no_events.eventon_list_event').length){
391						eList.find('.no_events.eventon_list_event').show();
392					}else{						
393						eList.append( inside_content );
394					}						
395				}else{
396					$.each(R.json,function(i,evid){
397						eList.find('#event_'+i).show();
398					});
399					CAL.find('.eventon_list_event.no_events').remove();
400				}
401				CAL.find('#evcal_list').removeClass('evo_hide').show();
402			}
403
404			// trigger
405			$('body').trigger('evofc_calendar_events_loaded',[ CAL , type]);
406		}
407		
408	// BODY GEN
409		$('body')
410			// calendar view switching
411			.on('evo_vSW_clicked_before_ajax',function(event, O, CAL, DD, reload_cal_data){
412				if(!(O.hasClass('evofc'))) return;
413				var SC = CAL.evo_shortcode_data();
414
415				CAL.evo_update_cal_sc({F:'calendar_type', V: 'fullcal'});
416
417			})
418			.on('evo_vSW_clicked',function(event, OBJ, CAL){
419				if(!(OBJ.hasClass('evofc'))) return;
420
421				CAL.evo_update_cal_sc({F:'calendar_type', V: 'fullcal'});
422
423				draw_fullcal( CAL );				
424
425			})
426			// resize fullcal grid
427				.on('evofc_resize_cal_grid', function(){
428					$('.eventon_fullcal').each(function(){
429						var cal_width = $(this).width();
430						var strip = $(this).find('.evofc_months_strip');
431						var multiplier = strip.attr('data-multiplier');
432						
433						if(multiplier<0){
434							strip.width(cal_width*3).css({'margin-left':(multiplier*cal_width)+'px'});					
435						}
436						$(this).find('.evofc_month').width(cal_width);
437					});
438				})			
439			// tool tips on calendar dates
440				.on('mouseover' , '.evofc_day.has_events', function(){
441					O = $(this);
442					CAL = O.closest('.ajde_evcal_calendar');
443					SC = CAL.evo_shortcode_data();
444					_fc_grid_O = CAL.find('.evofc_month_grid');
445					const box_index = O.index(),
446						box_height = O.height();
447				
448
449					// event names
450					if(SC.hover =='numname'){	
451						
452						R = CAL.evo_cal_events_in_range({
453							S: parseInt(O.data('su')), E: parseInt(O.data('eu')), 
454							hide:false});		
455						_events_html = '';	
456						
457						titletip = CAL.find('.evofc_title_tip');
458						
459						// events count
460						CAL.find('.evofc_ttle_cnt').html( R.count);
461
462						// event names
463						_C = 0;
464						$.each( R.json, function(key, ED){
465							if(_C>2) return;
466							_events_html += "<li style='border-left-color:#"+ ED.hex_color +"'>"+ ED.event_title +"</li>";	
467							_C++;
468						});
469
470						// show more events text only for events more than 3
471						if( R.count > 3){
472							_events_html += "<li>+ "+ CAL.evo_get_global({S1:'txt',S2:'more'}) +"</li>";	
473						}
474						CAL.find('.evofc_ttle_events').html( _events_html );
475
476						// Positioning
477							TITLETIP_HEIGHT = titletip.height();
478
479							var offs = O.position();
480							width = $('.eventon_fullcal').width();
481							var dayh = CAL.find('.eventon_fc_daynames').height();
482
483							var _TOP = (offs.top + dayh - TITLETIP_HEIGHT);
484
485
486							if( O.offset().left < ( _fc_grid_O.offset().left + _fc_grid_O.width() - (O.width()*4) ) ){
487								titletip.removeClass('lefter');
488								leftOff = offs.left + O.width();
489								rightOFF = 'initial';
490							}else{
491								titletip.addClass('lefter');
492								leftOff = 'initial';
493								rightOFF = width- offs.left ;	
494							}
495
496							// top row boxes
497							if( box_index <8){
498								titletip.addClass('topper');
499								_TOP = offs.top + dayh +  O.outerHeight();
500							}else{
501								titletip.removeClass('topper');
502							}
503
504							titletip.css({
505								top: _TOP, 
506								left:leftOff, 
507								right:rightOFF
508							})
509							.stop(true, false)
510							.fadeIn('fast');
511
512					}else{ // just event count number
513						var popup = CAL.find('.evoFC_tip');
514						var offs = O.position();
515						var leftOff ='';
516
517						var dayh = O.closest('.evofc_month').find('.eventon_fc_daynames')
518							.height();
519
520						if(O.offset().left < ( _fc_grid_O.offset().left + _fc_grid_O.width() - (O.width()*3) ) ){
521							leftOff = offs.left + O.width()+2;
522						}else{
523							popup.addClass('leftyy');
524							leftOff = offs.left - 17;							
525						}						
526						popup.css({top: (offs.top+dayh), left:leftOff});
527						popup.html( O.data('e').length ).stop(true, false).fadeIn('fast');
528					}
529					
530				})
531				.on('mouseout' , '.evofc_day.has_events', function(){
532					O = $(this);
533					CAL = O.closest('.ajde_evcal_calendar');
534					SC = CAL.evo_shortcode_data();
535
536					if(SC.hover=='numname'){
537						CAL.find('.evofc_title_tip').removeClass('lefter');
538						CAL.find('.evofc_title_tip').stop(true, false).hide();
539					}else{
540						var popup = CAL.find('.evoFC_tip');
541						popup.removeClass('leftyy');			
542						popup.stop(true, false).hide();
543					}
544				});
545	
546	// AJAX Operations
547		// SUCCESS
548		$('body').on('evo_main_ajax_success',function(event, CAL, ajaxtype, data, data_arg){
549			if(  data.SC.calendar_type == 'fullcal'){
550
551				SC = data.SC;
552
553				_month_grid_adds = draw_fullcal( CAL,  'replace' );
554
555				var this_section = CAL.find('.eventon_fc_days');
556				var strip = CAL.find('.evofc_months_strip');
557				var cur_margin = parseInt(strip.css('marginLeft'));
558				var month_width = parseInt(strip.parent().width());
559				var months = strip.find('.evofc_month').length;
560				var super_margin;
561				var pre_elems = strip.find('.focus').prevAll().length;
562				var next_elems = strip.find('.focus').nextAll().length;
563				
564				// build out month grid animation
565					if( data_arg.direction =='next' || ajaxtype=='jumper' || ajaxtype == 'today'){
566						strip.css({'width': (month_width*2)});
567						if( months ==2 && next_elems==0){
568							strip.find('.evofc_month:first-child').remove();
569							strip.css({'margin-left':(cur_margin+month_width)+'px'});						
570							super_margin = cur_margin;
571							strip.append( _month_grid_adds );
572							
573						}else if(months== 2 && next_elems==1){
574							super_margin = cur_margin-month_width;
575						}else{
576							strip.append( _month_grid_adds );
577							super_margin = cur_margin-month_width;
578							
579							if(ajaxtype=='jumper'){
580								strip.find('.evofc_month:first-child').remove();					
581								strip.css({'margin-left':'0'});
582							} 		
583						}					
584						
585						strip.attr({'data-multiplier':'-1'}).find('.evofc_month').removeClass('focus');
586						strip.find('.evofc_month:last-child').addClass('focus');
587						
588					}else if( data_arg.direction =='prev'){						
589						if(months==2 && pre_elems==0){	
590							strip.prepend( _month_grid_adds );
591							strip.css({'margin-left':(cur_margin-month_width)+'px'});
592							
593							strip.find('.evofc_month:last-child').remove();
594							super_margin =0;	
595						}else if(months== 2 && pre_elems==1){
596							super_margin =0;
597						}else{							
598							strip.prepend( _month_grid_adds );
599							strip.css({'margin-left':(cur_margin-month_width)+'px'});
600							super_margin = 0;							
601						}
602						
603						strip.attr({'data-multiplier':'+1'}).find('.evofc_month').removeClass('focus');
604						strip.find('.evofc_month:first-child').addClass('focus');						
605					}else{// no month change - filter, search
606						strip.find('.focus').replaceWith(  _month_grid_adds );
607						strip.find('.evofc_month[month='+ SC.fixed_month +']').addClass('focus');
608					}
609
610				strip.find('.evofc_month').width(month_width);
611				
612				// animate the month grid
613				if(data_arg.direction =='none' && ajaxtype != 'today'){
614					
615					populate_grid_boxes_with_events( CAL ,'noanimate');
616					
617					if(SC.load_fullmonth=='no') load_correct_events( CAL ,'init');
618					
619					strip.attr({'data-multiplier':'0'});
620				
621				}else{
622
623					strip.delay(100).animate({'margin-left':super_margin+'px'}, 500, 'easeOutQuint',function(){
624						strip.find('.focus').siblings().remove();
625						strip.css({'margin-left':'0'});
626						strip.attr({'data-multiplier':'0'});
627						
628						// load correct events and populate the new grid
629						populate_grid_boxes_with_events( CAL , 'init');
630
631
632						if(SC.load_fullmonth=='no')	load_correct_events( CAL, 'init');
633					});
634				}
635			}
636		});
637
638
639	// if mobile check
640		function is_mobile(){
641			return ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )? true: false;
642		}
643		function is_android(){
644			var ua = navigator.userAgent.toLowerCase();
645			return ( ua.indexOf("android") > -1)? true: false;
646		}
647
648});

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.