Skip to content

Commit aa51204

Browse files
committed
Add anim in login page
1 parent 79bc2f2 commit aa51204

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

static/css/mpg.login.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11

2+
/**
3+
* @see https://teamtreehouse.com/community/shake-effect-with-javascript-only
4+
*/
5+
6+
@keyframes shake {
7+
10%, 90% {
8+
transform: translate3d(-1px, 0, 0);
9+
}
10+
11+
20%, 80% {
12+
transform: translate3d(2px, 0, 0);
13+
}
14+
15+
30%, 50%, 70% {
16+
transform: translate3d(-4px, 0, 0);
17+
}
18+
19+
40%, 60% {
20+
transform: translate3d(4px, 0, 0);
21+
}
22+
}
23+
24+
.apply-shake {
25+
animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
26+
}
27+
228
/**
329
* Based on a snippet made by Mutiullah Samim.
430
*

static/js/mpg.login.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
/**
3+
* MongoDB PHP GUI namespace.
4+
*
5+
* @type {object}
6+
*/
7+
var MPG = {};
8+
9+
/**
10+
* Event listeners sub-namespace.
11+
*
12+
* @type {object}
13+
*/
14+
MPG.eventListeners = {};
15+
16+
/**
17+
* Adds an event listener on "Login" button.
18+
*
19+
* @returns {void}
20+
*/
21+
MPG.eventListeners.addLogin = function() {
22+
23+
document.querySelector('.card').addEventListener('animationend', function(event) {
24+
25+
event.currentTarget.classList.remove('apply-shake');
26+
27+
});
28+
29+
document.querySelector('#mpg-login-button').addEventListener('click', function(_event) {
30+
31+
if ( document.querySelector('input[name="host"]').value === ''
32+
|| document.querySelector('input[name="port"]').value === '' )
33+
{
34+
document.querySelector('.card').classList.add('apply-shake');
35+
}
36+
37+
});
38+
39+
};
40+
41+
// When document is ready:
42+
window.addEventListener('DOMContentLoaded', function(_event) {
43+
44+
MPG.eventListeners.addLogin();
45+
46+
});

views/login.tpl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<link rel="stylesheet" href="<?php echo MPG_BASE_URL; ?>/static/css/bootstrap.min.css">
1212
<link rel="stylesheet" href="<?php echo MPG_BASE_URL; ?>/static/css/mpg.login.css">
1313

14+
<script src="<?php echo MPG_BASE_URL; ?>/static/js/mpg.login.js"></script>
15+
1416
</head>
1517

1618
<body>
@@ -77,7 +79,7 @@
7779
</div>
7880

7981
<div class="form-group">
80-
<input type="submit" name="login" value="Login" class="btn btn-primary float-right">
82+
<input id="mpg-login-button" type="submit" name="login" value="Login" class="btn btn-primary float-right">
8183
</div>
8284

8385
</form>

0 commit comments

Comments
 (0)