1const blockUserInfo = { 2 3 view: null, 4 isLogged: null, 5 htmlDefMaxWidth: null, 6 fixedHeaderDefMaxWidth: null, 7 fixedHeaderOrderPageDefMaxWidth: null, 8 9 init: function () { 10 blockUserInfo.isLogged = isLogged 11 12 $('.js-blockuser-popup-toggler').unbind('click').click(function (e) { 13 14 /* prevent layout shift - start */ 15 var innerWidth = $('body').innerWidth() 16 var outerWidth = window.innerWidth 17 var scrollBarWidth = outerWidth - innerWidth 18 blockUserInfo.htmlDefMaxWidth = $('html').css('max-width') 19 blockUserInfo.fixedHeaderDefMaxWidth = $('#tmcategories .full.hidden-xs').css('max-width') 20 blockUserInfo.fixedHeaderOrderPageDefMaxWidth = $('#affix').css('max-width') 21 22 if (innerWidth) { 23 $('#tmcategories .full.hidden-xs').css('max-width', innerWidth + 'px') 24 $('html').css('max-width', innerWidth + 'px') 25 $('#affix').css('max-width', innerWidth + 'px') 26 } 27 /* prevent layout shift - end */ 28 29 let section = $(this).attr('data-section') 30 blockUserInfo.updateView(section) 31 $('body').addClass('overflow-hidden'); 32 $('#blockuserinfo-popup-wrapper').addClass('display-flex') 33 if (section === 'login' && !blockUserInfo.isLogged) { 34 blockUserInfo.getLoginForm() //get via ajax because of csrf token issue 35 } 36 blockUserInfo.recalculatePadding() 37 }); 38 39 $('.js-blockuserinfo-popup-close').unbind('click').click(function () { 40 blockUserInfo.closeView() 41 }) 42 43 $('#blockuserinfo-popup-wrapper').unbind('click').click(function (e) { 44 if (e.target === this) { 45 blockUserInfo.closeView() 46 } 47 }) 48 49 if ($('.js-switch-to-login').length) { 50 $('.js-switch-to-login').unbind('click').click(function () { 51 blockUserInfo.updateView('login') 52 blockUserInfo.getLoginForm() 53 }) 54 } 55 56 if ($('.js-minicart-alert').length) { 57 if (cartAlertTimeLeft > 0) { 58 setTimeout(function() { $('.js-minicart-alert').addClass('falldown'); }, 5000); 59 60 setTimeout(function() { 61 $('.js-minicart-alert').removeClass('falldown').addClass('goup') 62 setCookie('cart_alert_stop_show', true, 180) 63 }, cartAlertTimeLeft * 1000); 64 } 65 66 $('.js-minicart-alert').unbind('click').click(function () { 67 $(this).removeClass('falldown').addClass('goup') 68 setCookie('cart_alert_stop_show', true, 180) 69 }) 70 } 71 72 if ($('.js-mobile-user-menu').length) { 73 $('.js-mobile-user-menu').unbind('click').click(function () { 74 $('#blockuserinfo-popup-wrapper').addClass('display-flex') 75 }); 76 } 77 }, 78 79 getLoginForm: function () { 80 blockUserInfo.addLoading() 81 var isolang = (typeof window.isolang !== 'undefined' && window.isolang) || '' 82 var postData = 'ajax=true&getLoginForm&token=' + static_token + (isolang ? '&isolang=' + isolang : '') 83 $.ajax({ 84 type: 'POST', 85 url: baseDir + 'authentication.php', 86 async: true, 87 cache: false, 88 dataType: 'json', 89 data: postData, 90 success: function(jsonData) { 91 blockUserInfo.removeLoading() 92 if (jsonData.loginFormHtml) { 93 blockUserInfo.updateView('login') 94 $('.js-wrap-login .js-blockuserinfo-popup-body').html(jsonData.loginFormHtml) 95 initNiceInput() 96 blockUserInfo.validateForms() 97 $('.js-lost_password').unbind('click').click(function () { 98 blockUserInfo.updateView('password') 99 }) 100 $('.js-back-to-login').unbind('click').click(function () { 101 blockUserInfo.updateView('login') 102 }) 103 $('.js-submit-login').unbind('click').click(function (e) { 104 if ($(this).hasClass('not-active')) { 105 return false;
106 } 107 e.preventDefault() 108 blockUserInfo.processCaptcha('js-submit-login') 109 }) 110 $('.js-submit-password-reset').unbind('click').click(function (e) { 111 if ($(this).hasClass('not-active')) { 112 return false; 113 } 114 e.preventDefault() 115 blockUserInfo.processCaptcha('js-submit-password-reset') 116 }) 117 $('.js-submit-password-reset-form').on('submit', function (e) { 118 e.preventDefault() 119 let emailRecoverPassword = $('#recover_email_blockuserinfo').val() 120 let recaptchaResponse = $('.js-g-recaptcha-response-js-submit-password-reset').val() 121 if (emailRecoverPassword) { 122 blockUserInfo.addLoading() 123 $.ajax({ 124 type: 'POST', 125 url: baseDir + 'password.php', 126 async: true, 127 cache: false, 128 dataType: 'json', 129 data: 'ajax=true&email='+emailRecoverPassword+'&g-recaptcha-response='+recaptchaResponse+'&token=' + static_token, 130 success: function (jsonData) { 131 blockUserInfo.removeLoading() 132 blockUserInfo.removeErrorBlock() 133 if (jsonData.hasError && jsonData.errors_html) { 134 $('.js-blockuserinfo-popup-body').prepend(jsonData.errors_html) 135 } 136 if (jsonData.success) { 137 $('.js-password-recovery-form').hide() 138 $('.js-password-recovery-result').show() 139 } 140 }, 141 error: function () { 142 blockUserInfo.removeLoading() 143 } 144 }) 145 } 146 }) 147 } 148 }, 149 error: function (XMLHttpRequest, textStatus, errorThrown) { 150 blockUserInfo.removeLoading() 151 alert("TECHNICAL ERROR: unable to get login form \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 152 } 153 }); 154 }, 155 156 updateView: function (view) { 157 158 blockUserInfo.removeErrorBlock() 159 blockUserInfo.view = view 160 161 if (blockUserInfo.view === 'login') { 162 $('#blockuserinfo-popup-container').removeClass('password').removeClass('minicart').removeClass('wishlist').addClass('login') 163 } 164 165 if (blockUserInfo.view === 'password') { 166 $('#blockuserinfo-popup-container').removeClass('login').removeClass('minicart').removeClass('wishlist').addClass('password') 167 } 168 169 if (blockUserInfo.view === 'wishlist') { 170 $('#blockuserinfo-popup-container').removeClass('login').removeClass('password').removeClass('minicart').addClass('wishlist') 171 } 172 173 if (blockUserInfo.view === 'minicart') { 174 $('#blockuserinfo-popup-container').removeClass('login').removeClass('password').removeClass('wishlist').addClass('minicart') 175 document.dispatchEvent(new CustomEvent('onChangeMiniCart')); 176 } 177 }, 178 179 recalculatePadding: function () { 180 if ($('.blockuserinfo-popup-footer').length) { 181 let el = document.getElementsByClassName('blockuserinfo-popup-footer')[0]; 182 if (typeof el !== 'undefined') { 183 let rect = el.getBoundingClientRect(); 184 $('.blockuserinfo-popup-body').css('padding-bottom', rect.height + 'px') 185 } 186 } 187 }, 188 189 removeErrorBlock: function () {
190 $('.js-blockuserinfo-popup-body').find('div.error').remove() 191 }, 192 193 addLoading: function () { 194 $('.js-blockuserinfo-popup-body').addClass('loading') 195 }, 196 197 removeLoading: function () { 198 $('.js-blockuserinfo-popup-body').removeClass('loading') 199 }, 200 201 executeCaptcha: function (el) { 202 grecaptcha.execute(recaptcha_key).then(function (token) { 203 $('.js-g-recaptcha-response-'+el).val(token); 204 blockUserInfo.removeLoading() 205 $('.'+el+'-form').submit(); 206 }); 207 }, 208 209 processCaptcha: function (el) { 210 blockUserInfo.addLoading() 211 if (typeof recaptcha_key != 'undefined') { 212 if (typeof grecaptcha === 'undefined') { 213 $.getScript('https://www.google.com/recaptcha/api.js?render=' + recaptcha_key).done(function(script, textStatus) { 214 grecaptcha.ready(function () { 215 blockUserInfo.executeCaptcha(el); 216 }); 217 }); 218 } else { 219 blockUserInfo.executeCaptcha(el); 220 } 221 } else { 222 blockUserInfo.removeLoading() 223 $('.'+el+'-form').submit(); 224 } 225 }, 226 227 validateForms: function () { 228 229 if (typeof validateForms === 'undefined') { 230 return; 231 } 232 233 if ($('#login_email_blockuserinfo').length) { 234 $('#login_email_blockuserinfo').typeWatch({highlight: true, wait: 200, captureLength: 0, callback: function (){ 235 if (validateForms.validateEmail(this.text) && validateForms.validatePassword($('#login_passwd_blockuserinfo').val())) { 236 $('.js-submit-login').removeClass('not-active') 237 } else { 238 $('.js-submit-login').addClass('not-active') 239 } 240 241 if (validateForms.validateEmail(this.text)) { 242 $('#login_email_blockuserinfo').valid() 243 } 244 }}); 245 246 } 247 248 if ($('#login_passwd_blockuserinfo').length) { 249 $('#login_passwd_blockuserinfo').typeWatch({highlight: true, wait: 200, captureLength: 0, callback: function (){ 250 if (validateForms.validatePassword(this.text) && validateForms.validateEmail($('#login_email_blockuserinfo').val())) { 251 $('.js-submit-login').removeClass('not-active') 252 } else { 253 $('.js-submit-login').addClass('not-active') 254 } 255 256 if (validateForms.validatePassword(this.text)) { 257 $('#login_passwd_blockuserinfo').valid() 258 } 259 }}); 260 } 261 262 if ($('#login_email_blockuserinfo_2').length) { 263 $('#login_email_blockuserinfo_2').typeWatch({highlight: true, wait: 200, captureLength: 0, callback: function (){ 264 if (validateForms.validateEmail(this.text)) { 265 $('.js-submit-account-create').removeClass('not-active') 266 $('#login_email_blockuserinfo_2').valid() 267 } else { 268 $('.js-submit-account-create').addClass('not-active') 269 } 270 }}); 271 } 272 273 if ($('#recover_email_blockuserinfo').length) { 274 $('#recover_email_blockuserinfo').typeWatch({highlight: true, wait: 200, captureLength: 0, callback: function (){ 275 if (validateForms.validateEmail(this.text)) { 276 $('.js-submit-password-reset').removeClass('not-active') 277 $('#recover_email_blockuserinfo').valid() 278 } else { 279 $('.js-submit-password-reset').addClass('not-active') 280 } 281 }}); 282 } 283 284 if ($('#login_form_blockuserinfo').length) { 285 $('#login_form_blockuserinfo').validate({ 286 rules: { 287 email: { 288 emailonly: true, 289 required: true 290 }, 291 passwd: { 292 ispassword: true, 293 required: true 294 } 295 }, 296 errorPlacement: function (error, element) { 297 validateForms.insertNotEmptyOrRequired(error, element) 298 }, 299 invalidHandler: function (form, validator) { 300 validateForms.invalidHandler(form, validator) 301 }, 302 unhighlight: function(element, errorClass, validClass) { 303 validateForms.unhighlight(element, errorClass, validClass) 304 }, 305 highlight: function(element, errorClass, validClass) { 306 validateForms.highlight(element, errorClass, validClass) 307 } 308 }); 309 } 310 311 if ($('#create_account_form_blockuserinfo').length) { 312 $('#create_account_form_blockuserinfo').validate({ 313 rules: { 314 email: { 315 emailonly: true, 316 required: true 317 } 318 }, 319 errorPlacement: function (error, element) { 320 validateForms.insertNotEmptyOrRequired(error, element) 321 }, 322 invalidHandler: function (form, validator) { 323 validateForms.invalidHandler(form, validator) 324 }, 325 unhighlight: function(element, errorClass, validClass) { 326 validateForms.unhighlight(element, errorClass, validClass) 327 }, 328 highlight: function(element, errorClass, validClass) { 329 validateForms.highlight(element, errorClass, validClass) 330 } 331 }); 332 } 333 334 if ($('#recover_password_blockuserinfo').length) { 335 $('#recover_password_blockuserinfo').validate({ 336 rules: { 337 email: { 338 emailonly: true, 339 required: true 340 } 341 }, 342 errorPlacement: function (error, element) { 343 validateForms.insertNotEmptyOrRequired(error, element) 344 }, 345 invalidHandler: function (form, validator) { 346 validateForms.invalidHandler(form, validator) 347 }, 348 unhighlight: function(element, errorClass, validClass) { 349 validateForms.unhighlight(element, errorClass, validClass) 350 }, 351 highlight: function(element, errorClass, validClass) { 352 validateForms.highlight(element, errorClass, validClass) 353 } 354 }); 355 } 356 }, 357 358 closeView: function () { 359 if (blockUserInfo.fixedHeaderOrderPageDefMaxWidth) { 360 $('#affix').css('max-width', blockUserInfo.fixedHeaderOrderPageDefMaxWidth) 361 } 362 if (blockUserInfo.fixedHeaderDefMaxWidth) { 363 $('#tmcategories .full.hidden-xs').css('max-width', blockUserInfo.fixedHeaderDefMaxWidth) 364 } 365 if (blockUserInfo.htmlDefMaxWidth) { 366 $('html').css('max-width', blockUserInfo.htmlDefMaxWidth) 367 } 368 blockUserInfo.view = null 369 $('body').removeClass('overflow-hidden'); 370 $('#blockuserinfo-popup-wrapper').removeClass('display-flex') 371 } 372} 373 374$(document).ready(function() { 375 blockUserInfo.init(); 376});
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.