Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define(['backbone', 'facebook'], function (backbone, facebook) {
- var view = backbone.View.extend({
- el: '.navbar .login',
- message: this.$('.message'),
- button: this.$("button"),
- events: { "click button": "login" },
- initialize: function () {
- this.login();
- },
- authInfo: function (callback, id) {
- facebook.status(function (status) {
- if (status.status == 'connected') facebook.info(callback, id);
- else
- facebook.login(function (response) {
- if (response.authResponse) facebook.info(callback, id);
- });
- });
- },
- login: function () {
- var me = this;
- this.authInfo(function (user) {
- var compiledTemplate = _.template($('#login-message').html(), user);
- me.message.html(compiledTemplate);
- me.button.hide();
- me.message.find('i').click(function () {
- facebook.logout();
- me.button.show().siblings().empty();
- });
- });
- }
- });
- return view;
- });
Add Comment
Please, Sign In to add comment