diff --git a/media/js/profile.js b/media/js/profile.js index cb2eb9e03d23ffef5cc7b0f3282bbf3c4bd79852..bd659d612bd000bcec793f5c248095a2e3ab5c69 100644 --- a/media/js/profile.js +++ b/media/js/profile.js @@ -1,39 +1,37 @@ -$(function() -{ - var jProfiler = $('#profileInfo').first(); +$(function () { + var jProfiler = $('#profileInfo').first(); var isOpened = false; var flag = false; + var jLogin = $('#login'); + var jPass = $('#password'); // Показ профиля при нажатии - $('#settingsButton').click(function () - { - $.get(URLdir + "window/settings", function(data){ + $('#settingsButton').click(function () { + $.get(URLdir + "window/settings", function (data) { wnd.open(JSON.parse(data)); }); }); - $(document).click(function() { - if (flag === true) { - flag = false; - } else if (isOpened === true) { - jProfiler.slideUp(200);//css('display', 'none'); - isOpened = false; - } + $(document).click(function () { + if (flag === true) { + flag = false; + } else if (isOpened === true) { + jProfiler.slideUp(200);//css('display', 'none'); + isOpened = false; + } }); - $(".profile_wrapper").click(function() { - flag = true; + $(".profile_wrapper").click(function () { + flag = true; }); - $('#username').click(function() { - flag = true; - if(isOpened) - { + $('#username').click(function () { + flag = true; + if (isOpened) { jProfiler.slideUp(200);//css('display', 'none'); isOpened = false; } - else - { + else { jProfiler.slideDown(200);//css('display', 'block'); isOpened = true; } @@ -44,55 +42,71 @@ $(function() $.ajax({ type: "POST", url: URLdir + "handler/Session/closeSession", - success: function(data) { - + 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() { + timer = setTimeout(function () { $.ajax({ type: "POST", - url: URLdir + "handler/Session/getSessionTime", - success: function(data) - { + url: URLdir + "handler/Session/getSessionTime", + success: function (data) { data = $.parseJSON(data); wait = parseInt(data, 10); if (wait <= 10) { closeSession(); - return; } else { - setSessionTimer(wait-10); + setSessionTimer(wait - 10); } } - }); - }, 1000*time); + }); + }, 1000 * time); } setSessionTimer(1); - -}); \ No newline at end of file + + + 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>