1if (typeof S === 'undefined') { 2 var S = {}; 3} 4 5S.appcard = { 6 _data: {}, 7 _escAttr: function (str) { 8 return str.replace('"', """); 9 }, 10 _sanitize: function (str, delimiter) { 11 return str.replace(/[^A-Z0-9]/ig, delimiter).toLowerCase(); 12 }, 13 _initialize: function () { 14 jQuery(document).on('click', '#text-me-btn', function (e) { 15 e.preventDefault(); 16 var phone = jQuery('#field_phone').val(); 17 S.appcard.methodSelection(phone, "text"); 18 }); 19 jQuery(document).on('click', '#call-me-btn', function (e) { 20 e.preventDefault(); 21 var phone = jQuery('#field_phone').val(); 22 S.appcard.methodSelection(phone, "voice"); 23 }); 24 jQuery(document).on('click', '.overlay-exit', function (e) { 25 e.preventDefault(); 26 S.hideOverlay(); 27 }); 28 jQuery(document).on('click', '#acct_btn', function (e) { 29 e.preventDefault(); 30 S.showWaiting(); 31 S.appcard.updateAccount(); 32 }); 33 jQuery('#tpc_login_userpass').submit(function (e) { 34 jQuery('#tpc_login_userpass input').removeClass('idelay'); 35 S.appcard.validateEmail(jQuery('#ep_email')); 36 S.appcard.validatePassword(jQuery('#ep_password')); 37 38 if (jQuery('#tpc_login_userpass input.has-error').length > 0) { 39 e.preventDefault(); 40 } 41 42 jQuery('#tpc_login_userpass input').each(function () { 43 var $input = jQuery(this); 44 if ($input.hasClass('has-error')) { 45 $input.focus(); 46 return false; 47 } 48 }); 49 }); 50 jQuery('#tpc_login_phone').submit(function (e) { 51 $form = jQuery(this); 52 S.appcard.validateForm($form); 53 54 if (!$form.hasClass('form-valid')) { 55 e.preventDefault(); 56 } 57 }); 58 jQuery(document).on('click', '.tpc-submit-button', function () { 59 jQuery(this).parents('form').submit(); 60 }); 61 jQuery(document).on('click', '.multi-merchant a.link-mul', function (e) { 62 e.preventDefault(); 63 var store = jQuery('#login_store').val(); 64 var ref = jQuery(this).attr('href') + '&store=' + store; 65 window.location.href = ref; 66 }); 67 jQuery(document).on('input blur', '.form-input.required', function () { 68 var $element = jQuery(this); 69 70 if ($element.hasClass('invalid') || $element.hasClass('valid')) { 71 S.appcard.validateInput($element); 72 } 73 }); 74 jQuery(document).on('input', '#ep_email', function () { 75 var $element = jQuery(this); 76 77 if (!$element.hasClass('idelay')) { 78 S.appcard.validateEmail($element); 79 } 80 }); 81 jQuery(document).on('blur', '#ep_email', function () { 82 var $element = jQuery(this); 83 84 if ($element.val() !== "") { 85 $element.removeClass('idelay'); 86 } 87 88 if (!$element.hasClass('idelay')) { 89 S.appcard.validateEmail($element); 90 } 91 }); 92 jQuery(document).on('input', '#ep_password', function () { 93 var $element = jQuery(this); 94 95 if (!$element.hasClass('idelay')) { 96 S.appcard.validatePassword($element); 97 } 98 }); 99 jQuery(document).on('blur', '#ep_password', function () { 100 var $element = jQuery(this); 101 102 if ($element.val() !== "") { 103 $element.removeClass('idelay'); 104 } 105 106 if (!$element.hasClass('idelay')) { 107 S.appcard.validatePassword($element); 108 } 109 }); 110 }, 111 expandMethodSection: function () { 112 jQuery('.phone-method-area').fadeIn(); 113 }, 114 isValidEmailAddress: function (email) { 115 var pattern = new RegExp(/^([\w-\.\+]+@([\w-]+\.)+[\w-]{2,4})?$/); 116 return pattern.test(email); 117 }, 118 methodSelection: function (phone, method) { 119 if (!jQuery('#text-me-btn').isFullyVisible()) { 120 jQuery('.ll-login-container').first()[0].scrollIntoView(); 121 } 122 123 jQuery('.phone-verf-area').hide(); 124 jQuery('.phone-err-area').hide().text(''); 125 126 if (!S.appcard.validateForm(jQuery('#tpc_login_phone'))) { 127 return; 128 } 129 130 jQuery.ajax({ 131 type: "POST", 132 url: stcajax.ajaxurl, 133 data: {"action": "appcard_send_code", "phone": phone, "method": method, "nonce": stcajax.send_code_nonce}, 134 success: function (result) { 135 jQuery('.phone-err-area').hide(); 136 jQuery('.phone-verf-area').fadeIn(); 137 if (result && result.retry_after) { 138 S.appcard.startResendCooldown(result.retry_after); 139 } 140 }, 141 error: function (xhr, resp, text) { 142 var response = JSON.parse(xhr.responseText); 143 var retry = (response && response.retry_after) ? parseInt(response.retry_after, 10) : 0; 144 if (retry > 0) { 145 // In cooldown: a code was sent within the last cooldown window, so keep the 146 // code-entry field available (e.g. after a page refresh) and show the countdown 147 // -- otherwise a user who already has a code can't enter it. 148 jQuery('.phone-verf-area').fadeIn(); 149 S.appcard.startResendCooldown(retry); 150 } else { 151 jQuery('.phone-err-area').text(response.errors.message).fadeIn(); 152 } 153 } 154 }); 155 }, 156 startResendCooldown: function (seconds) { 157 var $btns = jQuery('#text-me-btn, #call-me-btn'); 158 var $note = jQuery('.phone-resend-note'); 159 160 if ($note.length === 0) { 161 $note = jQuery('<div class="phone-resend-note" style="text-align:center;margin-top:6px;font-size:14px;color:#333;"></div>'); 162 jQuery('.phone-method-area').append($note); 163 } 164 165 if (S.appcard._resendTimer) { 166 clearInterval(S.appcard._resendTimer); 167 } 168 169 $btns.prop('disabled', true).addClass('disabled'); 170 var remaining = parseInt(seconds, 10) || 0; 171 172 var tick = function () { 173 if (remaining <= 0) { 174 clearInterval(S.appcard._resendTimer); 175 S.appcard._resendTimer = null; 176 $btns.prop('disabled', false).removeClass('disabled'); 177 $note.text(''); 178 jQuery('.phone-err-area').hide().text(''); 179 return; 180 } 181 $note.html('You can request another code in <strong>' + remaining + 's</strong>'); 182 remaining -= 1; 183 }; 184 185 tick(); 186 S.appcard._resendTimer = setInterval(tick, 1000); 187 }, 188 validateInput: function ($input) {
189 var valid = true; 190 191 if ($input.hasClass('phone-mask')) { 192 if ($input.val() === '' || $input.val().length !== 14 || $input.val().indexOf('_') !== -1) { 193 valid = false; 194 } 195 } else if ($input.hasClass('pin-val')) { 196 if ($input.val() === '' || $input.val().length !== 4) { 197 valid = false; 198 } 199 } else { 200 if ($input.val() === '') { 201 valid = false; 202 } 203 } 204 205 if (valid) { 206 $input.removeClass('invalid').addClass('valid'); 207 } else { 208 $input.removeClass('valid').addClass('invalid'); 209 } 210 }, 211 validateForm: function ($form) { 212 var $inputs = $form.find('.form-input.required:visible'); 213 214 $inputs.each(function () { 215 S.appcard.validateInput(jQuery(this)); 216 }); 217 218 var valid = ($form.find('.form-input.required.invalid').length === 0) ? true : false; 219 if (valid) { 220 $form.removeClass('form-invalid').addClass('form-valid').find('.err-area').hide(); 221 } else { 222 $form.removeClass('form-valid').addClass('form-invalid').find('.err-area').text('Please fill in above fields.').fadeIn(); 223 } 224 225 return valid; 226 }, 227 validateEmail: function ($input) { 228 if ($input.val()) { 229 if (S.appcard.isValidEmailAddress($input.val())) { 230 $input.removeClass('has-error').siblings('.error-block').remove(); 231 } else { 232 var $errorBlock = $input.siblings('.error-block'); 233 234 if ($errorBlock.length > 0) { 235 $input.addClass('has-error').siblings('.error-block').text('Please enter a valid email address'); 236 } else { 237 $input.addClass('has-error').after('<span class="error-block" role="alert" aria-live="assertive">Please enter a valid email address</span>'); 238 } 239 } 240 } else { 241 var $errorBlock = $input.siblings('.error-block'); 242 243 if ($errorBlock.length > 0) { 244 $input.addClass('has-error').siblings('.error-block').text('Please enter your email address'); 245 } else { 246 $input.addClass('has-error').after('<span class="error-block" role="alert" aria-live="assertive">Please enter your email address</span>'); 247 } 248 } 249 }, 250 validatePassword: function ($input) { 251 if ($input.val()) { 252 $input.removeClass('has-error').parent().children('.error-block').remove(); 253 } else if ($input.siblings('.error-block').length === 0) { 254 $input.addClass('has-error').after('<span class="error-block" role="alert" aria-live="assertive">Please enter your password</span>'); 255 } 256 } 257}; 258 259jQuery.fn.isFullyVisible = function () { 260 var win = jQuery(window); 261 262 var viewport = { 263 top: win.scrollTop(), 264 left: win.scrollLeft() 265 }; 266 viewport.right = viewport.left + win.width(); 267 viewport.bottom = viewport.top + win.height(); 268 269 var elemtHeight = Math.round(this.height()); 270 271 var bounds = this.offset(); 272 bounds.top = bounds.top + elemtHeight; 273 bounds.right = bounds.left + this.outerWidth(); 274 bounds.bottom = bounds.top + this.outerHeight(); 275 276 return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); 277}; 278 279jQuery(document).ready(function () { 280 S.appcard._initialize(); 281 282 jQuery('#email').focus(); 283});
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.