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