Skip to content

Commit

Permalink
[WebUI IntelliHome#7] Added a layout for login form
Browse files Browse the repository at this point in the history
  • Loading branch information
skullbocks committed Jul 13, 2014
1 parent 43bc101 commit a215a66
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 1 deletion.
128 changes: 127 additions & 1 deletion assets/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,130 @@ Works 3.2+ Works 9.5+ 9+ Works Works
#iso .col-md-3, #iso .col-lg-3 {
width: 400px;
}
}
}

/*
Custom login Style
*/


#output{
position: absolute;
width: 300px;
top: -75px;
left: 0;
color: #fff;
}

#output.alert-success{
background: rgb(25, 204, 25);
}

#output.alert-danger{
background: rgb(228, 105, 105);
}


.login-container::before,.login-container::after{
content: "";
position: absolute;
width: 100%;height: 100%;
top: 3.5px;left: 0;
background: #fff;
z-index: -1;
-webkit-transform: rotateZ(4deg);
-moz-transform: rotateZ(4deg);
-ms-transform: rotateZ(4deg);
border: 1px solid #ccc;

}

.login-container::after{
top: 5px;
z-index: -2;
-webkit-transform: rotateZ(-2deg);
-moz-transform: rotateZ(-2deg);
-ms-transform: rotateZ(-2deg);

}

.avatar{
width: 100px;height: 100px;
margin: 10px auto 30px;
border-radius: 100%;
border: 2px solid #aaa;
background-size: cover;
}

.form-box input{
width: 100%;
padding: 10px;
text-align: center;
height:40px;
border: 1px solid #ccc;;
background: #fafafa;
transition:0.2s ease-in-out;

}

.form-box input:focus{
outline: 0;
background: #eee;
}

.form-box input[type="text"]{
border-radius: 5px 5px 0 0;
text-transform: lowercase;
}

.form-box input[type="password"]{
border-radius: 0 0 5px 5px;
border-top: 0;
}

.form-box button.login{
margin-top:15px;
padding: 10px 20px;
}

.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

@-webkit-keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translateY(20px);
transform: translateY(20px);
}

100% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
}
}

@keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translateY(20px);
-ms-transform: translateY(20px);
transform: translateY(20px);
}

100% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
}

.fadeInUp {
-webkit-animation-name: fadeInUp;
animation-name: fadeInUp;
}
61 changes: 61 additions & 0 deletions assets/public/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
$(function(){
var userField = $("input[name=username]");
var passwordField = $("input[name=password]");
$('button[type="submit"]').click(function(e) {
e.preventDefault();
if (userField.val() == "") {
//remove success mesage replaced with error message
$("#output").removeClass(' alert alert-success');
$("#output").addClass("alert alert-danger animated fadeInUp").html("Did you forget to enter username?");
} else if (passwordField.val() == "") {
//remove success mesage replaced with error message
$("#output").removeClass(' alert alert-success');
$("#output").addClass("alert alert-danger animated fadeInUp").html("Did you forget to enter password?");
} else {
var loginRequest = $.ajax({
type: "POST",
url : '/auth',
data : {username : userField.val(), password : passwordField.val()},
dataType : 'json', //gives back a JSON object
});
loginRequest.done(function( msg ) {
//Display a message for login
/*
$("#output").addClass("alert alert-success animated fadeInUp").html("Welcome back " + "<span style='text-transform:uppercase'>" + userField.val() + "</span>");
$("#output").removeClass(' alert-danger');
$("input").css({
"height":"0",
"padding":"0",
"margin":"0",
"opacity":"0"
});
*/
//Change button
/*
$('button[type="submit"]').html("continue")
.removeClass("btn-info")
.addClass("btn-default").click(function(){
$("input").css({
"height":"auto",
"padding":"10px",
"opacity":"1"
}).val("");
});
*/

//Display user avatar
/*
$(".avatar").css({
"background-image": "url('http://api.randomuser.me/0.3.2/portraits/women/35.jpg')"
});
*/
});
loginRequest.fail(function() {
//remove success mesage replaced with error message
$("#output").removeClass(' alert alert-success');
$("#output").addClass("alert alert-danger animated fadeInUp").html("Server have some trouble!");
});

}
});
});
13 changes: 13 additions & 0 deletions assets/templates/components/login.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="container">
<div class="login-container">
<div id="output"></div>
<div class="avatar"></div>
<div class="form-box">
<form action="" method="">
%= text_field 'username', type => 'text', required => "true", class=> "form-control", placeholder=> "username"
%= password_field 'password', required => "true", class=> "form-control" , placeholder=>"password"
%= submit_button 'Login', class => 'btn btn-info btn-block login'
</form>
</div>
</div>
</div>

0 comments on commit a215a66

Please sign in to comment.