Navigation Menu

Skip to content

Commit

Permalink
Wrapping API calls in login(), triggering login and logout events
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Jul 7, 2010
1 parent d83aca9 commit dcc09ab
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions public/js/jquery.facehugger.js
Expand Up @@ -33,7 +33,9 @@ jQuery.fb = new function() {
};

function api() {
fbAPI.apply(this, compressArgs(arguments));
login(function() {
fbAPI.apply(this, compressArgs(arguments));
});
return me;
}

Expand Down Expand Up @@ -199,13 +201,19 @@ jQuery.fb = new function() {
else if (typeof args[0] == 'string')
options = { perms: args.join(',') };

fbLogin(fn, options);
fbLogin(function(response) {
events.trigger('login');
if (fn) fn(response);
}, options);

return me;
}

function logout(fn) {
fbLogout(fn);
fbLogout(function(response) {
events.trigger('logout');
if (fn) fn(response);
});
return me;
}

Expand Down Expand Up @@ -237,7 +245,11 @@ jQuery.fb = new function() {
type = null;
}

fbGetLoginStatus(fn);
fbGetLoginStatus(function(response) {
if (response.status == 'notConnected')
response.status = 'not_connected';
if (fn) fn(response);
});

return me;
}
Expand Down

0 comments on commit dcc09ab

Please sign in to comment.