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