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