1var newsletterSubscribe = { 2 maxMobileWidth: 767, 3 speed: 300, 4 isMobileRotation: false, 5 widgetSelector: '.newsletter-widget', 6 widgets: null, 7 8 init: function() { 9 var self = this; 10 11 self.onWindowResize(); 12 13 $(window).resize(function() { 14 self.onWindowResize(); 15 }); 16 17 $(document).delegate('.newsletter-popup-close', 'click', function(e) { 18 $.fancybox.close(); 19 }); 20 21 // thank popup 22 var subscribeThank = $('.newsletter-subscribe-thank'); 23 if (subscribeThank.length) { 24 this.showModal(subscribeThank); 25 } 26 27 // reconfirm popup 28 var subscribeReconfirm = $('.newsletter-subscribe-reconfirm'); 29 if (subscribeReconfirm.length) { 30 this.showModal(subscribeReconfirm); 31 } 32 }, 33 34 showModal: function(content) { 35 var self = this; 36 37 $.fancybox({ 38 content: $(content), 39 'padding': 0, 40 'margin': 20, 41 'autoScale': true, 42 'autoDimensions': true, 43 'showCloseButton': false, 44 'centerOnScroll': true, 45 onComplete: function () { 46 self._resizeModal(); 47 } 48 }); 49 }, 50 51 _resizeModal: function() { 52 var modal = $('.newsletter-subscribe-thank').width() ? $('.newsletter-subscribe-thank') : $('.newsletter-subscribe-confirm'); 53 if (!modal.width()) { 54 modal = $('#country_popup') 55 } 56 if (!modal.width()) { 57 return; 58 } 59 60 var outerPadding = 0; 61 var outerMargin = 20; 62 var minDiff = outerPadding * 2 + outerMargin * 2; 63 64 var maxWidth = parseInt(modal.data('max-width')) || 400; 65 var width = modal.width(); 66 var availableWidth = $(window).width() - minDiff; 67 68 var newWidth = 0; 69 //window collapse 70 if (availableWidth < width) { 71 newWidth = availableWidth; 72 } 73 //window expand 74 else if (availableWidth > width && width != maxWidth) { 75 if (availableWidth > maxWidth) { 76 newWidth = maxWidth; 77 } 78 else { 79 newWidth = availableWidth; 80 } 81 } 82 83 newWidth = newWidth || width; 84 $('#fancybox-wrap').width(newWidth + outerPadding * 2 + 20 * 2); 85 86 $('#fancybox-wrap').stop() 87 .animate({ 88 'left' : (($(window).width() - $('#fancybox-wrap').outerWidth()) / 2) 89 }, 160); 90 }, 91 92 onWindowResize: function() { 93 this._resizeModal(); 94 }, 95 96 executeCaptcha: function($widget) { 97 var self = this; 98 grecaptcha.execute(newsletter_recaptcha_key, {action: 'blocknewsletter'}).then(function(token) { 99 self.submitForm($widget, token); 100 }); 101 }, 102 103 submitForm: function($widget, recaptchaToken) { 104 var self = this; 105 var emailInput = $widget.find('input.newsletter-email'); 106 var email = $.trim(emailInput.val()); 107 var nameInput = $widget.find('input.newsletter-name'); 108 var name = $.trim(nameInput.val()); 109 110 if (!email) { 111 self.showMessage(blocknewsletter_empty_email_error_text, false, $widget); 112 $('.newsletter-btn').removeClass('disabled'); 113 return false; 114 } 115 116 if (!name) { 117 self.showMessage(blocknewsletter_empty_name_error_text, false, $widget); 118 $('.newsletter-btn').removeClass('disabled'); 119 return false; 120 } 121 122 $widget.find('.newsletter-widget-container').addClass('loading'); 123 124 var requestData = 'ajax=1&action=0&email=' + encodeURIComponent(email) + '&name=' + encodeURIComponent(name) + '&age-confirm=1'; 125 if (recaptchaToken) { 126 requestData += '&reCaptcha-response=' + recaptchaToken; 127 } 128 129 $.ajax({ 130 type: 'POST', 131 url: blockNewsLetterAjax, 132 data: requestData, 133 dataType: 'json', 134 cache: false, 135 success: function(data) { 136 $widget.find('.newsletter-widget-container').removeClass('loading'); 137 if (typeof data == 'object') { 138 if (data.success) { 139 emailInput.val(''); 140 nameInput.val(''); 141 self.showMessage(data.success, true, $widget); 142 setCookie('newsletter_subscribed', true, 365 * 10); 143 } else if (data.error) { 144 self.showMessage(data.error, false, $widget); 145 } 146 } else { 147 self.showMessage(blocknewsletter_wrong_error_text, false, $widget); 148 } 149 $('.newsletter-btn').hide().removeClass('disabled'); 150 }, 151 error: function(XMLHttpRequest, textStatus, errorThrown) { 152 $widget.find('.newsletter-widget-container').removeClass('loading'); 153 $('.newsletter-btn').removeClass('disabled'); 154 self.showMessage(blocknewsletter_technical_error_text, false, $widget); 155 } 156 }); 157 }, 158 159 showMessage: function(msg, isSuccess, $widget) { 160 $widget.find('.newsletter-msg').hide(this.speed, function () { 161 $(this).remove(); 162 }); 163 164 if (typeof isSuccess == 'undefined' || !isSuccess) { 165 var className = ''; 166 var element = $widget.find('.newsletter-email'); 167 $('<div class="newsletter-msg ' + className + '">*' + msg + '</div>').hide().insertBefore(element).show(this.speed); 168 $widget.find('.newsletter-signup').addClass('with-error-message'); 169 } 170 else { 171 $widget.find('.newsletter-signup').removeClass('with-error-message'); 172 var successText = blocknewsletter_success_text; 173 var $form = $widget.find('.newsletter-signup'); 174 $form.find('.newsletter-success').remove(); 175 $form.find('.newsletter-name, .newsletter-email').hide(this.speed, function () { 176 $(this).remove(); 177 }); 178 $('<div class="newsletter-success">
178' + successText + '</div>').hide().insertBefore($form.find('.newsletter-btn')).show(newsletterSubscribe.speed); 179 } 180 } 181}; 182 183$(document).ready(function() { 184 newsletterSubscribe.init(); 185 initLottie(); 186 187 $('.newsletter-btn').click( function () { 188 var self = newsletterSubscribe; 189 var $widget = $(this).parents('.newsletter-widget'); 190 191 if ($('.newsletter-btn').hasClass('disabled')) { 192 return; 193 } 194 $('.newsletter-btn').addClass('disabled'); 195 196 if (typeof newsletter_recaptcha_key !== 'undefined' && newsletter_recaptcha_key) { 197 if (typeof grecaptcha === 'undefined') { 198 $.getScript('https://www.google.com/recaptcha/api.js?render=' + newsletter_recaptcha_key) 199 .done(function() { 200 grecaptcha.ready(function() { 201 self.executeCaptcha($widget); 202 }); 203 }) 204 .fail(function() { 205 $('.newsletter-btn').removeClass('disabled'); 206 self.showMessage(blocknewsletter_technical_error_text, false, $widget); 207 }); 208 } else { 209 self.executeCaptcha($widget); 210 } 211 } else { 212 self.submitForm($widget); 213 } 214 }); 215 216 $('.newsletter-email').click( function () { 217 if ($(this).val().length == 0) { 218 $(this).val($('.newsletter-email-default').val()); 219 } 220 }); 221 222}); 223 224 225function initLottie() { 226 const player = document.getElementById('dotlottie-player-widget'); 227 228 if (player == null) { 229 return; 230 } 231 232 const setLottieSource = function() { 233 if (window.innerWidth < 767) { 234 player.src = lottieSrcMobile; 235 } else { 236 player.src = lottieSrcDesktop; 237 } 238 }; 239 240 const initializeLottiePlayer = function() { 241 setLottieSource(); 242 player.load(player.src); 243 player.addEventListener('ready', () => { 244 player.play(); 245 }, { once: true }); 246 }; 247 248 const ensureDotLottieScript = function() { 249 if (window.customElements && window.customElements.get('dotlottie-player')) { 250 return Promise.resolve(); 251 } 252 253 if (window.dotLottieScriptPromise) { 254 return window.dotLottieScriptPromise; 255 } 256 257 window.dotLottieScriptPromise = new Promise(function(resolve, reject) { 258 const script = document.createElement('script'); 259 script.type = 'module'; 260 script.src = dotLottiePlayerScriptUrl; 261 script.onload = resolve; 262 script.onerror = reject; 263 document.head.appendChild(script); 264 }); 265 266 return window.dotLottieScriptPromise; 267 }; 268 269 const playerContainer = player.closest('.dotlottie-player-widget-container') || player; 270 if (typeof IntersectionObserver == 'undefined') { 271 ensureDotLottieScript().then(function() { 272 initializeLottiePlayer(); 273 }); 274 return; 275 } 276 277 const observer = new IntersectionObserver(function(entries, obs) { 278 entries.forEach(function(entry) { 279 if (!entry.isIntersecting) { 280 return; 281 } 282 283 obs.unobserve(entry.target); 284 ensureDotLottieScript().then(function() { 285 initializeLottiePlayer(); 286 }).catch(function() { 287 // Prevent blocking newsletter signup flow if animation script fails 288 }); 289 }); 290 }, { 291 rootMargin: '200px 0px', 292 threshold: 0.01 293 }); 294 295 observer.observe(playerContainer); 296}
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.