Created
June 6, 2013 03:31
-
-
Save mongoltolbo/5719125 to your computer and use it in GitHub Desktop.
Angular Picasa photo fetch controller
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 characters
var app = angular.module('picasa-photo', ['picasa-directives']); | |
function PicasaCtrl($scope, $http, $attrs) { | |
$scope.post = (!$attrs.post ? $(".picasa-post").addClass("hide") : $attrs.post ); | |
$scope.url = 'https://picasaweb.google.com/data/feed/api/user/' + $attrs.userid + '/albumid/' + $attrs.albumid + '/photoid/' + $attrs.photoid + '?alt=json&imgmax=' + $attrs.imgmax + '&callback=JSON_CALLBACK'; | |
$http({method: 'JSONP', url: $scope.url}).success(function(data, status) { | |
$scope.status = status; | |
$scope.data = data.feed; | |
}).error(function(data, status) { | |
$scope.data = data || "Request failed"; | |
$scope.status = status; | |
}); | |
} | |
angular.module('picasa-directives', []); | |
angular.module('picasa-directives').directive( | |
'picasa', function() { | |
return { | |
restrict: 'E', | |
transclude: true, | |
template: '<div id="gpPhoto" class="_thumbnail row aligncenter">'+ | |
'<img src="{{data.media$group.media$content[0].url}}"/>'+ | |
'<h2>{{data.subtitle.$t}}</h2>'+ | |
'<p class="picasa-post">{{post}}</p>' + | |
'<p class="gpPhotoExif">F{{data.exif$tags.exif$fstop.$t}}, {{data.exif$tags.exif$focallength.$t | number:0}}mm, {{data.exif$tags.exif$exposure.$t}}sec, ISO{{data.exif$tags.exif$iso.$t}}</p>'+ | |
'<div class="gpPhotoComments">'+ | |
'<h4 style="text-align:center" class="Comments{{data.gphoto$commentCount.$t}}">{{data.gphoto$commentCount.$t}} Comments</h4>'+ | |
'<ul><li ng-repeat="datas in data.entry">'+ | |
'<div class="media">'+ | |
'<a class="pull-left" href="{{datas.author[0].uri.$t}}">'+ | |
'<img class="media-object img-rounded" src="{{datas.author[0].gphoto$thumbnail.$t}}">'+ | |
'</a>'+ | |
'<div class="media-body">'+ | |
'<a class="media-heading" href="{{datas.author[0].uri.$t}}">'+ | |
'{{datas.author[0].name.$t}}'+ | |
'</a>'+ | |
'<span> {{datas.published.$t | date:"MMM/dd/yy @ h:mma"}}</span><br/>'+ | |
'<span>{{datas.content.$t}}</span>'+ | |
'</div>'+ | |
'</div>'+ | |
'</li></ul>'+ | |
'</div>'+ | |
'</div>', | |
link: function(scope, element, attrs) { | |
// select the needed DOM elements from the template | |
var marquee = element.find("picasa").text; | |
} | |
/*scope.urls = 'https://picasaweb.google.com/data/feed/api/user/' + attrs.userid + | |
'/albumid/'+ attrs.albumid + '/photoid/' + attrs.photoid + '?alt=json&imgmax=1000&callback=JSON_CALLBACK'; | |
https://picasaweb.google.com/data/feed/api/user/106908252002559129042/albumid/5874971830086344401/photoid/5874971838053725730?alt=json&imgmax=1000&callback=JSON_CALLBACK */ | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment