Improves album directives

This commit is contained in:
2016-02-12 11:37:36 +01:00
parent df62e82922
commit ce1ee99c9f
5 changed files with 24 additions and 18 deletions

View File

@@ -31,31 +31,28 @@ body > .container-fluid {
}
}
.album-container {
.cover-container {
width:100%;
display: inline-block;
position: relative;
overflow:hidden;
}
.album-container:after {
padding-top:130%;
.cover-container:after {
padding-top:100%;
display: block;
content: '';
}
.album-container .album {
.cover-container .cover {
position: absolute;
top: 15px;
top: 0;
bottom: 0;
right: 0;
left: 15px;
left: 0;
overflow:hidden;
}
.album-container .album .img-album-cover {
}
/* @media (max-width: 767px) { */
/* .album { */

View File

@@ -6,7 +6,7 @@ directives.directive('album', function() {
id: '=albumId'
},
templateUrl: 'js/directives/album.html',
restrict: 'A',
restrict: 'E',
controller: 'AlbumCtrl'
};
});
@@ -15,8 +15,7 @@ directives.controller('AlbumCtrl', function($scope,$http,$log,albumService) {
albumService.get($scope.id)
.then(function(data) {
$scope.album = data;
$log.info('Got : ' + data.ID);
}, function(err) {
$log.error('Got error :' + err);
$log.error('Could not fetch album' + $scope.id + ' :' + err);
});
});

View File

@@ -1,3 +1,7 @@
<div class="album">
<img class="img-responsive img-album-cover" alt="{{album.titre}}" ng-src="{{album.CoverURL}}"/>
<div class="cover-container">
<div class="cover">
<img class="img-responsive img-album-cover" alt="{{album.titre}}" ng-src="{{album.CoverURL}}"/>
</div>
</div>
<p>{{album.serie}}</p>

View File

@@ -1,9 +1,13 @@
var services = angular.module('satbd.satellite.bar.services',[])
services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
function cleanupFields(album) {
album.serie = album.série;
return album;
}
function get(id) {
return $http.get('/api/albums/'+ id).then(function (response) {
return response.data;
return cleanupFields(response.data);
});
}
@@ -12,7 +16,7 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
defer.reject('Search is not implemented');
return defer.promise;
}
return {
get: get,
search: search

View File

@@ -1,3 +1,5 @@
<h1> Albums Récents </h1>
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 album-container" album ng-repeat="id in albumIDs" album-id="id"></div>
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2" ng-repeat="id in albumIDs">
<album album-id="id"></album>
</div>