Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('sociogram.controllers', [])
- .controller('AppCtrl', function ($scope, $state, OpenFB) {
- $scope.logout = function () {
- OpenFB.logout().then(
- function () {
- $state.go('app.login');
- },
- function () {
- alert('Logout failed');
- });
- };
- $scope.revokePermissions = function () {
- OpenFB.revokePermissions().then(
- function () {
- $state.go('app.login');
- },
- function () {
- alert('Revoke permissions failed');
- });
- };
- })
- .controller('LoginCtrl', function ($scope, $location, OpenFB) {
- $scope.facebookLogin = function () {
- OpenFB.login('email,read_stream,publish_actions').then(
- function () {
- $location.path('/app/person/me/feed');
- },
- function () {
- alert('OpenFB login failed');
- });
- };
- })
- .controller('ShareCtrl', function ($scope, OpenFB) {
- $scope.item = {};
- $scope.share = function () {
- OpenFB.post('/me/feed', $scope.item)
- .success(function () {
- $scope.status = "This item has been shared on OpenFB";
- })
- .error(function(data) {
- alert(data.error.message);
- });
- };
- })
- .controller('ProfileCtrl', function ($scope, OpenFB) {
- OpenFB.get('/me').success(function (user) {
- $scope.user = user;
- });
- })
- .controller('PersonCtrl', function ($scope, $stateParams, OpenFB) {
- OpenFB.get('/' + $stateParams.personId).success(function (user) {
- $scope.user = user;
- });
- })
- .controller('FriendsCtrl', function ($scope, $stateParams, OpenFB) {
- OpenFB.get('/' + $stateParams.personId + '/friends', {limit: 50})
- .success(function (result) {
- $scope.friends = result.data;
- })
- .error(function(data) {
- alert(data.error.message);
- });
- })
- .controller('MutualFriendsCtrl', function ($scope, $stateParams, OpenFB) {
- OpenFB.get('/' + $stateParams.personId + '/mutualfriends', {limit: 50})
- .success(function (result) {
- $scope.friends = result.data;
- })
- .error(function(data) {
- alert(data.error.message);
- });
- })
- .controller('FeedCtrl', function ($scope, $stateParams, OpenFB, $ionicLoading) {
- $scope.show = function() {
- $scope.loading = $ionicLoading.show({
- content: 'Loading feed...'
- });
- };
- $scope.hide = function(){
- $scope.loading.hide();
- };
- function loadFeed() {
- $scope.show();
- OpenFB.get('/' + $stateParams.personId + '/home', {limit: 30})
- .success(function (result) {
- $scope.hide();
- $scope.items = result.data;
- // Used with pull-to-refresh
- $scope.$broadcast('scroll.refreshComplete');
- })
- .error(function(data) {
- $scope.hide();
- alert(data.error.message);
- });
- }
- $scope.doRefresh = loadFeed;
- loadFeed();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement