1jQuery(document).ready(function ($) { 2 var CTA_Click = []; 3 var CTA_Tracked = []; 4 5 const updateButtonMetrics = function ($cta) { 6 if (!$cta || !$cta.length) { 7 return; 8 } 9 10 const $button = $cta.find('.sticky-sidebar-button').first(); 11 if (!$button.length) { 12 return; 13 } 14 15 const width = Math.ceil($button.outerWidth()); 16 const height = Math.ceil($button.outerHeight()); 17 18 if (width) { 19 $cta.css('--buttonWidth', `${width}px`); 20 } 21 if (height) { 22 $cta.css('--buttonHeight', `${height}px`); 23 } 24 }; 25 26 const updateAllButtonMetrics = function () { 27 $('.easy-sticky-sidebar').each(function () { 28 updateButtonMetrics($(this)); 29 }); 30 }; 31 32 const updateOverlayBackgroundOffsets = function ($cta) { 33 if (!$cta || !$cta.length) { 34 return; 35 } 36 37 if (!$cta.hasClass('image-as-background')) { 38 $cta.css('--ess-overlay-bg-offset-x', ''); 39 $cta.css('--ess-overlay-bg-offset-y', ''); 40 return; 41 } 42 43 const $panel = $cta.find('.sticky-overlay-panel').first(); 44 if (!$panel.length) { 45 $cta.css('--ess-overlay-bg-offset-x', ''); 46 $cta.css('--ess-overlay-bg-offset-y', ''); 47 return; 48 } 49 50 const panelWidth = Math.max(0, Math.round(($panel.outerWidth() || 0) * 0.9)); 51 const panelHeight = Math.max(0, Math.round(($panel.outerHeight() || 0) * 0.9)); 52 $cta.css('--ess-overlay-bg-offset-x', `${panelWidth}px`); 53 $cta.css('--ess-overlay-bg-offset-y', `${panelHeight}px`); 54 }; 55 56 const updateAllOverlayBackgroundOffsets = function () { 57 $('.easy-sticky-sidebar.image-as-background').each(function () { 58 updateOverlayBackgroundOffsets($(this)); 59 }); 60 }; 61 62 const updateVerticalShrinkOffset = function ($cta, isShrink) { 63 if (!$cta || !$cta.length || !$cta.hasClass('vertical-cta')) { 64 return; 65 } 66 67 const isTop = $cta.hasClass('sticky-cta-position-top'); 68 const isBottom = $cta.hasClass('sticky-cta-position-bottom'); 69 if (!isTop && !isBottom) { 70 return; 71 } 72 73 const $button = $cta.find('.sticky-sidebar-button').first(); 74 if (!$button.length) { 75 return; 76 } 77 78 const ctaHeight = Math.ceil($cta.outerHeight()); 79 const buttonHeight = Math.ceil($button.outerHeight()); 80 const distanceRaw = getComputedStyle($cta[0]).getPropertyValue('--position_distance') || '0'; 81 const distance = parseFloat(distanceRaw) || 0; 82 83 if (!isShrink) { 84 $cta.css('--translateY', '0px'); 85 return; 86 } 87 88 const isExternalVerticalHtmlTab = $cta.hasClass('sticky-cta') 89 && ($cta.hasClass('ess-html-tab-align-left') || $cta.hasClass('ess-html-tab-align-center') || $cta.hasClass('ess-html-tab-align-right')); 90 const isExternalVerticalStickyOverlayTab = $cta.hasClass('sticky-cta') 91 && $cta.hasClass('image-as-background') 92 && !$cta.hasClass('ess-overlay-full-tab-height') 93 && (isTop || isBottom); 94 const isExternalVerticalTab = isExternalVerticalHtmlTab || isExternalVerticalStickyOverlayTab; 95 const delta = isExternalVerticalTab 96 ? Math.max(0, ctaHeight - distance) 97 : Math.max(0, ctaHeight - buttonHeight - distance); 98 const translateY = isTop ? -delta : delta; 99 $cta.css('--translateY', `${translateY}px`); 100 }; 101 102 const ensureTabCtaIcon = function ($cta) { 103 if (!$cta || !$cta.length || !$cta.hasClass('tab-cta')) { 104 return; 105 } 106 107 let iconClass = ($cta.data('button-icon') || '').toString().trim(); 108 if (!iconClass) { 109 return; 110 } 111 112 // Backward compatibility for values like "fa-angle-right". 113 if (/^fa-[a-z0-9-]+$/i.test(iconClass)) { 114 iconClass = `fa ${iconClass}`; 115 } 116 117 const $label = $cta.find('.sticky-sidebar-button > div').first(); 118 if (!$label.length) { 119 return; 120 } 121 122 if ($label.find('i').length) { 123 return; 124 } 125 126 const $icon = $('<i />').addClass(`icon ${iconClass}`); 127 $label.prepend(' ').prepend($icon); 128 }; 129 130 updateAllButtonMetrics(); 131 updateAllOverlayBackgroundOffsets(); 132 $('.easy-sticky-sidebar.tab-cta').each(function () { 133 ensureTabCtaIcon($(this)); 134 }); 135 $(window).on('load resize', function () { 136 updateAllButtonMetrics(); 137 updateAllOverlayBackgroundOffsets(); 138 }); 139 140 $('.easy-sticky-sidebar .btn-ess-close').on('click', function (e) { 141 e.stopPropagation(); 142 $(this).closest('.easy-sticky-sidebar').fadeOut(200, function () { 143 $(this).remove(); 144 }); 145 }); 146 147 var width = $(window).width(); 148 149 if (width >= 767) { 150 $(window).scroll(function () { 151 var scroll = $(window).scrollTop(); 152 if (scroll <= 120) { 153 return; 154 } 155 156 jQuery('.easy-sticky-sidebar.sticky-cta:not(.scrolled)').each(function () { 157 if ($(this).hasClass('shrink-disabled')) { 158 return; 159 } 160 161 cta_id = parseInt($(this).data('id')); 162 if (!CTA_Click.includes(cta_id)) { 163 updateButtonMetrics($(this)); 164 $(this).addClass('shrink scrolled'); 165 updateVerticalShrinkOffset($(this), true); 166 } 167 }); 168 }); 169 } 170 171 $('body').on('click', '.easy-sticky-sidebar .sticky-sidebar-button:not(a)', function (e) { 172 e.preventDefault(); 173 174 current_cta = $(this).closest('.easy-sticky-sidebar'); 175 updateButtonMetrics(current_cta); 176 177 cta_id = parseInt(current_cta.data('id')); 178 if (cta_id > 0 && !CTA_Click.includes(cta_id)) { 179 CTA_Click.push(cta_id); 180 } 181 182 const willShrink = !current_cta.hasClass('shrink'); 183 current_cta.toggleClass('shrink'); 184 updateVerticalShrinkOffset(current_cta, willShrink);
185 updateOverlayBackgroundOffsets(current_cta); 186 }); 187 188 (function trackImpressions() { 189 if (typeof easy_sticky_sidebar_front === 'undefined' || !easy_sticky_sidebar_front.ajax_url) { 190 return; 191 } 192 193 var ids = []; 194 $('.easy-sticky-sidebar[data-id]').each(function () { 195 var id = parseInt($(this).data('id'), 10); 196 if (id > 0) { 197 ids.push(id); 198 } 199 }); 200 201 if (ids.length) { 202 $.post(easy_sticky_sidebar_front.ajax_url, { 203 action: 'easy_sticky_sidebar_track_impressions', 204 ids: ids, 205 nonce: easy_sticky_sidebar_front.nonce 206 }); 207 } 208 })(); 209 210 $('body').on('click', '.easy-sticky-sidebar a', function () { 211 var sticky_id = parseInt($(this).closest('[data-id]').data('id'), 10); 212 if (!sticky_id || CTA_Tracked.includes(sticky_id)) { 213 return; 214 } 215 216 CTA_Tracked.push(sticky_id); 217 218 if (typeof easy_sticky_sidebar_front === 'undefined' || !easy_sticky_sidebar_front.ajax_url) { 219 return; 220 } 221 222 $.post(easy_sticky_sidebar_front.ajax_url, { 223 action: 'easy_sticky_sidebar_get_click', 224 sticky_id: sticky_id, 225 nonce: easy_sticky_sidebar_front.nonce 226 }); 227 }); 228});
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.