Skip to content
Snippets Groups Projects
Commit 946fc0c5 authored by mary.vtyurina's avatar mary.vtyurina Committed by xamgore
Browse files

Authorization popup window improvements

* Auto focus to the login text field
* Authorization by pressing "Enter" button
* Changed window title
parent 7021cb1c
Branches
Tags
No related merge requests found
...@@ -2,6 +2,8 @@ $(function () { ...@@ -2,6 +2,8 @@ $(function () {
var jProfiler = $('#profileInfo').first(); var jProfiler = $('#profileInfo').first();
var isOpened = false; var isOpened = false;
var flag = false; var flag = false;
var jLogin = $('#login');
var jPass = $('#password');
// Показ профиля при нажатии // Показ профиля при нажатии
$('#settingsButton').click(function () { $('#settingsButton').click(function () {
...@@ -41,33 +43,12 @@ $(function () { ...@@ -41,33 +43,12 @@ $(function () {
type: "POST", type: "POST",
url: URLdir + "handler/Session/closeSession", url: URLdir + "handler/Session/closeSession",
success: function (data) { success: function (data) {
$('.popup_overlay').css('display', 'block'); $('.popup_overlay').css('display', 'block');
jLogin.focus();
$('#signin_b').click(function () {
$.post(URLdir + 'handler/sign/in', {
'login': $('#login').val(),
'password': $.sha1($('#password').val())
},
function (data) {
data = $.parseJSON(data);
if (data.success === true) {
$('.popup_overlay').css('display', 'none');
//location.reload();
setSessionTimer(15);
}
else {
$('.auth_error').show();
}
});
});
} }
}); });
} }
function setSessionTimer(time) { function setSessionTimer(time) {
timer = setTimeout(function () { timer = setTimeout(function () {
$.ajax({ $.ajax({
...@@ -78,7 +59,6 @@ $(function () { ...@@ -78,7 +59,6 @@ $(function () {
wait = parseInt(data, 10); wait = parseInt(data, 10);
if (wait <= 10) { if (wait <= 10) {
closeSession(); closeSession();
return;
} else { } else {
setSessionTimer(wait - 10); setSessionTimer(wait - 10);
} }
...@@ -89,4 +69,44 @@ $(function () { ...@@ -89,4 +69,44 @@ $(function () {
setSessionTimer(1); setSessionTimer(1);
function authorize(login, pass) {
$.post(URLdir + 'handler/sign/in', {
'login': login,
'password': $.sha1(pass)
},
function (data) {
data = $.parseJSON(data);
if (data.success) {
$('.popup_overlay').hide();
setSessionTimer(15);
} else {
$('.auth_error').show();
}
});
}
function checkFieldsAndAuthorize() {
var login = jLogin.val();
var pass = jPass.val();
if (login.length > 0 && pass.length > 0) {
authorize(login, pass);
} else {
!login.length ? jLogin.focus() : jPass.focus();
}
}
jLogin.keypress(function (event) {
if (event.keyCode == 13)
checkFieldsAndAuthorize();
});
jPass.keypress(function (event) {
if (event.keyCode == 13)
checkFieldsAndAuthorize();
});
$('#signin_b').click(checkFieldsAndAuthorize);
}); });
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
color: #aaaaaa; color: #aaaaaa;
} }
.auth_title
{
font-size: x-large;
margin-bottom: 0.5em;
}
.auth_form .auth_form
{ {
padding: 3px; padding: 3px;
...@@ -74,7 +80,7 @@ ...@@ -74,7 +80,7 @@
max-width: 300px; max-width: 300px;
padding: 20px; padding: 20px;
border: 3px solid #fff; border: 3px solid #fff;
border-radius: 10px; border-radius: 7px;
box-shadow: inset 0 1px 2px 1px rgba(0,0,0,.4); box-shadow: inset 0 1px 2px 1px rgba(0,0,0,.4);
background: #fff; background: #fff;
vertical-align: middle vertical-align: middle
...@@ -111,4 +117,4 @@ ...@@ -111,4 +117,4 @@
-webkit-transform: scale3d(1,1,1); -webkit-transform: scale3d(1,1,1);
-webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9); -webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9);
} }
} }
\ No newline at end of file
<div class="popup_overlay"> <div class="popup_overlay">
<div class="popup"> <div class="popup">
<form action="sign" method='POST' id='signin_f'> <form action="sign" method='POST' id='signin_f'>
<div class="session_info">Пожалуйста, авторизируйтесь заново</div> <div class='auth_title'>Авторизация</div>
<div class='auth_error'>Неправильный логин/E-Mail или пароль</div>
<div class='inputs'> <div class='inputs'>
<div class="auth_form"> <div class="auth_form">
<input type="text" id="login" name="login" placeholder="Логин или E-Mail" value=""> <input type="text" id="login" name="login" placeholder="Логин или E-Mail" value="">
...@@ -21,4 +20,4 @@ ...@@ -21,4 +20,4 @@
{{ HTML.anchor('sign/up', 'Активировать аккаунт')|raw }} | {{ HTML.anchor('remind', 'Забыли пароль?')|raw }} {{ HTML.anchor('sign/up', 'Активировать аккаунт')|raw }} | {{ HTML.anchor('remind', 'Забыли пароль?')|raw }}
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment