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