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