1 2 3function nitroThumb(e) { 4 return ( 5 '<img src="' + document.getElementById(e).getAttribute("data-thumb") + '" alt="' + document.getElementById(e).getAttribute("data-thumbalt") + '">' 6 ).replace("ID", e) + '<a href="#" class="et_pb_video_play"></a>' 7 } 8 9 function machineYoutubeFrame(event) { 10 event.preventDefault(); 11 var iframe = document.createElement("iframe"); 12 iframe.setAttribute( 13 "src", 14 "https://www.youtube.com/embed/" + this.dataset.id + "?autoplay=1&mute=1&enablejsapi=1" 15 ); 16 iframe.setAttribute("frameborder", "0"); 17 iframe.setAttribute("allowfullscreen", "1"); 18 iframe.setAttribute("allow", "autoplay; fullscreen"); 19 20 // Create wrapper just like fitVids 21 var wrapper = document.createElement("div"); 22 wrapper.className = "fluid-width-video-wrapper"; 23 wrapper.style.paddingTop = "56.25%"; 24 25 // Style iframe like fitVids does 26 iframe.style.position = "absolute"; 27 iframe.style.top = "0"; 28 29 wrapper.appendChild(iframe); 30 31 // Replace the thumbnail container with the wrapped iframe 32 this.parentNode.replaceWith(wrapper); 33 } 34 35 function machineVimeoFrame(event) { 36 event.preventDefault(); 37 38 var e = document.createElement("iframe"); 39 var videoId = this.dataset.id; 40 41 e.setAttribute("src", "https://player.vimeo.com/video/" + videoId + "?autoplay=1&muted=1"); 42 e.setAttribute("frameborder", "0"); 43 e.setAttribute("allow", "autoplay; fullscreen"); 44 e.setAttribute("allowfullscreen", "1"); 45 46 this.parentNode.replaceChild(e, this); 47 } 48 49 function initializeVideoListeners() { 50 var e, t, r = document.getElementsByClassName("de_demach_youtube_listener"); 51 for (t = 0; t < r.length; t++) { 52 // Skip if already initialized 53 if (r[t].classList.contains('de_video_initialized')) continue; 54 r[t].classList.add('de_video_initialized'); 55 56 e = document.createElement("div"); 57 e.setAttribute("data-id", r[t].dataset.id); 58 e.innerHTML = nitroThumb(r[t].dataset.id); 59 e.onclick = machineYoutubeFrame; 60 r[t].appendChild(e); 61 } 62 63 r = document.getElementsByClassName("de_demach_vimeo_listener"); 64 for (t = 0; t < r.length; t++) { 65 // Skip if already initialized 66 if (r[t].classList.contains('de_video_initialized')) continue; 67 r[t].classList.add('de_video_initialized'); 68 69 e = document.createElement("div"); 70 e.setAttribute("data-id", r[t].dataset.id); 71 e.innerHTML = nitroThumb(r[t].dataset.id); 72 e.onclick = machineVimeoFrame; 73 r[t].appendChild(e); 74 } 75 } 76 77 document.addEventListener("DOMContentLoaded", function() { 78 initializeVideoListeners(); 79 }); 80 81 // Reinitialize listeners when the AJAX filter completes 82 jQuery(document).on('divi_filter_completed', function() { 83 initializeVideoListeners(); 84 }); 85 86 // Reinitialize listeners when modal content loads 87 jQuery(document).on('divi_machine_modal_loaded', function() { 88 initializeVideoListeners(); 89 }); 90 91 // Function to pause all videos in a modal 92 function pauseAllVideosInModal($modal) { 93 if (!$modal || !$modal.length) { 94 console.log('pauseAllVideosInModal: No modal found'); 95 return; 96 } 97 98 // Also check inside post-modal-cont and other nested containers 99 var $searchContainer = $modal.find('.post-modal-cont').length ? $modal.find('.post-modal-cont') : $modal; 100 101 var videoCount = $searchContainer.find('video').length; 102 var youtubeCount = $searchContainer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').length; 103 var vimeoCount = $searchContainer.find('iframe[src*="vimeo.com"]').length; 104 105 console.log('pauseAllVideosInModal: Found', videoCount, 'HTML5 videos,', youtubeCount, 'YouTube iframes,', vimeoCount, 'Vimeo iframes'); 106 107 // Pause HTML5 video elements 108 $searchContainer.find('video').each(function() { 109 try { 110 if (this.pause) { 111 this.pause(); 112 } 113 } catch (e) { 114 console.log('Could not pause HTML5 video:', e); 115 } 116 }); 117 118 // Pause YouTube iframes (check in modal and nested containers
118) 119 $searchContainer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').each(function() { 120 var iframe = this; 121 var originalSrc = iframe.src; 122 123 if (!originalSrc) { 124 console.log('pauseAllVideosInModal: YouTube iframe has no src'); 125 return; 126 } 127 128 console.log('pauseAllVideosInModal: Attempting to pause YouTube video:', originalSrc); 129 130 try { 131 // Method 1: Try postMessage API (works if enablejsapi=1 is in URL) 132 if (iframe.contentWindow && originalSrc.indexOf('enablejsapi=1') !== -1) { 133 console.log('pauseAllVideosInModal: Using postMessage for YouTube'); 134 iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 135 // Also try stopVideo for good measure 136 iframe.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*'); 137 } else { 138 console.log('pauseAllVideosInModal: enablejsapi not found, modifying src'); 139 // Method 2: For videos without enablejsapi, we need to modify src to stop playback 140 // Extract video ID and rebuild URL without autoplay 141 var videoIdMatch = originalSrc.match(/(?:youtube\.com\/embed\/|youtu\.be\/)([^?&]+)/
141); 142 if (videoIdMatch && videoIdMatch[1]) { 143 var videoId = videoIdMatch[1]; 144 // Rebuild URL with autoplay=0 to stop the video 145 var newSrc = 'https://www.youtube.com/embed/' + videoId + '?autoplay=0&enablejsapi=1'; 146 iframe.src = newSrc; 147 console.log('pauseAllVideosInModal: Modified YouTube src to:', newSrc); 148 } else { 149 // Fallback: just remove autoplay 150 var modifiedSrc = originalSrc.replace(/[?&]autoplay=\d+/gi, ''); 151 modifiedSrc += (modifiedSrc.indexOf('?') === -1 ? '?' : '&') + 'autoplay=0'; 152 iframe.src = modifiedSrc; 153 console.log('pauseAllVideosInModal: Modified YouTube src (fallback) to:', modifiedSrc); 154 } 155 } 156 } catch (e) { 157 console.log('Could not pause YouTube video:', e); 158 // Last resort: try to stop by rebuilding src 159 try { 160 var videoIdMatch = originalSrc.match(/(?:youtube\.com\/embed\/|youtu\.be\/)([^?&]+)/); 161 if (videoIdMatch && videoIdMatch[1]) { 162 iframe.src = 'https://www.youtube.com/embed/' + videoIdMatch[1] + '?autoplay=0'; 163 } 164 } catch (e2) { 165 console.log('Failed to stop YouTube video:', e2); 166 } 167 } 168 }); 169 170 // Pause Vimeo iframes (check in modal and nested containers) 171 $searchContainer.find('iframe[src*="vimeo.com"]').each(function() { 172 var iframe = this; 173 var originalSrc = iframe.src; 174 175 if (!originalSrc) { 176 console.log('pauseAllVideosInModal: Vimeo iframe has no src'); 177 return; 178 } 179 180 console.log('pauseAllVideosInModal: Attempting to pause Vimeo video:', originalSrc); 181 182 try { 183 // Method 1: Try postMessage API 184 if (iframe.contentWindow) { 185 console.log('pauseAllVideosInModal: Using postMessage for Vimeo'); 186 iframe.contentWindow.postMessage('{"method":"pause"}', '*'); 187 } 188 189 // Method 2: Modify src to remove autoplay (rebuild URL to ensure it stops) 190 var videoIdMatch = originalSrc.match(/vimeo\.com\/video\/([^?&]+)/); 191 if (videoIdMatch && videoIdMatch[1]) { 192 var videoId = videoIdMatch[1]; 193 // Rebuild URL with autoplay=0 to stop the video 194 var newSrc = 'https://player.vimeo.com/video/' + videoId + '?autoplay=0'; 195 if (originalSrc.indexOf('muted') !== -1) { 196 newSrc += '&muted=1'; 197 } 198 iframe.src = newSrc; 199 console.log('pauseAllVideosInModal: Modified Vimeo src to:', newSrc); 200 } else { 201 // Fallback: just modify autoplay 202 var modifiedSrc = originalSrc.replace(/[?&]autoplay=\d+/gi, ''); 203 modifiedSrc += (modifiedSrc.indexOf('?') === -1 ? '?' : '&') + 'autoplay=0'; 204 iframe.src = modifiedSrc; 205 console.log('pauseAllVideosInModal: Modified Vimeo src (fallback) to:', modifiedSrc); 206 } 207 } catch (e) { 208 console.log('Could not pause Vimeo video:', e); 209 // Last resort: try to stop by rebuilding src 210 try { 211 var videoIdMatch = originalSrc.match(/vimeo\.com\/video\/([^?&]+)/); 212 if (videoIdMatch && videoIdMatch[1]) { 213 iframe.src = 'https://player.vimeo.com/video/' + videoIdMatch[1] + '?autoplay=0'; 214 } 215 } catch (e2) { 216 console.log('Failed to stop Vimeo video:', e2); 217 } 218 } 219 }); 220 } 221 222 jQuery(document).ready(function ($) { 223 224 /*$(document.body).on('click', '.et_pb_de_mach_search_posts .et_pb_button', function () { 225 $(this).closest(".et_pb_de_mach_search_posts").find("#dmach-search-form").submit(); 226 });*/ 227 228 229 230 /* $(document).on('click', '.show_modal', function(e){ 231 e.preventDefault(); 232 e.stopPropagation(); 233 var srcContent = $($(this).attr('data-mfp-src')).html(); 234 $.magnificPopup.open({ 235 items: { 236 src: srcContent, // can be a HTML string, jQuery object, or CSS selector 237 type: 'inline' 238 } 239 }); 240 });*/ 241 242 if (typeof jQuery.fn.magnificPopup !== 'undefined') { 243 $('.et_pb_de_mach_gallery_trigger').magnificPopup({ 244 type:'inline', 245 midClick: true // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href. 246 }); 247 } 248 249 $(document.body).on('click', '.dmach-link-whole-grid-card', function () { 250 var url = $(this).data("link-url"); 251 window.location.href = url; 252 }); 253 254 255 256 main_count = Number(0); 257 258 $('.dmach-search-items').each(function (i, obj) { 259 main_count = Number(0); 260 $(this).children('.et_pb_de_mach_search_posts_item').each(function (i, obj) { 261 var count = Number($(this).find(".search_filter_cont").attr("data-count")); 262 main_count = main_count + count; 263 if (main_count >= "100") { 264 $(this).addClass("last-item"); 265 main_count = Number(0); 266 } 267 268 }); 269 }); 270 271 272 $(".search_filter_cont").removeClass("hidden"); 273 $(".button_container").removeClass("hidden"); 274 275 $('#select_post_types').on('change', function () { 276 var post_type_change = this.value; 277 $("#search_post_type").val(post_type_change); 278 279 }); 280 281 // end 282 283 var columns = $(".filtered-posts").attr("data-columns"); 284 $(".filtered-posts").find(".et_pb_column").addClass(columns) 285 286 $(window).click(function () { 287 $(".et_pb_de_mach_search_posts_item").removeClass("visible"); 288 }); 289 290 $('.et_pb_de_mach_search_posts_item').click(function (event) { 291 event.stopPropagation(); 292 }); 293 294 $(".dmach-filer-toggle .et_pb_contact_field_options_title ").click(function (e) { 295 296 if ($(this).closest(".et_pb_de_mach_search_posts_item").hasClass("visible")) { 297 $(".et_pb_de_mach_search_posts_item").removeClass("visible"); 298 } else { 299 $(".et_pb_de_mach_search_posts_item").removeClass("visible"); 300 $(this).closest(".et_pb_de_mach_search_posts_item").addClass("visible"); 301 } 302 303 }); 304 305 $('.dmach-tag-cloud a').click(function (e) { 306 307 var theClass = $(this).attr("class").match(/tag-link-[\w-]*\b/); 308 309 $(this).closest(".dmach-tag-cloud").find("select").val(theClass); 310 $(this).closest(".dmach-tag-cloud").find("select").trigger("change"); 311 312 }); 313 314 315 get_post_popup(); 316 317 }); 318 319 jQuery(document).on('click', '.dmach-popup .modal-close', function (e) { 320 e.preventDefault(); 321 var $modal = jQuery(this).closest('.dmach-popup'); 322 pauseAllVideosInModal($modal); 323 $modal.removeClass('open'); 324 jQuery('html').css('overflow', 'auto'); 325 jQuery('a').css('pointer-events','none'); 326 setTimeout( 327 function() 328 { 329 jQuery('a').css('pointer-events',''); 330 }, 100); 331 }); 332 333 jQuery(document).on('touchstart click', '.dmach-popup', function () { 334 var $modal = jQuery(this).closest('.dmach-popup'); 335 pauseAllVideosInModal($modal); 336 $modal.removeClass('open'); 337 jQuery('html').css('overflow', 'auto'); 338 jQuery('a').css('pointer-events','none'); 339 setTimeout( 340 function() 341 { 342 jQuery('a').css('pointer-events',''); 343 }, 100); 344 }); 345 346 347 jQuery(document).on('touchstart click', '.post-modal-cont', function (event) { 348 event.stopPropagation(); 349 }); 350 351 jQuery(document).on('touchstart click', '.dmach-next-post', function (event) { 352 var $currentModal = jQuery(this).closest('.dmach-popup'); 353 if ($currentModal.next('.dmach-popup').length) { 354 pauseAllVideosInModal($currentModal); 355 $currentModal.removeClass('open'); 356 $currentModal.next('.dmach-popup').addClass('open'); 357 } else { 358 pauseAllVideosInModal($currentModal); 359 $currentModal.removeClass('open'); 360 jQuery('html').css('overflow', 'auto'); 361 } 362 }); 363 364 365 jQuery(document).on('touchstart click', '.dmach-prev-post', function (event) { 366 var $currentModal = jQuery(this).closest('.dmach-popup'); 367 if ($currentModal.prev('.dmach-popup').length) { 368 pauseAllVideosInModal($currentModal); 369 $currentModal.removeClass('open'); 370 $currentModal.prev('.dmach-popup').addClass('open'); 371 } else { 372 pauseAllVideosInModal($currentModal); 373 $currentModal.removeClass('open'); 374 jQuery('html').css('overflow', 'auto'); 375 } 376 }); 377 378 379 function get_post_popup() { 380 jQuery('.dmach-popup').remove(); 381 if (jQuery('.show_modal').length > 0) { 382 383 var modal_style = jQuery('.show_modal').eq(0).attr('data-modal-style'); 384 385 var post_ids = []; 386 var modal_layouts = []; 387 var modal_posttypes = []; 388 // FIX: Get post_type from archive loop, fallback to button's data-modal-postype for single page usage 389 var post_type = jQuery('.show_modal').eq(0).closest('.divi-filter-archive-loop').attr('data-posttype'); 390 if (!post_type || post_type === 'auto') { 391 post_type = jQuery('.show_modal').eq(0).attr('data-modal-postype'); 392 } 393 jQuery('.show_modal').each(function () { 394 var post_id = jQuery(this).attr('data-id'); 395 var modal_layout = jQuery(this).attr('data-modal-layout'); 396 var modal_postype = jQuery(this).attr('data-modal-postype'); 397 var m_index = modal_layouts.indexOf( modal_layout ); 398 if ( m_index != -1 ) { 399 post_ids[m_index].push( post_id ); 400 } else { 401 modal_layouts.push( modal_layout ); 402 modal_posttypes.push( modal_postype ); 403 post_ids.push([post_id]); 404 } 405 }); 406 407 if (jQuery(".et-l--body").length) { 408 jQuery('.et-l--body').append('<div id="dmach-modal-wrapper" class="' + modal_style + ' loading"><div id="loading-modal" modallayout-id="" modaldata-id="" class="dmach-popup"><div class="post-modal-cont"><div class="modal-close"></div><div class="et_pb_section"><div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"><div class="filtered-posts-loading load-3"><span class="line"></span><span class="line"></span><span class="line"></span></div></div></div></div></div></div></div>'); 409 } else { 410 jQuery('#page-container').append('<div id="dmach-modal-wrapper" class="' + modal_style + ' loading"><div id="loading-modal" modallayout-id="" modaldata-id="" class="dmach-popup"><div class="post-modal-cont"><div class="modal-close"></div><div class="et_pb_section"><div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"><div class="filtered-posts-loading load-3"><span class="line"></span><span class="line"></span><span class="line"></span></div></div></div></div></div></div></div>'); 411 } 412 413 var data = { 414 'action': 'divi_filter_get_post_modal_ajax_handler',
415 'security': filter_ajax_object.security, 416 'post_ids': JSON.stringify(post_ids), 417 'post_type': post_type, 418 'modal_layout': JSON.stringify(modal_layouts), 419 'modal_postype': JSON.stringify(modal_posttypes) 420 }; 421 422 jQuery("body").addClass("hide_update_content_modal"); 423 424 jQuery('.show_modal').click(function (event) { 425 event.preventDefault(); 426 event.stopPropagation(); 427 428 var update_content_show_start = jQuery(this).attr('update_content_show_start'); 429 430 if (update_content_show_start == "off") { 431 jQuery("body").removeClass("hide_update_content_modal"); 432 } 433 434 var data_id = jQuery(this).attr('data-id'); 435 var loading_animation_color = jQuery(this).attr('loading_animation_color'); 436 var modal_type = jQuery(this).attr('modal_type'); 437 var modal_layout = jQuery(this).attr('data-modal-layout'); 438 439 if (modal_type == "update_content") { 440 441 jQuery('.dmach_content_update').each(function() { 442 // Pause videos before hiding 443 pauseAllVideosInModal(jQuery(this)); 444 jQuery(this).hide(); 445 jQuery(this).removeClass('open'); 446 }); 447 448 if (jQuery('#post-modal-' + modal_layout + '-' + data_id).length) { 449 jQuery('#post-modal-' + modal_layout + '-' + data_id).addClass('open'); 450 } else { 451 jQuery('#loading-modal').attr('modaldata-id', data_id); 452 jQuery('#loading-modal').attr('modallayout-id', modal_layout); 453 jQuery('#loading-modal').addClass('open'); 454 } 455 456 var $scrolltosection = jQuery('.dmach_content_update_cont'), 457 scrollto_fine_tune = '0px', 458 scrollto_fine_tune_dis = parseInt(scrollto_fine_tune); 459 460 jQuery('html, body').animate({ 461 scrollTop: $scrolltosection.offset().top - scrollto_fine_tune_dis 462 }, 500); 463 464 } else { 465 if (loading_animation_color !== "") { 466 jQuery('#loading-modal .line').each(function (i, obj) { 467 jQuery(this).css('background-color', loading_animation_color); 468 }); 469 } 470 471 if (jQuery('#post-modal-' + modal_layout + '-' + data_id).length) { 472 jQuery('#post-modal-' + modal_layout + '-' + data_id).addClass('open'); 473 } else { 474 jQuery('#loading-modal').attr('modaldata-id', data_id); 475 jQuery('#loading-modal').attr('modallayout-id', modal_layout); 476 jQuery('#loading-modal').addClass('open'); 477 } 478 jQuery('html').css('overflow', 'hidden'); 479 } 480 }); 481 482 jQuery.ajax({ 483 url: filter_ajax_object.ajax_url, // AJAX handler 484 data: data, 485 type: 'POST', 486 dataType: 'JSON', 487 success: function (data) { 488 489 // FIX: Save loading modal attributes BEFORE removing it 490 var pending_modal_data_id = jQuery('#loading-modal').attr('modaldata-id'); 491 var pending_modal_layout_id = jQuery('#loading-modal').attr('modallayout-id'); 492 var was_loading = jQuery("#dmach-modal-wrapper").hasClass('loading'); 493 494 jQuery('body').find('#dmach-modal-wrapper:not(.loading)').remove(); 495 jQuery('#loading-modal').remove(); 496 497 if (jQuery("#dmach-modal-wrapper.loading").length) { 498 } else { 499 if (jQuery(".et-l--body").length) { 500 jQuery('.et-l--body').append('<div id="dmach-modal-wrapper" class="' + modal_style + '"></div>'); 501 } else { 502 jQuery('#page-container').append('<div id="dmach-modal-wrapper" class="' + modal_style + '"></div>'); 503 } 504 } 505 506 jQuery('.show_modal').each(function () { 507 508 var data_id = jQuery(this).attr('data-id'); 509 var modal_type = jQuery(this).attr('modal_type'); 510 var update_content_pos = jQuery(this).attr('update_content_pos'); 511 var cur_modal_layout = jQuery(this).attr('data-modal-layout'); 512 513 if (modal_type == "update_content") { 514 if (update_content_pos == "above") { 515 jQuery('.update_content_loop .dmach-before-posts').addClass('dmach_content_update_cont'); 516 jQuery('.update_content_loop .dmach-before-posts').append('<div id="post-modal-' + cur_modal_layout + '-' + data_id + '" class="dmach_content_update"><div class="post-modal-cont">' + data['content']['show_modal_' + cur_modal_layout + '_' + data_id] + '</div></div>'); 517 } else { 518 jQuery('.update_content_loop .dmach-after-posts').addClass('dmach_content_update_cont'); 519 jQuery('.update_content_loop .dmach-after-posts').append('<div id="post-modal-' + cur_modal_layout + '-' + data_id + '" class="dmach_content_update"><div class="post-modal-cont">' + data['content']['show_modal_' + cur_modal_layout + '_' + data_id] + '</div></div>'); 520 521 } 522 } else { 523 jQuery('#dmach-modal-wrapper').append('<div id="post-modal-' + cur_modal_layout + '-' + data_id + '" class="dmach-popup"><div class="post-modal-cont"><div class="modal-close"></div>' + data['content']['show_modal_' + cur_modal_layout + '_' + data_id] + '<div class="dmach-nextprev-post"><div class="dmach-prev-post"></div><div class="dmach-next-post"></div></div></div></div>'); 524 } 525 526 // FIX: Fixed map initialization - use local variables instead of nested object access 527 if (jQuery('#post-modal-' + cur_modal_layout + '-' + data_id).find('.et_pb_map_container').length > 0) { 528 jQuery('#post-modal-' + cur_modal_layout + '-' + data_id).find('.et_pb_map_container').each(function () { 529 var $mapContainer = jQuery(this); 530 if (typeof et_pb_map_init !== "function") { 531 var mapInterval = setInterval(function () { 532 if (typeof et_pb_map_init === "function") { 533 et_pb_map_init($mapContainer); 534 clearInterval(mapInterval); 535 } 536 }, 1000); 537 } else { 538 et_pb_map_init($mapContainer); 539 } 540 }); 541 } 542 }); 543 544 // FIX: Use saved attributes instead of reading from removed element 545 if (was_loading && pending_modal_data_id && pending_modal_layout_id) { 546 jQuery('#dmach-modal-wrapper').removeClass('loading'); 547 jQuery('#post-modal-' + pending_modal_layout_id + '-' + pending_modal_data_id).addClass('open'); 548 } 549 550 jQuery('#dmach-modal-wrapper').append(data.css_output); 551 552 jQuery(".dmach-popup").each(function () { 553 var $popup = jQuery(this); 554 555 $popup.find(".et_pb_de_mach_acf_slider_containter").each(function () { 556 var $sliderContainer = jQuery(this); 557 var sliderID = $sliderContainer.attr("id"); // Get the ID of the container 558 559 if (sliderID) { 560 // Find gallery vars associated with this popup 561 var $galleryVarsElement = $popup.find(".gallery_vars"); 562 563 if ($galleryVarsElement.length > 0) { 564 var galleryVars = $galleryVarsElement.attr("data-gallery_vars"); 565 var galleryType = $galleryVarsElement.attr("data-gallery_type"); 566 567 if (galleryVars) { 568 // Clean and parse gallery_vars 569 galleryVars = galleryVars.replace(/,\s*$/, ""); 570 galleryVars = galleryVars.replace(/,/g, ", "); 571 galleryVars = galleryVars.replace(/'/g, '"'); 572 galleryVars = "{" + galleryVars + "}"; 573 galleryVars = JSON.parse(galleryVars); 574 575 // Apply Slick to the container 576 if ($sliderContainer.hasClass("slick-initialized")) { 577 $sliderContainer.slick("unslick"); 578 } 579 $sliderContainer.slick(galleryVars); 580 } 581 582 // If gallery_type is 'gallery', handle the navigation slider 583 if (galleryType === "gallery") { 584 var galleryNavVars = $galleryVarsElement.attr("data-gallery_nav"); 585 586 if (galleryNavVars) { 587 // Clean and parse gallery_nav_vars 588 galleryNavVars = galleryNavVars.replace(/,\s*$/, ""); 589 galleryNavVars = galleryNavVars.replace(/,/g, ", "); 590 galleryNavVars = galleryNavVars.replace(/'/g, '"'); 591 galleryNavVars = "{" + galleryNavVars + "}"; 592 galleryNavVars = JSON.parse(galleryNavVars); 593 594 // Set navigation-specific properties 595 galleryNavVars.asNavFor = "#" + sliderID; 596 galleryNavVars.focusOnSelect = true; 597 598 // Find the navigation container and apply Slick
599 var $navContainer = $popup.find(".et_pb_de_mach_acf_slider_containter_nav"); 600 601 if ($navContainer.length > 0) { 602 if ($navContainer.hasClass("slick-initialized")) { 603 $navContainer.slick("unslick"); 604 } 605 $navContainer.slick(galleryNavVars); 606 } 607 } 608 } 609 } 610 } 611 }); 612 }); 613 614 jQuery('#dmach-modal-wrapper .dmach-popup').each(function (i, obj) { 615 if (jQuery(this).find('.wpcf7-form').length > 0) { 616 wpcf7.init(jQuery(this).find('.wpcf7-form')); 617 } 618 }); 619 620 if ( "undefined" != typeof wc_add_to_cart_variation_params ) { 621 jQuery(".variations_form").each(function() { 622 jQuery(this).wc_variation_form(); 623 }); 624 } 625 626 if (typeof jQuery.fn.magnificPopup !== 'undefined') { 627 if (jQuery('.et_pb_de_mach_gallery_item').length > 0) { 628 // reinitalize magnific popup 629 jQuery('.et_pb_gallery_image a').magnificPopup({ 630 type: 'image' 631 }); 632 } 633 } else { 634 } 635 636 jQuery.event.trigger({ 637 type: "divi_machine_modal_loaded", 638 }); 639 640 } 641 }) 642 } 643 } 644 645 function same_height_cards() { 646 jQuery('.same-height-cards .filtered-posts').each(function () { 647 648 // Cache the highest 649 var highestBox = 0; 650 651 // Select and loop the elements you want to equalise 652 jQuery('.grid-col', this).each(function () { 653 // If this box is higher than the cached highest then store it 654 if (jQuery(this).height() > highestBox) { 655 highestBox = jQuery(this).height(); 656 } 657 }); 658 659 var margin_bottom = jQuery(this).find(".et_pb_section").css("marginBottom"); 660 661 // Set the height of all those children to whichever was highest 662 jQuery('.grid-col', this).height(highestBox); 663 jQuery('.grid-col', this).css("margin-bottom", margin_bottom); 664 }); 665 } 666 667 jQuery(document).ready(function($){ 668 $('span.hidethis').each(function(){ 669 var hide_option = $(this).attr('data-hide_option'); 670 if ( typeof hide_option !== "undefined" ) { 671 if ( hide_option == "hide_parent_row" ) { 672 if ($(this).parents('.et_section_specialty').length) { 673 $(this).closest('.et_pb_row_inner').hide(); 674 $(this).closest('.et_pb_row_inner').addClass('hidethis'); 675 } else { 676 $(this).closest('.et_pb_row').hide(); 677 $(this).closest('.et_pb_row').addClass('hidethis'); 678 } 679 } else if ( hide_option == "hide_parent_section") { 680 $(this).closest(".et_pb_section").hide(); 681 $(this).closest(".et_pb_section").addClass('hidethis'); 682 } else if ( hide_option == "hide_element" ) { 683 var target_selector = $(this).attr('data-hide_target'); 684 var target_in_section = $(this).attr('data-hide_target_in_section'); 685 686 if ( typeof target_in_section != 'undefined' && target_in_section == "on" ) { 687 $(this).closest('.et_pb_section').find(target_selector).hide(); 688 $(this).closest('.et_pb_section').find(target_selector).addClass('hidethis'); 689 690 // Check if target_selector includes 'grid-item' or 'grid-col' 691 if ( target_selector.indexOf('grid-item') > -1 || target_selector.indexOf('grid-col') > -1 || target_selector.indexOf('dmach-grid-item') > -1 ) { 692 $(this).closest('.grid-item, .grid-col, .dmach-grid-item').hide(); 693 $(this).closest('.grid-item, .grid-col, .dmach-grid-item').addClass('hidethis'); 694 } 695 696 } else { 697 $(target_selector).hide(); 698 $(target_selector).addClass('hidethis'); 699 } 700 } 701 } 702 703 }); 704 jQuery(document).on('divi_filter_completed', function(){ 705 jQuery('span.hidethis').each(function(){ 706 var hide_option = jQuery(this).attr('data-hide_option'); 707 if ( typeof hide_option !== "undefined" ) { 708 if ( hide_option == "hide_parent_row" ) { 709 if ($(this).parents('.et_section_specialty').length) { 710 $(this).closest('.et_pb_row_inner').hide(); 711 $(this).closest('.et_pb_row_inner').addClass('hidethis'); 712 } else { 713 $(this).closest('.et_pb_row').hide(); 714 $(this).closest('.et_pb_row').addClass('hidethis'); 715 } 716 } else if ( hide_option == "hide_parent_section") { 717 $(this).closest(".et_pb_section").hide(); 718 $(this).closest(".et_pb_section").addClass('hidethis'); 719 } else if ( hide_option == "hide_element" ) { 720 var target_selector = $(this).attr('data-hide_target'); 721 var target_in_section = $(this).attr('data-hide_target_in_section'); 722 723 if ( typeof target_in_section != 'undefined' && target_in_section == "on" ) { 724 $(this).closest('.et_pb_section').find(target_selector).hide(); 725 $(this).closest('.et_pb_section').find(target_selector).addClass('hidethis'); 726 727 // Check if target_selector includes 'grid-item' or 'grid-col' 728 if ( target_selector.indexOf('grid-item') > -1 || target_selector.indexOf('grid-col') > -1 || target_selector.indexOf('dmach-grid-item') > -1 ) { 729 $(this).closest('.grid-item, .grid-col, .dmach-grid-item').hide(); 730 $(this).closest('.grid-item, .grid-col, .dmach-grid-item').addClass('hidethis'); 731 } 732 733 } else { 734 $(target_selector).hide(); 735 $(target_selector).addClass('hidethis'); 736 } 737 } 738 } 739 }); 740 }); 741 }); 742 743 744 745 746 747 748 jQuery(document).ready(function ($) { 749 var $et_pb_countdown_timer = $( '.et_pb_countdown_timer' ); 750 window.et_countdown_timer = function( timer ) { 751 var end_date = parseInt( timer.attr( 'data-end-timestamp') ), 752 current_date = new Date().getTime() / 1000, 753 seconds_left = ( end_date - current_date ); 754 755 days = parseInt(seconds_left / 86400); 756 days = days > 0 ? days : 0; 757 seconds_left = seconds_left % 86400; 758 759 hours = parseInt(seconds_left / 3600); 760 hours = hours > 0 ? hours : 0; 761 762 seconds_left = seconds_left % 3600; 763 764 minutes = parseInt(seconds_left / 60); 765 minutes = minutes > 0 ? minutes : 0; 766 767 seconds = parseInt(seconds_left % 60); 768 seconds = seconds > 0 ? seconds : 0; 769
770 var $days_section = timer.find('.days > .value').parent('.section'), 771 $hours_section = timer.find('.hours > .value').parent('.section'), 772 $minutes_section = timer.find('.minutes > .value').parent('.section'), 773 $seconds_section = timer.find('.seconds > .value').parent('.section'); 774 775 776 if ( days == 0 ) { 777 if ( ! $days_section.hasClass('zero') ) { 778 timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero'); 779 } 780 } else { 781 days_slice = days.toString().length >= 3 ? days.toString().length : 3; 782 timer.find('.days > .value').html( ('000' + days).slice(-days_slice) ); 783 784 if ( $days_section.hasClass('zero') ) { 785 $days_section.removeClass('zero').next().removeClass('zero'); 786 } 787 } 788 789 if ( days == 0 && hours == 0 ) { 790 if ( ! $hours_section.hasClass('zero') ) { 791 timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 792 } 793 } else { 794 timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) ); 795 796 if ( $hours_section.hasClass('zero') ) { 797 $hours_section.removeClass('zero').next().removeClass('zero'); 798 } 799 } 800 801 if ( days == 0 && hours == 0 && minutes == 0 ) { 802 if ( ! $minutes_section.hasClass('zero') ) { 803 timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero'); 804 } 805 } else { 806 timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) ); 807 808 if ( $minutes_section.hasClass('zero') ) { 809 $minutes_section.removeClass('zero').next().removeClass('zero'); 810 } 811 } 812 813 if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) { 814 if ( ! $seconds_section.hasClass('zero') ) { 815 timer.find('.seconds > .value').html('00').parent('.section').addClass('zero'); 816 } 817 } else { 818 timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) ); 819 820 if ( $seconds_section.hasClass('zero') ) { 821 $seconds_section.removeClass('zero').next().removeClass('zero'); 822 } 823 } 824 } 825 826 window.et_countdown_timer_labels = function( timer ) { 827 if ( timer.closest( '.et_pb_column_3_8' ).length || timer.closest( '.et_pb_column_1_4' ).length || timer.children('.et_pb_countdown_timer_container').width() <= 400 ) { 828 timer.find('.days .label').html( timer.f
828ind('.days').data('short') ); 829 timer.find('.hours .label').html( timer.find('.hours').data('short') ); 830 timer.find('.minutes .label').html( timer.find('.minutes').data('short') ); 831 timer.find('.seconds .label').html( timer.find('.seconds').data('short') ); 832 } else { 833 timer.find('.days .label').html( timer.find('.days').data('full') ); 834 timer.find('.hours .label').html( timer.find('.hours').data('full') ); 835 timer.find('.minutes .label').html( timer.find('.minutes').data('full') ); 836 timer.find('.seconds .label').html( timer.find('.seconds').data('full') ); 837 } 838 } 839 840 if ( $et_pb_countdown_timer.length ) { 841 window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) { 842 $et_pb_countdown_timer.each(function(){ 843 var timer = $(this); 844 et_countdown_timer_labels( timer ); 845 et_countdown_timer( timer ); 846 setInterval(function(){ 847 et_countdown_timer( timer ); 848 }, 1000); 849 }); 850 } 851 et_pb_countdown_timer_init( $et_pb_countdown_timer ); 852 } 853 }); 854 855 856 /* Refresh countdown after ajax return */ 857 jQuery(document).ready(function ($) { 858 jQuery(document).on('divi_filter_completed', function(){ 859 860 861 var $et_pb_countdown_timer = $( '.et_pb_countdown_timer' ); 862 if ( $et_pb_countdown_timer.length ) { 863 window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) { 864 $et_pb_countdown_timer.each(function(){ 865 var timer = $(this); 866 et_countdown_timer_labels( timer ); 867 et_countdown_timer( timer ); 868 setInterval(function(){ 869 et_countdown_timer( timer ); 870 }, 1000); 871 }); 872 } 873 et_pb_countdown_timer_init( $et_pb_countdown_timer ); 874 } 875 876 877 var $et_pb_tabs = $( '.et_pb_tabs' ), 878 is_frontend_builder = $('body').hasClass('et-fb'); 879 880 if ( $et_pb_tabs.length || is_frontend_builder ) { 881 window.et_pb_tabs_init = function( $et_pb_tabs ) { 882 var $et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' ); 883 884 $et_pb_tabs.et_pb_simple_slider( { 885 use_controls : false, 886 use_arrows : false, 887 slide : '.et_pb_all_tabs > div', 888 tabs_animation : true 889 } ).on('et_hashchange', function( event ){ 890 var params = event.params; 891 var $the_tabs = $( '#' + event.target.id ); 892 var active_tab = params[0]; 893 if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) { 894 $the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click(); 895 } 896 }); 897 898 $et_pb_tabs_li.click( function() { 899 var $this_el = $(this), 900 $tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider'); 901 902 if ( $tabs_container.et_animation_running ) return false; 903 904 $this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' ); 905 906 $tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() ); 907 908 if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) { 909 var tab_state = []; 910 tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') ); 911 tab_state.push( $this_el.index() ); 912 tab_state = tab_state.join( et_hash_module_param_seperator ); 913 et_set_hash( tab_state ); 914 } 915 916 return false; 917 } ); 918 } 919 window.et_pb_tabs_init( $et_pb_tabs ); 920 } 921 922 923 }); 924 }); 925 926 // load more gallery 927 jQuery(document).ready(function ($) { 928 929 function ajax_load_more_gallery($this, is_popup) { 930 931 932 // if has the class loading, then stop 933 if ($this.hasClass('loading')) { 934 return false;
935 } 936 937 var $et_pb_gallery_grid = $this.closest('.et_pb_de_mach_acf_slider '); 938 var data_grid_image_ids = $et_pb_gallery_grid.find('.grid-item').attr('data-grid-image-ids'); 939 var data_load_more_num = $et_pb_gallery_grid.find('.grid-item').attr('data-load-more-num'); 940 var enable_lightbox = $et_pb_gallery_grid.find('.grid-item').attr('data-enable_lightbox'); 941 var show_title_and_caption = $et_pb_gallery_grid.find('.grid-item').attr('data-show_title_and_caption'); 942 943 var loading_text = $this.attr('data-loading_text'); 944 var original_text = $this.text(); 945 946 var data = { 947 'action': 'divi_filter_load_more_gallery_ajax_handler', 948 'data_grid_image_ids': data_grid_image_ids, 949 'data_load_more_num': data_load_more_num, 950 'enable_lightbox': enable_lightbox, 951 'show_title_and_caption': show_title_and_caption 952 }; 953 954 jQuery.ajax({ 955 url: filter_ajax_object.ajax_url, // AJAX handler 956 data: data, 957 type: 'POST', 958 dataType: 'JSON', 959 beforeSend: function () { 960 $this.addClass('loading'); 961 $this.attr('disabled', 'disabled'); 962 $this.text(loading_text); 963 }, 964 success: function (data) { 965 966 $this.removeClass('loading'); 967 $et_pb_gallery_grid.find('.grid-item').attr('data-grid-image-ids', data['ids']); 968 // $et_pb_gallery_grid.find('.grid-item').attr('data-load-more-num', data['data_load_more_num']); 969 $et_pb_gallery_grid.find('.grid-posts').append(data['content']); 970 $this.text(original_text); 971 972 if (data['data_load_more_num'] == 0) { 973 $this.hide(); 974 } 975 976 if (typeof jQuery.fn.magnificPopup !== 'undefined' && data['gallery_image_urls'] != '' && is_popup == true) { 977 // get instance (after popup was opened) 978 var mfp = jQuery.magnificPopup.instance; 979 jQuery.each(data['gallery_image_urls'], function( index, value ) { 980 mfp.items.push({ 981 src: value 982 }); 983 }); 984 985 // call update method to refresh counters (if required) 986 mfp.updateItemHTML(); 987 988 } else { 989 } 990 991 992 993 // if et_pb_gallery_grid find grid-item has the class "masonry", console log "masonry" 994 if ($et_pb_gallery_grid.find('.grid-item').hasClass('masonry')) { 995 let classes = $et_pb_gallery_grid.find('.grid-item').attr('class'); 996 997 // Match col-desk-4, col-tab-2, col-mob-1 and extract the colNumbers 998 let matches = classes.match(/col-(?:desk|tab|mob)-(\d+)/g); 999 1000 // Extract only the digits 1001 let colNumbers = matches.map(m => m.match(/\d+/)[0]); 1002 1003 var macyInstance = Macy({ 1004 container: $et_pb_gallery_grid.find('.grid-posts')[0], 1005 trueOrder: false, 1006 waitForImages: true, 1007 margin: { 1008 x: 25, 1009 y: 25 1010 }, 1011 columns: colNumbers[0], 1012 breakAt: { 1013 1200: colNumbers[0], 1014 980: colNumbers[1], 1015 767: colNumbers[2] 1016 } 1017 }); 1018 1019 macyInstance.recalculate(); 1020 $et_pb_gallery_grid.find('.masonry.et_pb_gallery_grid').addClass('loaded'); 1021 } 1022 1023 } 1024 }); 1025 1026 } 1027 1028 1029 $(document.body).on('click', '.et_pb_de_mach_load_more_button_link', function (e) { 1030 e.preventDefault(); 1031 1032 var $this = $(this); 1033 var is_popup = false;
1034 ajax_load_more_gallery($this, is_popup); 1035 1036 }); 1037 1038 // on .mfp-arrow click 1039 $(document.body).on('click', '.mfp-arrow', function (e) { 1040 // get the current image src 1041 var current_src = $('.mfp-img').attr('src'); 1042 // get the 2nd to last gallery item image src - .et_pb_gallery_items .grid-item:nth-last-child(2) img 1043 var second_last_src = $('.et_pb_gallery_items .grid-item:nth-last-child(2) img').attr('src'); 1044 1045 // if the current image src is the same as the 2nd to last gallery item image src, ajax load more 1046 if (current_src == second_last_src) { 1047 var $this = $('.et_pb_de_mach_load_more_button_link'); 1048 var is_popup = true; 1049 ajax_load_more_gallery($this, is_popup); 1050 } 1051 }); 1052 1053 // on keyboard arrow press 1054 $(document).keydown(function(e) { 1055 switch(e.which) { 1056 1057 case 39: // right 1058 // get the current image src 1059 var current_src = $('.mfp-img').attr('src'); 1060 // get the 2nd to last gallery item image src - .et_pb_gallery_items .grid-item:nth-last-child(2) img 1061 var second_last_src = $('.et_pb_gallery_items .grid-item:nth-last-child(2) img').attr('src'); 1062 1063 // if the current image src is the same as the 2nd to last gallery item image src, ajax load more 1064 if (current_src == second_last_src) { 1065 var $this = $('.et_pb_de_mach_load_more_button_link'); 1066 var is_popup = true; 1067 ajax_load_more_gallery($this, is_popup); 1068 } 1069 break; 1070 } 1071 }); 1072 1073 1074 1075 });
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.