2011-11-12 01:15:22 +00:00
|
|
|
angular.module.ng('myApplication', function($resource){
|
2010-07-22 18:18:32 +00:00
|
|
|
this.Activity = $resource(
|
|
|
|
|
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
|
|
|
|
|
{alt:'json', callback:'JSON_CALLBACK'},
|
|
|
|
|
{
|
|
|
|
|
get: {method:'JSON', params:{visibility:'@self'}},
|
|
|
|
|
replies: {method:'JSON', params:{visibility:'@self', comments:'@comments'}}
|
|
|
|
|
});
|
|
|
|
|
}, {inject:['$resource']});
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
function BuzzController() {
|
2010-07-22 18:18:32 +00:00
|
|
|
this.$watch('$location.hashPath', this.userChange);
|
|
|
|
|
}
|
|
|
|
|
BuzzController.prototype = {
|
2011-10-07 18:27:49 +00:00
|
|
|
userChange: function() {
|
2010-07-22 18:18:32 +00:00
|
|
|
this.userId = this.$location.hashPath;
|
|
|
|
|
this.activities = this.Activity.get({userId:this.userId});
|
2010-07-22 22:32:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
expandReplies: function(activity) {
|
|
|
|
|
var self = this;
|
|
|
|
|
if (activity.replies) {
|
|
|
|
|
activity.replies.show = !activity.replies.show;
|
|
|
|
|
} else {
|
2011-10-07 18:27:49 +00:00
|
|
|
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function() {
|
2010-07-22 22:32:57 +00:00
|
|
|
activity.replies.show = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
2010-07-22 18:18:32 +00:00
|
|
|
}
|
|
|
|
|
};
|
2010-07-22 22:32:57 +00:00
|
|
|
|
|
|
|
|
angular.widget('my:expand', function(element){
|
|
|
|
|
element.css('display', 'block');
|
|
|
|
|
this.descend(true);
|
|
|
|
|
return function(element) {
|
|
|
|
|
element.hide();
|
|
|
|
|
var watch = element.attr('expand');
|
|
|
|
|
this.$watch(watch, function(value){
|
|
|
|
|
if (value) {
|
|
|
|
|
element.delay(0).slideDown('slow');
|
|
|
|
|
} else {
|
|
|
|
|
element.slideUp('slow');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|