0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #654 from JohnONolan/center-login

Center login
This commit is contained in:
Hannah Wolfe 2013-09-08 11:33:34 -07:00
commit 61e5212fd7
8 changed files with 25 additions and 43 deletions

View file

@ -19,15 +19,17 @@
} }
main { main {
top: 0; top: 15px;
} }
}//.ghost-login }//.ghost-login
.login-box { .login-box {
max-width: 530px; max-width: 530px;
height: 90%;
margin: 0 auto; margin: 0 auto;
padding: 0; padding: 0;
display: none; display: table;
@include breakpoint(630px) { @include breakpoint(630px) {
max-width: 264px; max-width: 264px;
@ -39,6 +41,8 @@
@include box-sizing(border-box); @include box-sizing(border-box);
max-width: 530px; max-width: 530px;
color: lighten($midgrey, 15%); color: lighten($midgrey, 15%);
display: table-cell;
vertical-align: middle;
@include breakpoint(630px) { @include breakpoint(630px) {
max-width: 264px; max-width: 264px;

View file

@ -19,15 +19,15 @@
}, },
signup: function () { signup: function () {
Ghost.currentView = new Ghost.Views.Signup({ el: '.js-login-container' }); Ghost.currentView = new Ghost.Views.Signup({ el: '.js-login-box' });
}, },
login: function () { login: function () {
Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-container' }); Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-box' });
}, },
forgotten: function () { forgotten: function () {
Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-login-container' }); Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-login-box' });
}, },
blog: function () { blog: function () {

View file

@ -7,6 +7,6 @@
</div> </div>
<button class="button-save" type="submit">Log in</button> <button class="button-save" type="submit">Log in</button>
<section class="meta"> <section class="meta">
<a class="forgotten-password" href="/ghost/forgotten/">Forgotten password?</a> &bull; <a href="/ghost/signup/">Register new user</a> <a class="forgotten-password" href="/ghost/forgotten/">Forgotten password?</a>{{! &bull; <a href="/ghost/signup/">Register new user</a>}}
</section> </section>
</form> </form>

View file

@ -6,37 +6,9 @@
Ghost.SimpleFormView = Ghost.View.extend({ Ghost.SimpleFormView = Ghost.View.extend({
initialize: function () { initialize: function () {
this.render(); this.render();
$(window).trigger('resize'); $(".js-login-box").fadeIn(500, function () {
},
afterRender: function () {
var self = this;
$(window).on('resize', self.centerOnResize);
$(window).one('centered', self.fadeInAndFocus);
},
fadeInAndFocus: function () {
$(".js-login-container").fadeIn(750, function () {
$("[name='email']").focus(); $("[name='email']").focus();
}); });
},
centerOnResize: _.debounce(function (e) {
var container = $(".js-login-container");
container.css({
'position': 'relative'
}).animate({
'top': Math.round($(window).height() / 2) - container.outerHeight() / 2 + 'px'
});
$(window).trigger("centered");
}, 100),
remove: function () {
var self = this;
$(window).off('resize', self.centerOnResize);
$(window).off('centered', self.fadeInAndFocus);
} }
}); });

View file

@ -1,4 +1,4 @@
{{!< default}} {{!< default}}
<section class="login-box js-login-container"> <section class="login-box js-login-box">
</section> </section>

View file

@ -1,4 +1,4 @@
{{!< default}} {{!< default}}
<section class="login-box js-login-container"> <section class="login-box js-login-box">
</section> </section>

View file

@ -15,12 +15,12 @@ casper.test.begin('Ensure Session is Killed', 1, function suite(test) {
casper.test.begin('Ensure a User is Registered', 2, function suite(test) { casper.test.begin('Ensure a User is Registered', 2, function suite(test) {
test.filename = 'login_user_registered_test.png'; test.filename = 'login_user_registered_test.png';
casper.start(url + 'ghost/signup/'); casper.start(url + 'ghost/signup/').viewport(1280, 1024);
casper.waitFor(function checkOpaque() { casper.waitFor(function checkOpaque() {
return this.evaluate(function () { return this.evaluate(function () {
var loginBox = document.querySelector('.login-box'); var loginBox = document.querySelector('.login-box');
return window.getComputedStyle(loginBox).getPropertyValue('display') === "block" return window.getComputedStyle(loginBox).getPropertyValue('display') === "table"
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1"; && window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
}); });
}, function then() { }, function then() {
@ -90,11 +90,13 @@ casper.test.begin("Can't spam it", 4, function suite(test) {
return this.evaluate(function () { return this.evaluate(function () {
var loginBox = document.querySelector('.login-box'); var loginBox = document.querySelector('.login-box');
return window.getComputedStyle(loginBox).getPropertyValue('display') === "block" return window.getComputedStyle(loginBox).getPropertyValue('display') === "table"
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1"; && window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
}); });
}, function then() { }, function then() {
this.fill("#login", falseUser, true); this.fill("#login", falseUser, true);
}, function onTimeout() {
test.fail('Sign in form didn\'t fade in.');
}); });
casper.wait(200, function doneWait() { casper.wait(200, function doneWait() {
@ -109,6 +111,10 @@ casper.test.begin("Can't spam it", 4, function suite(test) {
test.assert(false, 'Spamming the login did not result in an error notification'); test.assert(false, 'Spamming the login did not result in an error notification');
}); });
// This test causes the spam notification
// add a wait to ensure future tests don't get tripped up by this.
casper.wait(1000);
casper.run(function () { casper.run(function () {
test.done(); test.done();
}); });
@ -124,7 +130,7 @@ casper.test.begin("Can login to Ghost", 4, function suite(test) {
casper.waitFor(function checkOpaque() { casper.waitFor(function checkOpaque() {
return casper.evaluate(function () { return casper.evaluate(function () {
var loginBox = document.querySelector('.login-box'); var loginBox = document.querySelector('.login-box');
return window.getComputedStyle(loginBox).getPropertyValue('display') === "block" return window.getComputedStyle(loginBox).getPropertyValue('display') === "table"
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1"; && window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
}); });
}, function then() { }, function then() {

View file

@ -43,7 +43,7 @@ casper.test.begin("Can't spam signin", 3, function suite(test) {
casper.waitFor(function checkOpaque() { casper.waitFor(function checkOpaque() {
return this.evaluate(function () { return this.evaluate(function () {
var loginBox = document.querySelector('.login-box'); var loginBox = document.querySelector('.login-box');
return window.getComputedStyle(loginBox).getPropertyValue('display') === "block" return window.getComputedStyle(loginBox).getPropertyValue('display') === "table"
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1"; && window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
}); });
}, function then() { }, function then() {