-
-
Save devniel/5846169 to your computer and use it in GitHub Desktop.
Revisions
-
devniel renamed this gist
Jun 23, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
devniel revised this gist
Jun 23, 2013 . 2 changed files with 55 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ function UserCtrl( $scope, $FB) { $scope.$watch(function() { return $FB.isLoaded() },function(value){ console.log("VALUE",value); // It needs authentication, this won't work. if(value){ $scope.facebook_friends = $FB.api('/me/friends', function(response) { $scope.facebook_friends = response.data; }); } },true); $scope.$watch(function() { return $FB.isAuthenticated() },function(value){ console.log("VALUE isAuthenticated",value); // YEP, this will work. if(value){ $scope.facebook_friends = $FB.api('/me/friends', function(response) { $scope.facebook_friends = response.data; console.log("FRIENDS",response); }); } },true); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,29 +42,46 @@ angular.module('facebook', []) .factory('$FB', ['$rootScope', function($rootScope) { var fbLoaded = false; // Our own customisations var _fb = { loaded: fbLoaded, isLoaded : function(){ return this.loaded; }, authenticated : false, isAuthenticated : function(){ return this.authenticated; }, _init: function(params) { self = this; if(window.FB) { // FIXME: Ugly hack to maintain both window.FB // and our AngularJS-wrapped $FB with our customisations angular.extend(window.FB, this); angular.extend(this, window.FB); // Set the flag this.loaded = true; // Initialise FB SDK window.FB.init(params); window.FB.Event.subscribe('auth.authResponseChange', function(response) { if (response.status === 'connected') { self.authenticated = true; } }); if(!$rootScope.$$phase) { $rootScope.$apply(); } } } } return _fb; }]); -
ruiwen revised this gist
May 5, 2013 . 1 changed file with 69 additions and 56 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,57 +1,70 @@ // Facebook SDK angular.module('facebook', []) .directive('fb', ['$FB', function($FB) { return { restrict: "E", replace: true, template: "<div id='fb-root'></div>", compile: function(tElem, tAttrs) { return { post: function(scope, iElem, iAttrs, controller) { var fbAppId = iAttrs.appId || ''; var fb_params = { appId: iAttrs.appId || "", cookie: iAttrs.cookie || true, status: iAttrs.status || true, xfbml: iAttrs.xfbml || true }; // Setup the post-load callback window.fbAsyncInit = function() { $FB._init(fb_params); if('fbInit' in iAttrs) { iAttrs.fbInit(); } }; (function(d, s, id, fbAppId) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk', fbAppId)); } } } }; }]) .factory('$FB', ['$rootScope', function($rootScope) { var fbLoaded = false; // Our own customisations var _fb = { loaded: fbLoaded, _init: function(params) { if(window.FB) { // FIXME: Ugly hack to maintain both window.FB // and our AngularJS-wrapped $FB with our customisations angular.extend(window.FB, _fb); angular.extend(_fb, window.FB); // Set the flag _fb.loaded = true; // Initialise FB SDK window.FB.init(params); if(!$rootScope.$$phase) { $rootScope.$apply(); } } } } return _fb; }]); -
ruiwen revised this gist
Feb 6, 2013 . 1 changed file with 26 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,32 @@ // Facebook SDK angular.module('facebook', []). directive('fb', ['$FB', function($FB) { return { restrict: "E", replace: true, template: "<div id='fb-root'></div>", compile: function(tElem, tAttrs) { return { post: function(scope, iElem, iAttrs, controller) { var fbAppId = iAttrs.appId || ''; // Setup the post-load callback window.fbAsyncInit = function() { $FB._init(); if('fbInit' in iAttrs) { iAttrs.fbInit(); } }; (function(d, s, id, fbAppId) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js#appId=" + fbAppId; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk', fbAppId)); } } } }; }]). factory('$FB', ['$rootScope', function($rootScope) { -
ruiwen revised this gist
Feb 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,6 +53,6 @@ angular.module('facebook', []). } } } return _fb; }]); -
ruiwen revised this gist
Feb 6, 2013 . 1 changed file with 11 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,17 @@ // Facebook SDK angular.module('facebook', []). directive('fb', ['$FB', function($FB) { return { restrict: "E", replace: true, template: "<div id='fb-root'></div>", compile: function(tElem, tAttrs) { return { post: function(scope, iElem, iAttrs, controller) { var fbAppId = iAttrs.appId || ''; // Setup the post-load callback window.fbAsyncInit = function() { $FB._init(); if('fbInit' in iAttrs) { iAttrs.fbInit(); -
ruiwen created this gist
Feb 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ // Facebook SDK angular.module('facebook', []). directive('fb', ['$FB', function($FB) { return { restrict: "E", replace: true, template: "<div id='fb-root'></div>", compile: function(tElem, tAttrs) { return { post: function(scope, iElem, iAttrs, controller) { var fbAppId = iAttrs.appId || ''; // Setup the post-load callback window.fbAsyncInit = function() { $FB._init(); if('fbInit' in iAttrs) { iAttrs.fbInit(); } }; (function(d, s, id, fbAppId) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js#appId=" + fbAppId; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk', fbAppId)); } } } }; }]). factory('$FB', ['$rootScope', function($rootScope) { var fbLoaded = false; // Our own customisations var _fb = { loaded: fbLoaded, _init: function() { if(window.FB) { // FIXME: Ugly hack to maintain both window.FB // and our AngularJS-wrapped $FB with our customisations angular.extend(window.FB, _fb); angular.extend(_fb, window.FB); // Set the flag _fb.loaded = true; if(!$rootScope.$$phase) { $rootScope.$apply(); } } } } return _fb; }]); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <!DOCTYPE html> <html ng-app='app'> <head></head> <body> <fb app-id='123123'></fb> </body> </html>