105 lines
2.3 KiB
JavaScript
105 lines
2.3 KiB
JavaScript
$(document).ready(function(){
|
|
if (document.getElementById('email'))
|
|
document.getElementById('email').focus();
|
|
});
|
|
|
|
|
|
function displayForgotPassword()
|
|
{
|
|
$('#error').hide();
|
|
$("#login").flip({
|
|
direction:'tb',
|
|
color : '#FFF',
|
|
content: $('#forgot_password')
|
|
})
|
|
}
|
|
|
|
function doAjaxLogin()
|
|
{
|
|
$('#error').hide();
|
|
$('#ajax-loader').fadeIn('slow', function () {
|
|
$.ajax({
|
|
type:"POST",
|
|
url: "ajax-tab.php",
|
|
async: true,
|
|
dataType: "json",
|
|
data : {
|
|
ajax: "1",
|
|
token: "",
|
|
controller: "AdminLogin",
|
|
submitLogin: "1",
|
|
passwd : $('#passwd').val(),
|
|
email : $('#email').val()
|
|
},
|
|
success : function(jsonData)
|
|
{
|
|
if (jsonData.hasErrors)
|
|
{
|
|
displayErrors(jsonData.errors);
|
|
$('#login').effect("shake", { times:3 }, 300);
|
|
}
|
|
else
|
|
{
|
|
window.location.href = jsonData.redirect;
|
|
}
|
|
},
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|
$('#error').html('<h3>TECHNICAL ERROR:</h3><p>Details: Error thrown: ' + XMLHttpRequest + '</p><p>Text status: ' + textStatus + '</p>');
|
|
$('#error').fadeIn();
|
|
$('#ajax-loader').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
function doAjaxForgot()
|
|
{
|
|
$('#error').hide();
|
|
$('#ajax-loader').fadeIn('slow', function () {
|
|
$.ajax({
|
|
type:"POST",
|
|
url: "ajax-tab.php",
|
|
async: true,
|
|
dataType: "json",
|
|
data : {
|
|
ajax: "1",
|
|
token: "",
|
|
controller: "AdminLogin",
|
|
submitForgot: "1",
|
|
email_forgot: $('#email_forgot').val()
|
|
},
|
|
success : function(jsonData)
|
|
{
|
|
if (jsonData.hasErrors)
|
|
{
|
|
displayErrors(jsonData.errors);
|
|
$('#login').effect("shake", { times:3 }, 300);
|
|
}
|
|
else
|
|
{
|
|
window.location.href = jsonData.redirect;
|
|
}
|
|
},
|
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|
$('#error').html('<h3>TECHNICAL ERROR:</h3><p>Details: Error thrown: ' + XMLHttpRequest + '</p><p>Text status: ' + textStatus + '</p>');
|
|
$('#error').fadeIn();
|
|
$('#ajax-loader').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function displayErrors(errors)
|
|
{
|
|
str_errors = '<h3>'+(errors.length > 1 ? there_are : there_is )+' '+errors.length+' '+(errors.length > 1 ? label_errors : label_error )+'</h3><ol>';
|
|
for(error in errors)
|
|
//IE6 bug fix
|
|
if(error != 'indexOf')
|
|
str_errors += '<li>'+errors[error] + '</li>';
|
|
$('#ajax-loader').fadeOut('slow');
|
|
$('#error').html(str_errors+'</ol>');
|
|
$('#error').fadeIn();
|
|
}
|
|
|