Skip to content

Instantly share code, notes, and snippets.

@zoghal
Created June 4, 2012 19:53
Show Gist options
  • Save zoghal/2870466 to your computer and use it in GitHub Desktop.
Save zoghal/2870466 to your computer and use it in GitHub Desktop.
Ember.js login animations
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();
}
});
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