Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Triggering login event on init if logged in, fixes for cachedAPI

  • Loading branch information...
commit 63fe5d11be4baf8edf01db3a7797e727d818398b 1 parent b3735fb
Winton Welsh authored
Showing with 18 additions and 10 deletions.
  1. +14 −7 public/js/jquery.facehugger.js
  2. +4 −3 public/js/qunit.facehugger.js
21 public/js/jquery.facehugger.js
View
@@ -60,19 +60,26 @@ jQuery.fb = new function() {
response.status = 'not_connected';
events.trigger('status_' + response.status, response);
});
+ FB.getLoginStatus(function(response) {
+ if (response.status == 'connected')
+ events.trigger('login');
+ });
});
}
function cachedAPI(path, values, method, data, fn) {
var key = 'fb' + path.replace(/\W/g, '_');
- if (values == undefined)
- return fromJson(cookie(key));
- else {
- var args = compressArgs([ path, method, data, fn ]);
-
- if (typeof args[args.length-1] == 'function')
- fn = args[args.length-1];
+ var args = compressArgs([ path, values, method, data, fn ]);
+
+ if (typeof args[args.length-1] == 'function')
+ fn = args[args.length-1];
+ if (values.constructor != Array)
+ values = this.cached_values;
+
+ if (cookie(key))
+ fn(fromJson(cookie(key)));
+ else {
var replacement_fn = function(response) {
var data = {};
$.each(values, function(i, item) {
7 public/js/qunit.facehugger.js
View
@@ -263,9 +263,10 @@ $(function() {
equals(typeof response.id, 'string');
equals(typeof response.name, 'string');
- var cached = $.fb.cachedAPI('/me');
- equals(typeof cached.id, 'string');
- equals(typeof cached.name, 'string');
+ $.fb.cachedAPI('/me', function() {
+ equals(typeof cached.id, 'string');
+ equals(typeof cached.name, 'string');
+ });
});
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.