Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add facebook feature to tests (App ID removed)

  • Loading branch information...
commit be00acd00370091db125cbaa7ecfae7525e6bb26 1 parent 7cc2eee
@yurenju yurenju authored committed
Showing with 62 additions and 1 deletion.
  1. +2 −0  jquery.getcontent.js
  2. +60 −1 tests/jquery.getcontent.html
View
2  jquery.getcontent.js
@@ -167,11 +167,13 @@ $.getContent = function (source, options) {
$.getContent.feedSupported = !!Array.prototype.forEach;
$.getContent.htmlSupported = true;
+$.getContent.fbSupported = true;
$.getContent.fileSupported = !!window.FileReader;
$.getContentSupported = (
$.getContent.feedSupported
&& $.getContent.htmlSupported
&& $.getContent.fileSupported
+ && $.getContent.fbSupported
);
})(jQuery);
View
61 tests/jquery.getcontent.html
@@ -22,6 +22,7 @@
<p id="feedSupported">$.getContent.feedSupported</p>
<p id="htmlSupported">$.getContent.htmlSupported</p>
<p id="fileSupported" >$.getContent.fileSupported</p>
+<p id="fbSupported" >$.getContent.fbSupported</p>
<p id="supported">$.getContentSupported</p>
<h2>$.getContent(feed);</h2>
<form method="get" action="#" id="feed">
@@ -51,16 +52,35 @@
<input type="submit" value="test" />
</p>
</form>
+<h2>$.getContent(facebook);</h2>
+<form method="get" action="#" id="facebook">
+ <p>
+ <div id='fb-root'></div>
+ <input type="submit" value="test" />
+ </p>
+</form>
<textarea id="result" readonly="true" cols="80" rows="30">
</textarea>
+<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.getcontent.js"></script>
<script type="text/javascript">
+
+var FB_app_id = '';
+
jQuery(function ($) {
+ fbUser = null,
+ FB.init({
+ appId : FB_app_id,
+ status: true,
+ cookie: true,
+ xfbml: true
+ });
$('#feedSupported').addClass(($.getContent.feedSupported?'':'not_') + 'support');
$('#htmlSupported').addClass(($.getContent.htmlSupported?'':'not_') + 'support');
$('#fileSupported').addClass(($.getContent.fileSupported?'':'not_') + 'support');
+ $('#fbSupported').addClass(($.getContent.fbSupported?'':'not_') + 'support');
$('#supported').addClass(($.getContentSupported?'':'not_') + 'support');
var $r = $('#result');
@@ -146,7 +166,46 @@
return false;
}
);
+ $('#facebook').bind(
+ 'submit',
+ function () {
+ FB.getLoginStatus(function(response) {
+ if(response.session) {
+ getFbUser();
+ }
+ else {
+ FB.login(function(response) {
+ if(response) {
+ getFbUser();
+ }
+ else {
+ }
+ }, {perms:'read_stream'});
+ }
+ });
+ }
+ );
+
+ function getFbUser() {
+ FB.api('/me', function(response) {
+ fbUser = response;
+ try {
+ $.getContent(
+ fbUser.id,
+ {
+ type: 'fbok',
+ beforeComplete: beforeComplete,
+ complete: complete
+ }
+ );
+ } catch (e) {error(e); }
+ start();
+ return false;
+ });
+ };
+
+
});
</script>
</body>
-</html>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.