diff --git a/assets/public/css/style.css b/assets/public/css/style.css index 163f28e..03c2d1c 100644 --- a/assets/public/css/style.css +++ b/assets/public/css/style.css @@ -49,4 +49,130 @@ Works 3.2+ Works 9.5+ 9+ Works Works #iso .col-md-3, #iso .col-lg-3 { width: 400px; } -} \ No newline at end of file +} + +/* + 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; +} diff --git a/assets/public/js/script.js b/assets/public/js/script.js index e69de29..c9c496b 100644 --- a/assets/public/js/script.js +++ b/assets/public/js/script.js @@ -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 " + "" + userField.val() + ""); + $("#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!"); + }); + + } + }); +}); diff --git a/assets/templates/components/login.html.ep b/assets/templates/components/login.html.ep new file mode 100644 index 0000000..f91caf2 --- /dev/null +++ b/assets/templates/components/login.html.ep @@ -0,0 +1,13 @@ +
+
+
+
+
+
+ %= 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' +
+
+
+
\ No newline at end of file