1(function($) { 2 3 var BREAKPOINT = 1200; 4 var CARDS_KEY = 'splitCtaOriginalCards'; 5 6 function isDesktop() { 7 return $(window).width() > BREAKPOINT; 8 } 9 10 // Cache the original card HTML the first time we see this column, 11 // BEFORE SimpleBar wraps it. 12 function cacheOriginalCards($rightCol) { 13 if ($rightCol.data(CARDS_KEY)) return; 14 var $cards = $rightCol.children('.split-cta-card'); 15 if ($cards.length === 0) return; 16 var html = ''; 17 $cards.each(function() { 18 html += this.outerHTML; 19 }); 20 $rightCol.data(CARDS_KEY, html); 21 } 22 23 function destroySimpleBar($rightCol) { 24 var el = $rightCol[0]; 25 if (!el) return; 26 27 if (typeof SimpleBar !== 'undefined') { 28 var instance = SimpleBar.instances && SimpleBar.instances.get 29 ? SimpleBar.instances.get(el) 30 : null; 31 if (instance && typeof instance.unMount === 'function') { 32 instance.unMount(); 33 } 34 } 35 36 // Strip auto-init attributes so it doesn't re-wrap 37 $rightCol.removeAttr('data-simplebar'); 38 $rightCol.removeAttr('data-simplebar-auto-hide'); 39 40 // Restore original card markup, blowing away all .simplebar-* wrappers 41 var cachedHtml = $rightCol.data(CARDS_KEY); 42 if (cachedHtml) { 43 $rightCol.html(cachedHtml); 44 } 45 } 46 47 function mountSimpleBar($rightCol) { 48 var el = $rightCol[0]; 49 if (!el || typeof SimpleBar === 'undefined') return; 50 51 var existing = SimpleBar.instances && SimpleBar.instances.get 52 ? SimpleBar.instances.get(el) 53 : null; 54 if (existing) return; 55 56 $rightCol.attr('data-simplebar', ''); 57 $rightCol.attr('data-simplebar-auto-hide', 'false'); 58 new SimpleBar(el, { autoHide: false }); 59 } 60 61 function updateSplitCta() { 62 var desktop = isDesktop(); 63 $('.split-cta-right--scroll').each(function() { 64 var $rightCol = $(this); 65 var $leftCol = $rightCol.siblings('.split-cta-left'); 66 var leftHeight = $leftCol.outerHeight(); 67 68 // Capture original markup the first time (works whether SimpleBar has 69 // wrapped or not â we look for cards as direct children before any wrap) 70 cacheOriginalCards($rightCol); 71 72 var currentMode = $rightCol.data('splitCtaMode'); // 'desktop' | 'mobile' | undefined 73 var targetMode = desktop ? 'desktop' : 'mobile'; 74 var modeChanged = currentMode !== targetMode; 75 76 if (desktop) { 77 if (modeChanged) { 78 mountSimpleBar($rightCol); 79 } 80 if (leftHeight > 0) { 81 $rightCol.css('max-height', leftHeight + 'px'); 82 } 83 } else { 84 if (modeChanged) { 85 destroySimpleBar($rightCol); 86 $rightCol.css('max-height', ''); 87 } 88 } 89 90 $rightCol.data('splitCtaMode', targetMode); 91 }); 92 } 93 94 // Cache cards as early as possible â before SimpleBar's auto-init runs. 95 // SimpleBar v6 auto-initializes on DOMContentLoaded, so we run on 96 // document ready (which fires before window load). 97 $(function() { 98 $('.split-cta-right--scroll').each(function() { 99 cacheOriginalCards($(this)); 100 }); 101 }); 102 103 // Show more / Show less toggle (mobile, scroll mode) 104 $(document).on('click', '.split-cta-card-toggle', function(e) { 105 e.preventDefault(); 106 var $btn = $(this); 107 var $card = $btn.closest('.split-cta-card'); 108 var isOpen = $btn.attr('aria-expanded') === 'true'; 109 $btn.attr('aria-expanded', isOpen ? 'false' : 'true'); 110 $card.toggleClass('is-expanded', !isOpen); 111 }); 112 113 $(window).on('load', updateSplitCta); 114 $(window).on('resize', updateSplitCta); 115 116 // ACF preview support 117 if (window.acf) { 118 window.acf.addAction('render_block_preview/type=split-cta', function($el) { 119 setTimeout(updateSplitCta, 200); 120 }); 121 } 122 123})(jQuery);
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.