1/* MueveTicket â Ãrea de Usuario JS v2.0 */ 2(function($) { 3 'use strict'; 4 5 var LOGIN_FORM = '#mt-login-form, #mt-header-login-form'; 6 var FORGOT_FORM = '#mt-forgot-form, #mt-header-forgot-form'; 7 var REGISTER_FORM = '#mt-register-form, #mt-header-register-form'; 8 9 $(document).on('click', '.mt-auth-tab', function() { 10 var tab = $(this).data('tab'); 11 $('.mt-auth-tab').removeClass('active'); 12 $(this).addClass('active'); 13 $('.mt-auth-panel').removeClass('active'); 14 $('#mt-tab-' + tab).addClass('active'); 15 }); 16 17 $(document).on('click', '.mt-pwd-toggle', function() { 18 var input = $(this).siblings('input'); 19 var type = input.attr('type') === 'password' ? 'text' : 'password'; 20 input.attr('type', type); 21 $(this).text(type === 'password' ? 'ð' : 'ð'); 22 }); 23 24 $(document).on('click', '#mt-show-forgot', function(e) { 25 e.preventDefault(); 26 $(LOGIN_FORM).hide(); 27 $(FORGOT_FORM).show(); 28 }); 29 30 $(document).on('click', '#mt-show-login', function(e) { 31 e.preventDefault(); 32 $(FORGOT_FORM).hide(); 33 $(LOGIN_FORM).show(); 34 }); 35 36 function showMsg(el, msg, type) { 37 if (!el.length) return; 38 el.text(msg).removeClass('error success').addClass(type).prop('hidden', false); 39 } 40 41 $(document).on('submit', LOGIN_FORM, function(e) { 42 e.preventDefault(); 43 var form = $(this); 44 var btn = form.find('button[type="submit"]'); 45 var msg = form.find('.mt-form-msg'); 46 47 btn.prop('disabled', true).text('Iniciando sesión...'); 48 49 $.post(mtSecutix.ajaxUrl, { 50 action: 'mt_secutix_login', 51 nonce: mtSecutix.nonce, 52 email: form.find('[name="email"]').val(), 53 password: form.find('[name="password"]').val(), 54 remember: form.find('[name="remember"]').is(':checked') ? 1 : 0, 55 }) 56 .done(function(res) { 57 if (res.success) { 58 showMsg(msg, 'â Sesión iniciada. Redirigiendo...', 'success'); 59 setTimeout(function() { 60 window.location.href = res.data.redirect || mtSecutix.accountUrl; 61 }, 800); 62 } else { 63 showMsg(msg, 'â ' + (res.data.message || 'Error al iniciar sesión.'), 'error'); 64 btn.prop('disabled', false).text('Iniciar sesión'); 65 } 66 }) 67 .fail(function() { 68 showMsg(msg, 'â Error de conexión. Inténtalo de nuevo.', 'error'); 69 btn.prop('disabled', false).text('Iniciar sesión'); 70 }); 71 }); 72 73 $(document).on('submit', FORGOT_FORM, function(e) { 74 e.preventDefault(); 75 var form = $(this); 76 var btn = form.find('button[type="submit"]'); 77 var msg = form.find('.mt-form-msg'); 78 79 btn.prop('disabled', true).text('Enviando...'); 80 81 $.post(mtSecutix.ajaxUrl, { 82 action: 'mt_secutix_forgot', 83 nonce: mtSecutix.nonce, 84 email: form.find('[name="email"]').val(), 85 }) 86 .done(function(res) { 87 if (res.success) { 88 showMsg(msg, 'â ' + res.data.message, 'success'); 89 } else { 90 showMsg(msg, 'â ' + (res.data.message || 'Error.'), 'error'); 91 } 92 btn.prop('disabled', false).text('Enviar enlace'); 93 }); 94 }); 95 96 $(document).on('submit', REGISTER_FORM, function(e) { 97 e.preventDefault(); 98 var form = $(this); 99 var btn = form.find('button[type="submit"]'); 100 var msg = form.find('.mt-form-msg'); 101 102 var pwd = form.find('[name="password"]').val(); 103 if (pwd.length < 8) { 104 showMsg(msg, 'â La contraseña debe tener al menos 8 caracteres.', 'error'); 105 return; 106 } 107 108 btn.prop('disabled', true).text('Creando cuenta...'); 109 110 $.post(mtSecutix.ajaxUrl, { 111 action: 'mt_secutix_register', 112 nonce: mtSecutix.nonce, 113 firstName: form.find('[name="firstName"]').val(), 114 lastName: form.find('[name="lastName"]').val(), 115 email: form.find('[name="email"]').val(), 116 phone: form.find('[name="phone"]').val(), 117 password: pwd, 118 }) 119 .done(function(res) { 120 if (res.success) { 121 showMsg(msg, 'â Cuenta creada. Redirigiendo...', 'success'); 122 setTimeout(function() { 123 window.location.href = res.data.redirect || mtSecutix.accountUrl; 124 }, 800); 125 } else { 126 showMsg(msg, 'â ' + (res.data.message || 'Error al crear la cuenta.'), 'error'); 127 btn.prop('disabled', false).text('Crear cuenta'); 128 } 129 }) 130 .fail(function() { 131 showMsg(msg, 'â Error de conexión.', 'error'); 132 btn.prop('disabled', false).text('Crear cuenta'); 133 }); 134 }); 135 136 $(document).on('click', '.mt-logout-btn', function(e) { 137 e.preventDefault(); 138 $.post(mtSecutix.ajaxUrl, { 139 action: 'mt_secutix_logout', 140 nonce: mtSecutix.nonce, 141 }) 142 .done(function(res) { 143 window.location.href = res.data.redirect || mtSecutix.loginUrl; 144 }); 145 }); 146 147})(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.