diff options
| author | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
| commit | b42072733c3afd03a49457d88ffed28ebe55655e (patch) | |
| tree | 2fa2b8703cdc75fe19a204d2c9677e27d33c8176 /example/buzz/buzz.js | |
| parent | 2f7c538628929888ce7c99b9577e34f8c87211f7 (diff) | |
| parent | 8ddee9bb25ade2bbe7d57db6353b29867606c184 (diff) | |
| download | angular.js-b42072733c3afd03a49457d88ffed28ebe55655e.tar.bz2 | |
Merge branch 'master' of github.com:angular/angular.js into future
Diffstat (limited to 'example/buzz/buzz.js')
| -rw-r--r-- | example/buzz/buzz.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/example/buzz/buzz.js b/example/buzz/buzz.js new file mode 100644 index 00000000..40813d16 --- /dev/null +++ b/example/buzz/buzz.js @@ -0,0 +1,46 @@ +angular.service('myApplication', function($resource){ + 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']}); + +function BuzzController(){ + this.$watch('$location.hashPath', this.userChange); +} +BuzzController.prototype = { + userChange: function(){ + this.userId = this.$location.hashPath; + this.activities = this.Activity.get({userId:this.userId}); + }, + + expandReplies: function(activity) { + var self = this; + if (activity.replies) { + activity.replies.show = !activity.replies.show; + } else { + activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function(){ + activity.replies.show = true; + }); + } + } +}; + +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'); + } + }); + }; +}); |
