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