Created
June 4, 2012 19:53
-
-
Save zoghal/2870466 to your computer and use it in GitHub Desktop.
Ember.js login animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.LoginState = Ember.State.extend({ | |
enter: function() { | |
App.loginView = App.LoginView.create(); | |
App.loginView.appendTo('#content.container'); | |
}, | |
submit: function(a, params) { | |
App.loginView.loggingIn(); | |
var data = params.get('data'); | |
email = data.email; | |
password = data.password; | |
App.usersAdapter.login(email, password); | |
}, | |
userSigned: function(a, user) {}, | |
userFailed: function() { | |
App.loginView.loginFailed(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.LoginView = Ember.View.extend({ | |
templateName: 'login', | |
//Timer for button animation | |
timer: null, | |
loginButton: 'button#log-in', | |
loggingIn: function() { | |
this.timer = setTimeout("$(this.loginButton).button('loading')", 1000); | |
}, | |
loginFailed: function() { | |
var self = this; | |
// clear loggingIn timer for loading status. | |
clearTimeout(this.timer); | |
// reset button status | |
$(this.loginButton).button('reset'); | |
// setup tooltip for login button | |
$(this.loginButton).tooltip({ | |
delay: { show: 500, hide: 100 }, | |
title: 'Please check your credentials', | |
trigger: 'manual' | |
}); | |
//show tooptip | |
$(this.loginButton).tooltip('show'); | |
// after 3,5 sec close tooltip | |
setTimeout(function() { | |
$(self.loginButton).tooltip('hide'); | |
}, 3500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment