gallery update: years, /gallery... -> /album...;

This commit is contained in:
tmshv committed 2015-07-05 20:42:24 +03:00
1 parent d16bb492aa
commit e8a65edde1
5 files changed
+102 -27

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ app.config(function ($locationProvider, $routeProvider) {
title:"Работы учащихся"
},
{
name: "/gallery/:year/:course/:album",
name: "/album/:year/:course/:album",
templateUrl: "/views/gallery-album.html",
controller: "AlbumPageController",
title:"Работы учащихся"
+35 -14
View File
@@ -1,8 +1,8 @@
module.exports = function (app) {
app.directive("gFotorama", function(){
app.directive("gFotorama", function () {
return {
restrict: "A",
link: function(scope, element, attrs){
link: function (scope, element, attrs) {
element.addClass('fotorama');
var fotorama = $(element.fotorama()).data('fotorama');
fotorama.setOptions({
@@ -12,7 +12,7 @@ module.exports = function (app) {
nav: "thumbs"
});
scope.$watch(attrs.gFotorama, function (value){
scope.$watch(attrs.gFotorama, function (value) {
console.log(value);
fotorama.load(value);
});
@@ -21,20 +21,40 @@ module.exports = function (app) {
});
app.controller("GalleryPageController", function ($scope, $http) {
$http.get("/gallery")
.success(function (albums) {
$scope.albums = albums.map(function (album) {
var preview = album.content[0];
album.preview_url = preview.content.medium.url;
album.fotorama = album.content.map(productToFotorama);
$scope.years = [];
var years = [2015, 2014, 2013, 2012, 2011, 2010];
years.forEach(function (year, year_index) {
$http.get("/gallery/" + year)
.success(function (albums) {
if(albums.length) {
$scope.years[year_index] = {
year: year,
albums: albums.map(function (album) {
var preview = album.content[0];
album.preview_url = preview.content.medium.url;
album.fotorama = album.content.map(productToFotorama);
return album;
});
return album;
})
};
}
})
});
});
//$http.get("/gallery")
// .success(function (albums) {
// $scope.albums = albums.map(function (album) {
// var preview = album.content[0];
// album.preview_url = preview.content.medium.url;
// album.fotorama = album.content.map(productToFotorama);
//
// return album;
// });
// });
}
);
app.controller("AlbumPageController", function ($scope, $http, $routeParams) {
var url = '/gallery/{year}/{course}/{album}'
var url = '/album/{year}/{course}/{album}'
.replace('{year}', $routeParams.year)
.replace('{course}', $routeParams.course)
.replace('{album}', $routeParams.album);
@@ -47,7 +67,8 @@ module.exports = function (app) {
$scope.album = album;
});
});
};
}
;
function productToFotorama(product) {
return {