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