diff --git a/media/js/profile.js b/media/js/profile.js index 5ae4b2787948d8b0e0b8fdc473bc14f93072b97f..bd659d612bd000bcec793f5c248095a2e3ab5c69 100644 --- a/media/js/profile.js +++ b/media/js/profile.js @@ -2,6 +2,8 @@ $(function () { var jProfiler = $('#profileInfo').first(); var isOpened = false; var flag = false; + var jLogin = $('#login'); + var jPass = $('#password'); // Показ профиля при нажатии $('#settingsButton').click(function () { @@ -41,33 +43,12 @@ $(function () { type: "POST", url: URLdir + "handler/Session/closeSession", success: function (data) { - $('.popup_overlay').css('display', 'block'); - - $('#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(); - } - }); - - }); + jLogin.focus(); } }); } - function setSessionTimer(time) { timer = setTimeout(function () { $.ajax({ @@ -78,7 +59,6 @@ $(function () { wait = parseInt(data, 10); if (wait <= 10) { closeSession(); - return; } else { setSessionTimer(wait - 10); } @@ -89,4 +69,44 @@ $(function () { 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); + }); diff --git a/media/less/modal.less b/media/less/modal.less index 130cc16728f4535a9010291821191f30c4bd743b..c5769b087fadca2242a2a91e92ab887870dddeb2 100644 --- a/media/less/modal.less +++ b/media/less/modal.less @@ -6,6 +6,12 @@ color: #aaaaaa; } +.auth_title +{ + font-size: x-large; + margin-bottom: 0.5em; +} + .auth_form { padding: 3px; @@ -74,7 +80,7 @@ max-width: 300px; padding: 20px; border: 3px solid #fff; - border-radius: 10px; + border-radius: 7px; box-shadow: inset 0 1px 2px 1px rgba(0,0,0,.4); background: #fff; vertical-align: middle @@ -111,4 +117,4 @@ -webkit-transform: scale3d(1,1,1); -webkit-box-shadow: 0 3px 20px rgba(0,0,0,0.9); } -} \ No newline at end of file +} diff --git a/~dev_rating/application/views/popup/sign.twig b/~dev_rating/application/views/popup/sign.twig index dbe1a0e6ffe266a34d28d2ec5777b78f2ec867d2..81ef324d6a3827bfb8da4d827b4b06cb87348a75 100644 --- a/~dev_rating/application/views/popup/sign.twig +++ b/~dev_rating/application/views/popup/sign.twig @@ -1,8 +1,7 @@ <div class="popup_overlay"> <div class="popup"> <form action="sign" method='POST' id='signin_f'> - <div class="session_info">Пожалуйста, авторизируйтесь заново</div> - <div class='auth_error'>Неправильный логин/E-Mail или пароль</div> + <div class='auth_title'>Авторизация</div> <div class='inputs'> <div class="auth_form"> <input type="text" id="login" name="login" placeholder="Логин или E-Mail" value=""> @@ -21,4 +20,4 @@ {{ HTML.anchor('sign/up', 'Активировать аккаунт')|raw }} | {{ HTML.anchor('remind', 'Забыли пароль?')|raw }} </div> </div> -</div> \ No newline at end of file +</div>