1/** 2 * Javascript code that is associated with the front end of the calendar 3 * version: 2.6.16 4 * updated: 2.8 5 */ 6 7jQuery(document).ready(function($){ 8 9 init(); 10 var BODY = $('body'); 11 12 var BUS = ''; // initial eventon calendar data 13 14 // RUN on Page load 15 function init(){ 16 init_run_gmap_openevc(); 17 fullheight_img_reset(); 18 19 init_load_cal_data(); 20 handlebar_additional_arguments(); 21 } 22 23 24 // Initial load data via ajax 25 function init_load_cal_data(){ 26 var data_arg = {action: 'eventon_init_load'}; 27 28 BODY = $('body'); 29 BODY.trigger('evo_global_page_run'); 30 31 data_arg['global'] = $('#evo_global_data').data('d'); 32 data_arg['cals'] ={}; 33 34 // pass ajax loading calendar shortcodes 35 $('body').find('.ajax_loading_cal').each(function(){ 36 CAL = $(this); 37 SC = CAL.find('.evo_cal_data').data('sc'); 38 39 data_arg['cals'][ CAL.attr('id')] = {}; 40 data_arg['cals'][ CAL.attr('id')]['sc'] = SC; 41 }); 42 43 $.ajax({ 44 beforeSend: function(){}, 45 type: 'POST', 46 url:the_ajax_script.ajaxurl, 47 data: data_arg, 48 dataType:'json', 49 success:function(data){ 50 $('#evo_global_data').data('d', data); 51 52 BUS = data; 53 54 // append html to calendars if present 55 if('cals' in data){ 56 $.each(data.cals, function(i,v){ 57 CAL = BODY.find('#'+ i); 58 if('html' in v){ 59 CAL.find('#evcal_list').html( v.html ); 60 CAL.removeClass('ajax_loading_cal'); 61 CAL.find('.evo_ajax_load_events').remove(); 62 } 63 if('json' in v) CAL.find('.evo_cal_events').data('events', v.json); 64 if('sc' in v) CAL.evo_update_all_cal_sc({SC: v.sc}); 65 66 $('body').trigger('evo_init_ajax_success_each_cal', [data, i, v]); 67 }); 68 } 69 70 $('body').trigger('evo_init_ajax_success', [data]); 71 72 },complete:function(data){} 73 }); 74 } 75 76 // handlebar additions 77 function handlebar_additional_arguments(){ 78 Handlebars.registerHelper('ifE',function(v1, options){ 79 return (v1 !== undefined && v1 != '' && v1) 80 ? options.fn(this) 81 : options.inverse(this); 82 }); 83 84 Handlebars.registerHelper('ifEQ',function(v1, v2, options){ 85 return ( v1 == v2)? options.fn(this): options.inverse(this); 86 }); 87 Handlebars.registerHelper('ifNEQ',function(v1, v2, options){ 88 return ( v1 != v2)? options.fn(this): options.inverse(this); 89 }); 90 Handlebars.registerHelper('BUStxt',function(V, options){ 91 if( !( V in BUS.txt) ) return V; 92 return BUS.txt[V]; 93 }); 94 Handlebars.registerHelper('GetDMnames',function(V, U, options){ 95 return BUS.dms[U][ V ]; 96 }); 97 // get total of increments 98 Handlebars.registerHelper('forAdds',function(count, add_val, options){ 99 O = ''; 100 for(x=1; x<= count; x++){ O += add_val; } 101 return O; 102 }); 103 Handlebars.registerHelper('GetEvProp',function(EID, PROP, CALID){ 104 EID = EID.split('-'); 105 EV = $('#'+ CALID).find('.evo_cal_events').data('events'); 106 107 var O = ''; 108 $.each(EV, function(i,d){ 109 if( d.ID == EID[0] && d.ri == EID[1]){ 110 if( !(PROP in d.event_pmv)) return; 111 O = d.event_pmv[PROP][0]; 112 } 113 }); 114 return O; 115 }); 116 Handlebars.registerHelper('GetEvV',function(EID, PROP, CALID){ 117 EID = EID.split('-'); 118 EV = $('#'+ CALID).find('.evo_cal_events').data('events'); 119 120 var O = ''; 121 $.each(EV, function(i,d){ 122 if( d.ID == EID[0] && d.ri == EID[1]){ 123 O = d[PROP]; 124 } 125 }); 126 return O; 127 }); 128 Handlebars.registerHelper('COUNT',function( V){ 129 return Object.keys(V).length; 130 }); 131 Handlebars.registerHelper('CountlimitLess',function( AR, C,options){ 132 var L= Object.keys(AR).length; 133 return ( L < C)? options.inverse(this): options.fn(this); 134 }); 135 Handlebars.registerHelper('ifCOND',function(v1, operator, v2, options){ 136 return checkCondition(v1, operator, v2) 137 ? options.fn(this) 138 : options.inverse(this); 139 }); 140 Handlebars.registerHelper('toJSON', function(obj) { 141 return new Handlebars.SafeString(JSON.stringify(obj)); 142 }); 143 Handlebars.registerHelper('Cal_def_check',function(V, options){ 144 if( BUS.cal_def && BUS.cal_def[V] ) return options.fn(this); 145 return options.inverse(this); 146 }); 147 Handlebars.registerHelper('TypeCheck',function(V, options){ 148 if( options.type == V ) return options.fn(this); 149 return options.inverse(this); 150 }); 151 } 152 function checkCondition(v1, operator, v2) { 153 switch(operator) { 154 case '==': 155 return (v1 == v2); 156 case '===': 157 return (v1 === v2); 158 case '!==': 159 return (v1 !== v2); 160 case '<': 161 return (v1 < v2); 162 case '<=': 163 return (v1 <= v2); 164 case '>': 165 return (v1 > v2); 166 case '>=': 167 return (v1 >= v2); 168 case '&&': 169 return (v1 && v2); 170 case '||': 171 return (v1 || v2); 172 default: 173 return false; 174 } 175 } 176 177 // LIGHTBOX 178 // close popup 179 BODY.on('click','.evolbclose', function(){ 180 LIGHTBOX = $(this).closest('.evo_lightbox'); 181 closing_lightbox( LIGHTBOX ); 182 }); 183 184 // close with click outside popup box when pop is shown 185 $(document).on('click', function(event) { 186 //event.stopPropagation(); 187 //console.log($(event.target)); 188 if( 189 $(event.target).hasClass('evo_content_inin') 190 ){ 191 closing_lightbox( $(event.target).closest('.evo_lightbox') ); 192 //console.log('5'); 193 } 194 }); 195 function closing_lightbox( lightboxELM){ 196 197 if(! lightboxELM.hasClass('show')) return false; 198 Close = (lightboxELM.parent().find('.evo_lightbox.show').length == 1)? true: false; 199 lightboxELM.removeClass('show'); 200 201 $('body').trigger('lightbox_before_event_closing', [lightboxELM]); 202 203 setTimeout( function(){ 204 lightboxELM.find('.evo_lightbox_body').html(''); 205 206 if(Close){ 207 $('body').removeClass('evo_overflow'); 208 $('html').removeClass('evo_overflow'); 209 } 210 211 // trigger action to hook in at this stage 212 $('body').trigger('lightbox_event_closing', [lightboxELM]); 213 }, 500); 214 } 215 216 // when lightbox open triggered 217 $('body').on('evolightbox_show',function(){ 218 $('.evo_lightboxes').show(); 219 $('body').addClass('evo_overflow'); 220 $('html').addClass('evo_overflow'); 221 222 $('body').trigger('evolightbox_opened'); 223 }); 224 225 // OPENING event card -- USER INTREACTION and loading google maps 226 //event full description\ 227 $('body').on('click','.eventon_events_list .desc_trig', function(event){ 228 229 var obj = $(this); 230 231 var attr = obj.closest('.evo_lightbox').attr('data-cal_id'); 232 if(typeof attr !== typeof undefined && attr !== false){ 233 var cal_id = attr; 234 var CAL = cal = $('#'+cal_id); 235 }else{ 236 var CAL = cal = obj.closest('.ajde_evcal_calendar'); 237 } 238 239 SC = CAL.evo_shortcode_data(); 240 241 var evodata = cal.find('.evo-data'); 242 243 click_sinev_box = (obj.closest('.eventon_single_event').length>0 && evodata.data('exturl')) ? true: false; 244 event_id = obj.closest('.eventon_list_event').data('event_id'); 245 246 247 // whole calendar specific values 248 var cal_ux_val = SC.ux_val; 249 250 // event specific values 251 var ux_val = obj.data('ux_val'); 252 var exlk = obj.data('exlk'); 253 254 // override overall calendar user intereaction OVER individual event UX 255 if(cal_ux_val!='' && cal_ux_val!== undefined && cal_ux_val!='0'){ 256 ux_val = cal_ux_val; 257 } 258 259 //console.log(cal_ux_val+' '+ux_val); 260 // open as lightbox 261 if(ux_val=='3'){ 262 event.preventDefault(); 263 264 // set elements 265 EVO_LIGHTBOX = $('.evo_lightbox.eventcard'); 266 LIGHTBOX_body = EVO_LIGHTBOX.find('.evo_lightbox_body'); 267 268 repeat_interval = parseInt(obj.closest('.eventon_list_event').data('ri')); 269 repeat_interval = (repeat_interval)? repeat_interval: '0'; 270 271 // resets 272 EVO_LIGHTBOX.find('.evo_pop_body').show(); 273 fullheight_img_reset(); 274 LIGHTBOX_body.html(''); 275 276 var event_list = obj.closest('.eventon_events_list'); 277 var content = obj.closest('.eventon_list_event').find('.event_description').html(); 278 var content_front = obj.html(); 279 280 var _content = $(content).not('.evcal_close'); 281 282 // RTL 283 if(event_list.hasClass('evortl')){ 284 EVO_LIGHTBOX.find('.evo_popin').addClass('evortl'); 285 EVO_LIGHTBOX.addClass('evortl'); 286 } 287 288 LIGHTBOX_body.append('<div class="evopop_top">'+content_front+'</div>').append(_content); 289 LIGHTBOX_body.attr('class','evo_lightbox_body eventon_list_event evo_pop_body evcal_eventcard event_'+event_id +'_'+ repeat_interval); 290 291 var this_map = LIGHTBOX_body.find('.evcal_gmaps'); 292 var idd = this_map.attr('id'); 293 this_map.attr({'id':idd+'_evop'}); 294 295 EVO_LIGHTBOX.addClass('show'); 296 $('body').trigger('evolightbox_show'); 297 298 obj.evoGenmaps({ 299 '_action':'lightbox', 300 'cal':cal, 301 'mapSpotId':idd+'_evop' 302 }); 303 304 fullheight_img_reset(); // added second reset 305 306 // update border color 307 bgcolor = $('.evo_pop_body').find('.evcal_cblock').attr('data-bgcolor'); 308 $('.evo_pop_body').find('.evopop_top').css({'border-left':'3px solid '+bgcolor}); 309 310 // trigger 311 if( obj.data('runjs')){ 312 $('body').trigger('evo_load_single_event_content',[ event_id, obj]); 313 } 314 315 $('body').trigger('evolightbox_end'); 316 return false; 317 318 // open in single events page -- require single event addon 319 }else if(ux_val=='4'){ 320 321 if( obj.attr('href')!='' && obj.attr('href')!== undefined){ 322 return; 323 }else{ 324 var url = obj.parent().siblings('.evo_event_schema').find('a').attr('href'); 325 if(obj.attr('target') == '_blank'){ window.open(url);}else{ window.open(url, '_self');} 326 return false; 327 } 328 329 // open as external link 330 }else if(ux_val=='2'){ 331 //var url = obj.parent().siblings('.evo_event_schema').find('a').attr('href'); 332 var url = obj.attr('href'); 333 334 // if the click is coming from single event box 335 if( click_sinev_box ){ 336 event.preventDefault(); 337 return false; 338 } 339 340 //console.log(url); 341 if(url !== undefined && url != ''){ 342 if(obj.attr('target') == '_blank'){ 343 var win = window.open(url, '_blank'); 344 win.focus(); 345 }else{ 346 window.open(url, '_self'); 347 } 348 349 event.preventDefault(); 350 } 351 return true; 352 353 // do not do anything 354 }else if(ux_val=='X'){ 355 return false; 356 }else if(ux_val=='none'){ 357 return false; 358 }else{ 359 360 // redirecting to external link 361 if(exlk=='1' && ux_val!='1'){ 362 // if there is no href 363 if( obj.attr('href')!='' && obj.attr('href')!== undefined){ 364 return; 365 }else{ 366 var url = obj.siblings('.evo_event_schema').find('a').attr('href'); 367 if(obj.attr('target') == '_blank'){ window.open(url);}else{ window.open(url, '_self');} 368 369 event.preventDefault(); 370 return false; 371 } 372 // SLIDE DOWN eventcard 373 }else{ 374 375 var event_box = obj.closest('.eventon_list_event'); 376 var click_item = event_box.find('.event_description'); 377 378 if(click_item.hasClass('open')){ 379 event_box.removeClass('open'); 380 click_item.slideUp().removeClass('open'); 381 }else{ 382 // accordion 383 if( SC.accord == 'yes'){ 384 cal.find('.eventon_list_event').removeClass('open');
385 cal.find('.event_description').slideUp().removeClass('open'); 386 } 387 event_box.addClass('open'); 388 click_item.slideDown().addClass('open'); 389 } 390 391 // This will make sure markers and gmaps run once and not multiples 392 if( obj.attr('data-gmstat')!= '1'){ 393 obj.attr({'data-gmstat':'1'}); 394 obj.evoGenmaps({'fnt':2}); 395 } 396 397 // trigger 398 if( obj.data('runjs')){ 399 $('body').trigger('evo_load_single_event_content',[ event_id, obj]); 400 } 401 402 return false; 403 } 404 } 405 }); 406 407 // call to run google maps on load 408 function init_run_gmap_openevc(delay){ 409 $('.ajde_evcal_calendar').each(function(){ 410 SC = $(this).evo_shortcode_data(); 411 412 if( SC === undefined) return; 413 414 if( 'evc_open' in SC && SC.evc_open =='yes'){ 415 $(this).find('.desc_trig').each(function(){ 416 if(delay!='' && delay !== undefined){ 417 $(this).evoGenmaps({'fnt':2, 'delay':delay}); 418 }else{ 419 $(this).evoGenmaps({'fnt':2}); 420 } 421 }); 422 } 423 }); 424 } 425 426 // Calendar Interaction 427 // event bubbles 428 $('.ajde_evcal_calendar.bub').on('mouseover','.eventon_list_event', function(){ 429 O = $(this); 430 LIST = O.closest('.eventon_events_list'); 431 title = O.find('.evcal_event_title').html(); 432 433 p = O.position(); 434 435 LIST.append('<span class="evo_bub_box" style="">'+ title +"</span>"); 436 B = LIST.find('.evo_bub_box'); 437 438 l = p.left; 439 t = p.top- B.height() -30; 440 441 // adjust bubble to left if event on right edge 442 LM = LIST.width(); 443 tl = p.left + B.width() + O.width(); 444 if( tl > LM){ 445 l = l - B.width() +O.width()-20; 446 } 447 448 B.css({'top':t, 'left':l}); 449 450 LIST.find('.evo_bub_box').addClass('show'); 451 }).on('mouseout',function(){ 452 B = $(this).find('.evo_bub_box').remove(); 453 }); 454 455 // Click on eventtop items 456 $('body').on('click','.evocmd_button', function(event){ 457 event.preventDefault(); 458 event.stopPropagation(); 459 460 href = $(this).data('href'); 461 if( $(this).data('target')=='yes'){ 462 window.open(href,'_blank'); 463 }else{ 464 window.location = href; 465 } 466 467 }); 468 469 // GO TO TODAY 470 // @+ 2.3 @up 2.8 471 $('body').on('click','.evo-gototoday-btn', function(){ 472 var obj = $(this); 473 CAL = obj.closest('.ajde_evcal_calendar'); 474 var calid = CAL.attr('id'); 475 476 CAL.evo_update_cal_sc({F:'fixed_month', V: obj.data('mo')}); 477 CAL.evo_update_cal_sc({F:'fixed_year', V: obj.data('yr')}); 478 479 run_cal_ajax( calid,'none','today'); 480 obj.fadeOut(); 481 }); 482 483 $('body').on('evo_main_ajax_before', function(event, CAL, ajaxtype){ 484 if(ajaxtype == 'switchmonth') CAL.find('.evo-gototoday-btn').fadeIn(); 485 }); 486 $('body').on('evo_main_ajax_complete', function(event, CAL,ajaxtype, D , data_arg){ 487 // if focused month and year are same as current month and year hide the current month button 488 var N = moment().utc(); 489 SC = D.SC; 490 491 var SU = parseInt( SC.focus_start_date_range); 492 var M = moment.unix(SU).utc(); 493 494 if( N.format('YYYY M') == M.format('YYYY M')){ 495 CAL.find('.evo-gototoday-btn').fadeOut(); 496 } 497 498 }); 499 500 // MONTH jumper
501 $('.ajde_evcal_calendar').on('click','.evo-jumper-btn', function(){ 502 $(this).parent().siblings().find('.evo_j_container').slideToggle(); 503 }); 504 505 // select a new time from jumper 506 $('.evo_j_dates').on('click','a',function(){ 507 var val = $(this).attr('data-val'), 508 type = $(this).parent().parent().attr('data-val'), 509 CAL = $(this).closest('.ajde_evcal_calendar'); 510 SC = CAL.evo_shortcode_data(); 511 512 if(type=='m'){ // change month 513 CAL.evo_update_cal_sc({F:'fixed_month', V: val }); 514 }else{ 515 CAL.evo_update_cal_sc({F:'fixed_year', V: val }); 516 } 517 518 run_cal_ajax( CAL.attr('id') ,'none','jumper'); 519 520 // hide month jumper if not set to leave expanded 521 if(SC.expj =='no') container.delay(2000).slideUp(); 522 }); 523 524 // RESET general calendar 525 function cal_resets(calOBJ){ 526 calargs = $(calOBJ).find('.cal_arguments'); 527 calargs.attr('data-show_limit_paged', 1 ); 528 } 529 530 // close event card 531 $('.eventon_events_list').on('click','.evcal_close',function(){ 532 $(this).closest('.evcal_eventcard').slideUp().removeClass('open'); 533 }); 534 535 // change IDs for map section for eventon widgets 536 if( $('.ajde_evcal_calendar').hasClass('evcal_widget')){ 537 cal.find('.evcal_gmaps').each(function(){ 538 var gmap_id = obj.attr('id'); 539 var new_gmal_id =gmap_id+'_widget'; 540 obj.attr({'id':new_gmal_id}) 541 }); 542 } 543 544 // Tab view switcher 545 $('body').find('.evo_tab_container').each(function(){ 546 $(this).find('.evo_tab_section').each(function(){ 547 if(!$(this).hasClass('visible')){ 548 $(this).addClass('hidden'); 549 } 550 }); 551 }); 552 $('body').on('click','ul.evo_tabs li',function(){ 553 tab = $(this).data('tab'); 554 tabsection = $(this).closest('.evo_tab_view').find('.evo_tab_container'); 555 tabsection.find('.evo_tab_section').addClass('hidden').removeClass('visible'); 556 tabsection.find('.'+tab).addClass('visible').removeClass('hidden'); 557 558 $(this).parent().find('li').removeClass('selected'); 559 $(this).addClass('selected'); 560 }); 561 // layout view changer 562 if($('body').find('.evo_layout_changer').length>0){ 563 $('body').find('.evo_layout_changer').each(function(item){ 564 if($(this).parent().hasClass('boxy')){ 565 $(this).find('.fa-th-large').addClass('on'); 566 }else{ 567 $(this).find('.fa-reorder').addClass('on'); 568 } 569 }); 570 571 $('.evo_layout_changer').on('click','i',function(){ 572 TYPE = $(this).data('type'); 573 $(this).parent().find('i').removeClass('on'); 574 $(this).addClass('on'); 575 576 //console.log(TYPE); 577 578 if(TYPE=='row'){ 579 $(this).closest('.ajde_evcal_calendar').removeClass('boxy'); 580 }else{ 581 $(this).closest('.ajde_evcal_calendar').addClass('boxy'); 582 } 583 }); 584 } 585 586 // SORTING & FILTERING 587 // display sort section 588 $('.evo-filter-btn').click(function(){ 589 CAL = $(this).closest('.ajde_evcal_calendar'); 590 line = CAL.find('.eventon_sorting_section'); 591 if(line.is(':visible')){ 592 line.hide(); 593 $(this).removeClass('show'); 594 }else{ 595 line.show(); 596 $(this).addClass('show'); 597 } 598 // hide sort menu 599 CAL.find('.eventon_sort_line').hide(); 600 }); 601 602 // SORTing 603 $('.evo-sort-btn').click(function(){ 604 line = $(this).find('.eventon_sort_line'); 605 if(line.is(':visible')){ 606 line.hide(); 607 $(this).removeClass('show'); 608 }else{ 609 line.show(); 610 $(this).addClass('show'); 611 } 612 }); 613 614 // update calendar based on the sorting selection 615 $('.eventon_sort_line').on('click','p',function(){ 616 O = $(this); 617 var CAL = O.closest('.ajde_evcal_calendar'); 618 var sort_by = O.data('val'); 619 620 // update new values everywhere 621 CAL.evo_update_cal_sc({F:'sort_by',V:sort_by}); 622 623 O.parent().find('p').removeClass('select'); 624 O.addClass('select'); 625 626 run_cal_ajax(CAL.attr('id'),'none','sorting'); 627 }); 628 629 // filtering section open and close menu 630 $('.filtering_set_val').click(function(){ 631 // close sorting 632 sortSelect = $(this).closest('.eventon_sorting_section').find('.evo_srt_options'); 633 if(sortSelect.is(':visible') == true) sortSelect.fadeToggle(); 634 635 var obj = $(this); 636 var current_Drop = obj.siblings('.eventon_filter_dropdown'); 637 var current_drop_pare = obj.closest('.eventon_filter'); 638 639 current_drop_pare.siblings('.eventon_filter').find('.eventon_filter_dropdown').each(function(){ 640 if($(this).is(':visible')== true ){ 641 $(this).hide(); 642 $(this).siblings('p').removeClass('show'); 643 } 644 }); 645 646 if(current_Drop.is(':visible')== true){ 647 obj.siblings('.eventon_filter_dropdown').fadeOut('fast'); 648 obj.removeClass('show'); 649 }else{ 650 obj.siblings('.eventon_filter_dropdown').fadeIn('fast'); 651 obj.addClass('show'); 652 } 653 }); 654 655 // selection on filter dropdown list 656 $('.eventon_filter_dropdown').on('click','p',function(){ 657 var new_filter_val = $(this).data('filter_val'), 658 O = $(this), 659 filter_section = $(this).closest('.eventon_filter_line'); 660 var filter = $(this).closest('.eventon_filter');
661 var filter_current_set_val = filter.data('filter_val'); 662 var select_filter_type = filter_section.hasClass('selecttype')? true:false; 663 FILTER_DROPDOWN = $(this).parent(); 664 CAL = $(this).closest('.ajde_evcal_calendar'); 665 666 // for filter values with checkboxes 667 if(select_filter_type){ 668 val = ''; 669 670 // NOT all 671 if( new_filter_val != 'all'){ 672 O.parent().find('p.all').removeClass('select'); 673 O.toggleClass('select'); 674 675 var unselect_count = 0; 676 O.parent().find('p').each(function(){ 677 if( $(this).hasClass('select')){ 678 val += $(this).data('filter_val')+','; 679 }else{ 680 if(!$(this).hasClass('all')) unselect_count++; 681 } 682 }); 683 684 // all selected 685 if(unselect_count == 0){ 686 O.parent().find('p.all').addClass('select'); 687 val = 'all'; 688 } 689 690 // remove comma at the end 691 val = ( val.slice(-1) == ',')? val.slice(0,-1): val; 692 693 // if all field is not visible; nothing selected = all 694 if(val == '' && O.parent().find('p.all').length == 0) val='all'; 695 696 // == all 697 }else{ 698 if( O.hasClass('select')){ 699 O.parent().find('p').removeClass('select'); 700 }else{ 701 O.parent().find('p').addClass('select'); 702 val = 'all'; 703 } 704 } 705 706 filter.data('filter_val',val); // v 2.7.4 707 708 // regular selecting 709 }else{ 710 if( new_filter_val == 'all'){ 711 O.parent().find('p').addClass('select'); 712 }else{ 713 O.parent().find('p').removeClass('select'); 714 O.addClass('select'); 715 } 716 } 717 if(filter_section.hasClass('selecttype')) return; 718 719 720 // For non checkbox select options 721 if(filter_current_set_val == new_filter_val){ 722 $(this).parent().fadeOut(); 723 }else{ 724 cal_resets( CAL ); 725 726 // make changes 727 filter.data('filter_val', new_filter_val); 728 729 CAL.evo_update_sc_from_filters(); 730 731 run_cal_ajax( CAL.attr('id') ,'none','filering'); 732 733 // reset the new values 734 var new_filter_name = $(this).html(); 735 736 O.parent().fadeOut(); 737 O.parent().siblings('.filtering_set_val').removeClass('show'); 738 } 739 }); 740 741 // apply filters via button to the calendar 742 $('.eventon_filter_dropdown').on('change','input',function(event){ 743 FILTER = $(this).closest('.eventon_filter'); 744 745 val = ''; 746 FILTER.find('input').each(function(){ 747 val = ($(this).is(':checked'))? val + $(this).data('filter_val') +',': val; 748 }); 749 val = (val=='')? '':val; // v2.5.2 750 FILTER.data('filter_val',val); // v 2.7.4 751 }); 752 // apply filters 753 $('body').on('click','.evo_filter_submit',function(){ 754 // fadeout any open filter dropdowns 755 $(this).closest('.eventon_filter_line').find('.eventon_filter_dropdown').fadeOut(); 756 $(this).closest('.eventon_filter_line').find('.filtering_set_val').removeClass('show'); 757 758 CAL = $(this).closest('.ajde_evcal_calendar'); 759 cal_resets( CAL); 760 761 CAL.evo_update_sc_from_filters(); // update shortcode from filters 762 763 run_cal_ajax(CAL.attr('id'),'none','filering'); 764 }); 765 766 // CAL BODY Listeners 767 $('body') 768 // Show more events on list 769 .on('click','.evoShow_more_events', function(){ 770 CAL = $(this).closest('.ajde_evcal_calendar'); 771 SC = CAL.evo_shortcode_data(); 772 773 OBJ = $(this); 774 775 // redirect to an external link 776 if(SC.show_limit_redir !== ''){
777 window.location = SC.show_limit_redir; return false; 778 } 779 780 // ajax pagination 781 if( SC.show_limit_ajax =='yes'){ 782 CURRENT_PAGED = parseInt(SC.show_limit_paged); 783 CAL.evo_update_cal_sc({F:'show_limit_paged', V: CURRENT_PAGED+1}); 784 run_cal_ajax( CAL.attr('id'), 'none','paged'); 785 786 }else{ 787 var event_count = parseInt( SC.event_count ); 788 789 var eventList = OBJ.parent(); 790 var allEvents = eventList.find('.eventon_list_event').length; 791 792 var currentShowing = eventList.find('.eventon_list_event:visible').length; 793 794 for(x=1; x<=event_count ; x++ ){ 795 var inde = currentShowing+x-1; 796 eventList.find('.eventon_list_event:eq('+ inde+')').slideDown(); 797 } 798 799 // hide view more button 800 if(allEvents > currentShowing && allEvents<= (currentShowing+event_count)){ 801 $(this).fadeOut(); 802 } 803 } 804 805 }) 806 // MONTH switch 807 .on('click','.evcal_btn_prev', function(){ 808 cal_id = $(this).closest('.ajde_evcal_calendar').attr('id'); 809 run_cal_ajax(cal_id,'prev','switchmonth'); 810 }) 811 .on('click','.evcal_btn_next',function(){ 812 cal_id = $(this).closest('.ajde_evcal_calendar').attr('id'); 813 run_cal_ajax( cal_id,'next','switchmonth'); 814 }) 815 816 // JUMPER switch 817 .on('calendar_month_changed',function(event, CAL){ 818 SC = CAL.evo_shortcode_data(); 819 820 var O = CAL.find('.evo_j_container'); 821 O.find('.evo_j_months a').removeClass('set'); 822 O.find('.evo_j_months a[data-val="'+ SC.fixed_month +'"]').addClass('set'); 823 824 O.find('.evo_j_years a').removeClass('set'); 825 O.find('.evo_j_years a[data-val="'+ SC.fixed_year +'"]').addClass('set'); 826 827 // show go to today 828 B = CAL.find('.evo-gototoday-btn'); 829 if( SC.fixed_month != B.data('mo') || SC.fixed_year != B.data('yr')){ 830 B.show(); 831 } 832 }) 833 834 // View Switcher 835 .on('click', '.evo_vSW',function(){ 836 O = $(this); 837 if(O.hasClass('focus')) return; 838 O.siblings('.evo_vSW').removeClass('focus'); 839 O.addClass('focus'); 840 CAL = O.closest('.ajde_evcal_calendar'); 841 CAL.find('.evoADDS').fadeOut().delay(200).queue(function(){ 842 $(this).remove(); 843 }); 844 845 if(O.hasClass('evoD')){ 846 CAL.evo_update_cal_sc({F:'calendar_type', V: 'default'}); 847 //SC = CAL.evo_shortcode_data(); 848 CAL.find('#evcal_list').removeClass('evo_hide'); 849 CAL.find('.eventon_list_event').show(); 850 } 851 852 $('body').trigger('evo_vSW_clicked', [ O, CAL]); 853 }) 854 // show more/less event details 855 .on('click','.eventon_shad_p',function(){ 856 control_more_less( $(this)); 857 }) 858 ; 859 860 861 // PRIMARY hook to get content 862 // MAIN AJAC for calendar events v2.8 863 function run_cal_ajax( cal_id, direction, ajaxtype){ 864 865 // identify the calendar and its elements. 866 var CAL = ev_cal = $('#'+cal_id); 867 868 // check if ajax post content should run for this calendar or not 869 if(CAL.attr('data-runajax')!='0'){ 870 871 // category filtering for the calendar 872 var cat = CAL.find('.evcal_sort').attr('cat'); 873 874 // reset paged values for switching months 875 if(ajaxtype=='switchmonth'){ 876 CAL.find('.cal_arguments').attr('data-show_limit_paged',1); 877 CAL.evo_update_cal_sc({F:'show_limit_paged', V: '1'}); 878 } 879 880 SC = CAL.evo_shortcode_data(); 881 882 $('body').trigger('evo_main_ajax_before', [CAL, ajaxtype, direction, SC]); 883 884 var data_arg = { 885 action: 'the_ajax_hook', 886 direction: direction, 887 shortcode: SC, 888 ajaxtype: ajaxtype, 889 }; 890 891 EVENTS_LIST = ev_cal.find('.eventon_events_list'); 892 893 $.ajax({
894 beforeSend: function(){ 895 ev_cal.addClass('evo_loading'); 896 if(ajaxtype != 'paged') EVENTS_LIST.slideUp('fast'); 897 898 if(ajaxtype == 'paged'){ 899 txt = EVENTS_LIST.find('.evoShow_more_events').html(); 900 EVENTS_LIST.find('.evoShow_more_events').html('. . .').data('txt',txt); 901 } 902 ev_cal.evo_loader_animation(); 903 }, 904 type: 'POST', 905 url:the_ajax_script.ajaxurl, 906 data: data_arg, 907 dataType:'json', 908 success:function(data){ 909 if(!data) return false; 910 if(ajaxtype == 'paged'){ 911 EVENTS_LIST.find('.evoShow_more_events').remove(); 912 EVENTS_LIST.find('.clear').remove(); 913 914 915 EVENTS_LIST.append( data.html + "<div class='clear'></div>"); 916 917 // hide show more events if all events loaded 918 var events_in_list = EVENTS_LIST.find('.eventon_list_event').length; 919 if( 'total_events' in data && data.total_events == events_in_list){ 920 EVENTS_LIST.find('.evoShow_more_events').hide(); 921 } 922 923 // for month lists duplicate headers // @+2.8.1 924 var T = {}; 925 EVENTS_LIST.find('.evcal_month_line').each(function(){ 926 d = $(this).data('d'); 927 if( T[d]) 928 $(this).remove(); 929 else 930 T[d] = true; 931 }); 932 933 var T = {}; 934 EVENTS_LIST.find('.sep_month_events').each(function(){ 935 d = $(this).data('d'); 936 if( T[d]){ 937 var H = $(this).html(); 938 EVENTS_LIST.find('.sep_month_events[data-d="'+d+'"]').append( H ); 939 $(this).remove(); 940 }else{T[d] = true;} 941 }); 942 943 }else{ 944 EVENTS_LIST.html(data.html); 945 } 946 947 // update calednar month title 948 animate_month_switch(data.cal_month_title, ev_cal.find('#evcal_cur')); 949 950 // update calendar shortcode values after ajax 951 ev_cal.evo_update_all_cal_sc({SC: data.SC}); 952 953 // update events list to calendar footer data 954 ev_cal.find('.evo_cal_events').data('events', data.json); 955 956 $('body').trigger('calendar_month_changed',[CAL]); 957 958 $('body').trigger('evo_main_ajax_success', [CAL, ajaxtype, data, data_arg]); 959 960 },complete:function(data){ 961 ev_cal.evo_loader_animation({direction:'end'}); 962 963 // show events list events if not set to hide on load 964 if(! EVENTS_LIST.hasClass('evo_hide')) EVENTS_LIST.delay(300).slideDown('slow'); 965 966 ev_cal.evoGenmaps({'delay':400}); 967 init_run_gmap_openevc(600); 968 fullheight_img_reset(cal_id); 969 970 // pluggable 971 $('body').trigger('evo_main_ajax_complete', [CAL, ajaxtype, data.responseJSON , data_arg]); 972 ev_cal.removeClass('evo_loading'); 973 } 974 }); 975 } 976 } 977 978 $('body').on('evo_run_cal_ajax',function(event,cal_id, direction, ajaxtype){ 979 run_cal_ajax( cal_id, direction, ajaxtype); 980 }); 981 982 // deprecated bridge function for sortby value 983 function ajax_post_content(sortby, cal_id, direction, ajaxtype){ 984 run_cal_ajax( cal_id, direction, ajaxtype); 985 } 986 987 // subtle animation when switching months 988 function animate_month_switch(new_data, title_element){ 989 var current_text = title_element.html(); 990 var hei = title_element.height(); 991 var wid= title_element.width(); 992 993 title_element.html("<span style='position:absolute; width:"+wid+"; height:"+hei+" ;'>"+current_text+"</span><span style='position:absolute; display:none;'>"+new_data+"</span>").width(wid); 994 995 title_element.find('span:first-child').fadeOut(800); 996 title_element.find('span:last-child').fadeIn(800, function(){ 997 title_element.html(new_data).width(''); 998 }); 999 } 1000 1001 1002 // actual animation/function for more/less button 1003 function control_more_less(obj){ 1004 var content = obj.attr('content'); 1005 var current_text = obj.find('.ev_more_text').html(); 1006 var changeTo_text = obj.find('.ev_more_text').attr('data-txt'); 1007 1008 if(content =='less'){ 1009 1010 var hei = obj.parent().siblings('.eventon_full_description').height(); 1011 var orhei = obj.closest('.evcal_evdata_cell').height(); 1012 1013 obj.closest('.evcal_evdata_cell').attr({'orhei':orhei}
1013).animate({height: (parseInt(hei)+40) }); 1014 1015 obj.attr({'content':'more'}); 1016 obj.find('.ev_more_arrow').addClass('less'); 1017 obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text); 1018 1019 }else{ 1020 var orhei = parseInt(obj.closest('.evcal_evdata_cell').attr('orhei')); 1021 1022 obj.closest('.evcal_evdata_cell').animate({height: orhei }); 1023 1024 obj.attr({'content':'less'}); 1025 obj.find('.ev_more_arrow').removeClass('less'); 1026 obj.find('.ev_more_text').attr({'data-txt':current_text}).html(changeTo_text); 1027 } 1028 } 1029 1030 // expand and shrink featured image 1031 $('body').on('click','.evcal_evdata_img',function(){ 1032 if(!$(this).hasClass('evo_noclick')){ 1033 feature_image_expansion($(this), 'click'); 1034 } 1035 }); 1036 1037 // featured image height processing 1038 function feature_image_expansion(image, type){ 1039 img = image; 1040 1041 var img_status = img.attr('data-status'); 1042 var img_style = img.attr('data-imgstyle'); 1043 1044 // if image already expanded 1045 if(img_status=='open' ){ 1046 img.attr({'data-status':'close'}).css({'height':''}); 1047 }else{ 1048 var img_full_height = parseInt(img.attr('data-imgheight')); 1049 var cal_width = parseInt(img.closest('.ajde_evcal_calendar').width()); 1050 cal_width = (cal_width)? cal_width: img.width(); 1051 var img_full_width = parseInt(img.attr('data-imgwidth')); 1052 1053 1054 // show at minimized height 1055 if(img_style=='100per'){ 1056 relative_height = img_full_height; 1057 }else if(img_style=='full'){ 1058 relative_height = parseInt(img_full_height * (cal_width/img_full_width)) ; 1059 }else{ 1060 // minimized version 1061 if(type=='click'){ 1062 relative_height = parseInt(img_full_height * (cal_width/img_full_width)); 1063 relative_height = (relative_height)? relative_height: img_full_height; 1064 1065 relative_height = parseInt((cal_width * img_full_height) /img_full_width); 1066 1067 //console.log(relative_height+ ' '+img_full_height+' '+cal_width); 1068 1069 }else{ 1070 relative_height = img.attr('data-minheight'); 1071 } 1072 } 1073 1074 // when to set the status as open for images 1075 if(img_status=='' && img_style=='minmized'){ 1076 img.attr({'data-status':'close'}).removeClass('expanded'); 1077 }else{ 1078 img.attr({'data-status':'open'}).addClass('expanded'); 1079 } 1080 img.css({'height':relative_height}); 1081 } 1082 } 1083 1084 // reset featured images based on settings 1085 function fullheight_img_reset(calid){ 1086 if(calid){ 1087 $('#'+calid).find('.eventon_list_event .evo_metarow_fimg').each(function(){ 1088 feature_image_expansion($(this)); 1089 }); 1090 }else{ 1091 $('.evo_metarow_fimg').each(function(){ 1092 feature_image_expansion($(this)); 1093 }); 1094 } 1095 } 1096 1097 // treatments for calendar events upon load 1098 function treat_events(calid){ 1099 if(calid!=''){ 1100 if(is_mobile()){ 1101 $('#'+calid).find('.evo_metarow_getDr form').attr({'target':'_self'}); 1102 } 1103 } 1104 } 1105 1106 // if mobile check 1107 function is_mobile(){ 1108 return ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )? true: false; 1109 } 1110 1111 // edit event button redirect 1112 $('body').on('click','.editEventBtnET', function(event){ 1113 event.stopPropagation(); 1114 1115 href = $(this).attr('href'); 1116 //console.log(href); 1117 window.open(href); 1118 }); 1119 1120 // repeat events series 1121 // @u 2.6.9 1122 $('body').on('click','.evo_repeat_series_date',function(){ 1123 if( $(this).parent().data('click') ){ 1124 URL = $(this).data('l'); 1125 window.location = URL; 1126 } 1127 }); 1128 1129 // event location archive card page 1130 // @u 2.6.11 1131 $('body').find('.evo_location_map').each(function(){ 1132 THIS = $(this); 1133 MAPID = THIS.attr('id'); 1134 1135 var location_type = THIS.attr('data-location_type'); 1136 if(location_type=='add'){ 1137 var address = THIS.attr('data-address'); 1138 var location_type = 'add'; 1139 }else{ 1140 var address = THIS.attr('data-latlng'); 1141 var location_type = 'latlng'; 1142 } 1143 1144 // zoomlevel 1145 zoom = parseInt(THIS.data('zoom')); 1146 scrollwheel = THIS.data('scroll') == 'yes'? true: false; 1147 1148 initialize( 1149 MAPID, 1150 address, 1151 THIS.data('mty'), 1152 zoom, 1153 location_type, 1154 scrollwheel 1155 ); 1156 }); 1157 1158 // SINGLE EVENTS 1159 // Loading single event json based content 1160 $('body').on('evo_load_single_event_content', function(event, eid, obj){ 1161 var ajaxdataa = {};
1162 ajaxdataa['action']='eventon_load_event_content'; 1163 ajaxdataa['eid'] = eid; 1164 ajaxdataa['nonce'] = the_ajax_script.postnonce; 1165 1166 // pass on other event values 1167 if(obj.data('j')){ 1168 $.each(obj.data('j'), function(index,val){ 1169 ajaxdataa[ index] = val; 1170 }); 1171 } 1172 1173 $.ajax({ 1174 beforeSend: function(){ }, 1175 url: the_ajax_script.ajaxurl, 1176 data: ajaxdataa, dataType:'json', type: 'POST', 1177 success:function(data){ 1178 $('body').trigger('evo_single_event_content_loaded', [data, obj]); 1179 },complete:function(){ } 1180 }); 1181 }); 1182 1183 if(is_mobile()){ 1184 if($('body').find('.fb.evo_ss').length != 0){ 1185 $('body').find('.fb.evo_ss').each(function(){ 1186 obj = $(this); 1187 obj.attr({'href':'http://m.facebook.com/sharer.php?u='+obj.attr('data-url')}); 1188 }); 1189 } 1190 } 1191 1192 // on single event page 1193 if($('body').find('.evo_sin_page').length>0){ 1194 $('.evo_sin_page').each(function(){ 1195 $('body').trigger('evo_load_single_event_content',[ $(this).data('eid'), $(this)]); 1196 $(this).find('.desc_trig ').attr({'data-ux_val':'none'}); 1197 }); 1198 } 1199 1200 // Single events box 1201 // Click on single event box 1202 $('.eventon_single_event').on('click', '.evcal_list_a',function(event){ 1203 var obj = $(this); 1204 var CAL = obj.closest('.ajde_evcal_calendar'); 1205 var SC = CAL.evo_shortcode_data(); 1206 1207 event.preventDefault(); 1208 1209 // open in event page 1210 if(SC.ux_val == 4){ 1211 var url = obj.parent().siblings('.evo_event_schema').find('[itemprop=url]').attr('href'); 1212 window.location.href= url; 1213 }else if(SC.ux_val == '2'){ // External Link 1214 var url = SC.exturl; 1215 window.location.href= url; 1216 }else if(SC.ux_val == 'X'){ // do not do anything 1217 return false; 1218 } 1219 }); 1220 // each single event box 1221 $('body').find('.eventon_single_event').each(function(){ 1222 var _this = $(this); 1223 1224 var CAL = _this.closest('.ajde_evcal_calendar'); 1225 var SC = CAL.evo_shortcode_data(); 1226 var evObj = CAL.find('.eventon_list_event'); 1227 1228 // show expanded eventCard 1229 if( SC.expanded =='yes'){ 1230 _this.find('.evcal_eventcard').show(); 1231 var idd = _this.find('.evcal_gmaps'); 1232 1233 // close button 1234 _this.find('.evcal_close').parent().css({'padding-right':0}); 1235 _this.find('.evcal_close').hide(); 1236 1237 //console.log(idd); 1238 var obj = _this.find('.desc_trig'); 1239 1240 obj.evoGenmaps({'fnt':2}); 1241 1242 // open eventBox and lightbox 1243 }else if(SC.uxval =='3'){ 1244 1245 var obj = _this.find('.desc_trig'); 1246 // remove other attr - that cause to redirect 1247 obj.removeAttr('data-exlk').attr({'data-ux_val':'3'}); 1248 } 1249 1250 // show event excerpt 1251 var ev_excerpt = CAL.find('.event_excerpt').html(); 1252 1253 if(ev_excerpt!='' && ev_excerpt!== undefined && SC.excerpt =='yes' ){ 1254 var appendation = '<div class="event_excerpt_in">'+ev_excerpt+'</div>' 1255 evObj.append(appendation); 1256 } 1257 }); 1258 1259 1260 // HELPER items script 1261 // yes no button 1262 $('body').on('click','.ajde_yn_btn ', function(){ 1263 var obj = $(this); 1264 var afterstatement = obj.attr('afterstatement'); 1265 afterstatement = (afterstatement === undefined)? obj.attr('data-afterstatement'): afterstatement; 1266 // yes 1267 if(obj.hasClass('NO')){ 1268 obj.removeClass('NO'); 1269 obj.siblings('input').val('yes'); 1270 1271 // afterstatment 1272 if(afterstatement!=''){ 1273 var type = (obj.attr('as_type')=='class')? '.':'#'; 1274 $(type+ afterstatement).addClass('tt').slideDown('fast'); 1275 } 1276 1277 }else{//no 1278 obj.addClass('NO'); 1279 obj.siblings('input').val('no'); 1280 1281 if(afterstatement!=''){ 1282 var type = (obj.attr('as_type')=='class')? '.':'#'; 1283 $(type+ afterstatement ).slideUp('fast'); 1284 } 1285 } 1286 }); 1287 1288// Search Scripts 1289 // Enter key detection for pc 1290 $.fn.evo_enterKey = function (fnc) { 1291 return this.each(function () { 1292 $(this).keypress(function (ev) { 1293 var keycode = (ev.keyCode ? ev.keyCode : ev.which); 1294 if (keycode == '13') { 1295 fnc.call(this, ev); 1296 } 1297 }) 1298 }) 1299 } 1300 1301 $('.evo-search').on('click',function(){ 1302 var section = $(this).closest('.calendar_header'); 1303 var item = section.find('.evo_search_bar'); 1304 1305 item.slideToggle('2000', function(){ 1306 if(item.is(':visible')) item.find('input').focus(); 1307 }); 1308 }); 1309 1310 // Submit search from search box 1311 $('body').on('click','.evo_do_search',function(){ 1312 do_search_box( $(this) ); 1313 }); 1314 1315 $(".evosr_search_box input").evo_enterKey(function () { 1316 do_search_box( $(this).siblings('.evo_do_search') ); 1317 }); 1318 1319 function do_search_box(OBJ){ 1320 SearchVal = OBJ.closest('.evosr_search_box').find('input').val(); 1321 Evosearch = OBJ.closest('.EVOSR_section'); 1322 OBJ.closest('.evo_search_entry').find('.evosr_msg').hide(); 1323 //console.log(SearchVal); 1324 1325 if( SearchVal === undefined || SearchVal == ''){ 1326 OBJ.closest('.evo_search_entry').find('.evosr_msg').show(); 1327 return false; 1328 } 1329 SC = Evosearch.find('span.data').evo_item_shortcodes(); 1330 1331 var data_arg = { 1332 action: 'eventon_search_evo_events', 1333 search: SearchVal, 1334 shortcode: SC 1335 }; 1336 $.ajax({
1337 beforeSend: function(){ 1338 Evosearch.find('.evo_search_results_count').hide(); 1339 Evosearch.addClass('searching'); 1340 }, 1341 type: 'POST', 1342 url:the_ajax_script.ajaxurl, 1343 data: data_arg, 1344 dataType:'json', 1345 success:function(data){ 1346 Evosearch.find('.evo_search_results').html( data.content); 1347 1348 if(Evosearch.find('.no_events').length>0){ 1349 1350 }else{ 1351 // find event count 1352 Events = Evosearch.find('.evo_search_results').find('.eventon_list_event').length; 1353 Evosearch.find('.evo_search_results_count span').html( Events); 1354 Evosearch.find('.evo_search_results_count').fadeIn(); 1355 } 1356 1357 },complete: function(){ 1358 Evosearch.removeClass('searching'); 1359 } 1360 }); 1361 } 1362 1363 // submit search from calendar 1364 $('body').on('click','.evosr_search_btn',function(){ search_within_calendar( $(this).siblings('input') ); }); 1365 $(".evo_search_bar_in input").evo_enterKey(function () { search_within_calendar( $(this) ); }); 1366 1367 function search_within_calendar(obj){ 1368 1369 var ev_cal = obj.closest('.ajde_evcal_calendar'); 1370 1371 ev_cal.evo_update_cal_sc({F:'s',V: obj.val() }); 1372 1373 run_cal_ajax( ev_cal.attr('id'),'none','search'); 1374 1375 return false; 1376 } 1377 1378 1379 // More event images interaction 1380 $('body').on('click','.evo_event_more_img',function(){ 1381 var O = $(this); 1382 var eCARD = O.closest('.evcal_eventcard'); 1383 var fIMG = O.find('img'); 1384 var fURL = fIMG.data('f'); 1385 1386 O.parent().find('span').removeClass('select'); O.addClass('select'); 1387 1388 eCARD.find('img.evo_event_main_img').attr({'src': fURL}); 1389 1390 relIMG = eCARD.find('.evo_metarow_fimg'); 1391 relIMG.css('background-image', 'url('+ fURL +')' ); 1392 relIMG.data('imgheight', fIMG.data('h')); 1393 }); 1394 1395});
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.