Commit 06e1d4c2 authored by Alina Habibulina's avatar Alina Habibulina

+auth form v3

parent 809c0b06
.submit { .login-form{
background-color: #e7e7e7; left: 50%;
color: black; transform: translate(-50%, 0);
border: none; width: 320px;
padding: 15px 32px; height: 230px;
text-align: center; background-color: white;
text-decoration: none; position: absolute;
border-radius: 5px; border-color: #24282B;
display: inline-block; border-style: none solid solid;
font-size: 16px; border-width: 1px;
top: 150px;
} }
.login-form { .header{
position: relative; background-color: #4C5256;
width: 200px; position: relative;
height: 250px; padding: 12px;
margin-left: auto; color: white;
margin-right: auto; font-family: arial, tahoma, sans-serif;
padding: 15px 25px 0 25px; font-size: 13pt;
margin-top: 15px; font-weight: bold;
cursor: default; cursor: pointer;
background-color: #141517;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0px 1px 1px 0px rgba(255,255,255, .2), inset 0px 1px 1px 0px rgb(0,0,0);
-moz-box-shadow: 0px 1px 1px 0px rgba(255,255,255, .2), inset 0px 1px 1px 0px rgb(0,0,0);
box-shadow: 0px 1px 1px 0px rgba(255,255,255, .2), inset 0px 1px 1px 0px rgb(0,0,0);
} }
.login-form h3 { .error{
line-height: 20px; margin-top: 5px;
font-family: 'Myriad Pro', sans-serif; color: red;
font-size: 22px; font-family: arial, tahoma, sans-serif;
font-weight: normal; font-size: 15pt;
color: #e4e4e4;
} }
.login-form input[type=text], .login{
.login-form input[type=password]{ position: static;
line-height: 14px; margin-top: 25px;
margin: 10px 0; width: 250px;
padding: 6px 15px; display: inline-block;
border: 0; height: 20px;
outline: none; size: 50px;
font-family: Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-shadow: 0px 1px 1px rgba(255,255,255, .2);
-webkit-border-radius: 26px;
-moz-border-radius: 26px;
border-radius: 26px;
-webkit-transition: all .15s ease-in-out;
-moz-transition: all .15s ease-in-out;
transition: all .15s ease-in-out;
} }
.login-form input[type=text], .password {
.login-form input[type=password]{ position: static;
color: #686868; margin-top: 15px;
width: 170px; width: 250px;
-webkit-box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6); display: inline-block;
-moz-box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6); height: 20px;
box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6);
background: #989898;
background: -moz-linear-gradient(top, #ffffff 0%, #989898 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#989898));
background: -webkit-linear-gradient(top, #ffffff 0%,#989898 100%);
background: -o-linear-gradient(top, #ffffff 0%,#989898 100%);
background: -ms-linear-gradient(top, #ffffff 0%,#989898 100%);
background: linear-gradient(top, #ffffff 0%,#989898 100%);
} }
.login-form input[type=text]:hover, .submit{
.login-form input[type=password]:hover { margin-top: 15px;
-webkit-box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6), 0px 0px 5px rgba(255,255,255, .5); width: 100px;
-moz-box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6), 0px 0px 5px rgba(255,255,255, .5); position: relative;
box-shadow: inset 1px 1px 1px 0px rgba(255,255,255, .6), 0px 0px 5px rgba(255,255,255, .5); height: 35px;
} border-radius: 5px;
background-color: #49b785;
.login-form input[type=text]:focus, border-color: #49b785;
.login-form input[type=password]:focus { color: #ffffff;
background: #e1e1e1;
background: -moz-linear-gradient(top, #ffffff 0%, #e1e1e1 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e1e1e1));
background: -webkit-linear-gradient(top, #ffffff 0%,#e1e1e1 100%);
background: -o-linear-gradient(top, #ffffff 0%,#e1e1e1 100%);
background: -ms-linear-gradient(top, #ffffff 0%,#e1e1e1 100%);
background: linear-gradient(top, #ffffff 0%,#e1e1e1 100%);
} }
\ No newline at end of file
...@@ -18,16 +18,6 @@ ...@@ -18,16 +18,6 @@
<div id ="form_player_container" align ="center"> <div id ="form_player_container" align ="center">
<div id ="form_player_div" ></div> <div id ="form_player_div" ></div>
</div> </div>
<div id="authForm"></div>
<div class ="login-form" align ="center">
<form id ="authorization">
<p><h3>Please, log in: </h3>
<div class ="infoInput">
<p><input type ="text" id ="login" name ="login" placeholder ="Username" size ="20" required></p>
<p><input type ="password" id ="password" name ="password" placeholder ="Password" size ="20" required></p>
</div>
<input type ="submit" id ="submit" class ="submit" align ="center" value ="Submit"></button>
</form>
</div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -17,36 +17,83 @@ var portal = { ...@@ -17,36 +17,83 @@ var portal = {
portal.player = AS.FORMS.createPlayer(); portal.player = AS.FORMS.createPlayer();
portal.player.showFormByCode(formCode); portal.player.showFormByCode(formCode);
portal.player.view.appendTo($('#form_player_div')); portal.player.view.appendTo($('#form_player_div'));
},
showMessage : function(message) {
alert(message);
} }
}; };
AS.SERVICES.unAuthorized = function() AS.SERVICES.unAuthorized = function()
{ {
portal.showMessage("Authorization Error!"); CreateAuthForm();
location.reload();
}; };
function CreateAuthForm(){
var forma = document.createElement("form");
forma.className = "login-form";
forma.setAttribute('id',"login-form");
forma.setAttribute('align',"center");
var authHeader = document.createTextNode('Введите логин и пароль');
var authErr = document.createTextNode('Неверный логин или пароль');
var Hdiv = document.createElement("div");
Hdiv.className = "header";
Hdiv.appendChild(authHeader);
var Ediv = document.createElement("div");
Ediv.className = "error";
Ediv.appendChild(authErr);
Ediv.setAttribute('id',"error");
var textInp = document.createElement("input");
textInp.className = "login";
textInp.setAttribute('type',"text");
textInp.setAttribute('name',"login");
textInp.setAttribute('id',"login");
textInp.setAttribute('placeholder',"Логин");
textInp.setAttribute('align',"center");
var pasInp = document.createElement("input");
pasInp.className = "password";
pasInp.setAttribute('type',"password");
pasInp.setAttribute('name',"password");
pasInp.setAttribute('id',"password");
pasInp.setAttribute('placeholder',"Пароль");
pasInp.setAttribute('align',"center");
var submitBtn = document.createElement("input");
submitBtn.className = "submit";
submitBtn.setAttribute('type',"submit");
submitBtn.setAttribute('value',"Войти");
submitBtn.setAttribute('id',"submit");
submitBtn.setAttribute('align',"center");
var addHandlers = function(){ forma.appendChild(Hdiv);
forma.appendChild(Ediv);
forma.appendChild(textInp);
forma.appendChild(pasInp);
forma.appendChild(submitBtn);
document.getElementById("authForm").appendChild(forma);
authFunc();
};
var authFunc = function(){
jQuery(".submit").on( "click", function(event){ jQuery(".submit").on( "click", function(event){
AS.OPTIONS.login = $("input#login").val(); AS.OPTIONS.login = $("input#login").val();
AS.OPTIONS.password = $("input#password").val(); AS.OPTIONS.password = $("input#password").val();
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api', xhr); AS.FORMS.ApiUtils.simpleAsyncGet('rest/api', xhr);
if (xhr.status == "401") { if (xhr.status != 200) {
AS.SERVICES.unAuthorized();
} else {
$(".login-form").remove();
$(".form_player_container").show(); $(".form_player_container").show();
portal.createPlayer("timesheet"); portal.createPlayer("timesheet");
$(".login-form").remove();
} else {
CreateAuthForm();
} }
}); });
} };
$(document).ready(function(){ $(document).ready(function(){
addHandlers(); CreateAuthForm();
}); $(".error").hide();
\ No newline at end of file });
Markdown is supported
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