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