diff --git a/src/client/app.js b/src/client/app.js index eba70a39..d0b74efc 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -11,6 +11,8 @@ import TeamMemberProfile from './components/TeamMemberProfile'; import AppController from './controllers/AppController'; import HomeController from './controllers/HomeController'; import TeamController from './controllers/TeamController'; +import GalleryController from './controllers/GalleryController'; +import AlbumController from './controllers/AlbumController'; import DocumentsController from './controllers/DocumentsController'; import CopyrightController from './controllers/CopyrightController'; import ContactsController from './controllers/ContactsController'; @@ -105,7 +107,6 @@ app.run(($location, $rootScope, $http) => { UppercaseFirst, require('./ui/timeline'), require('./pages/schedule'), - require('./pages/gallery'), MainMenu, Breadcrumbs, Document, @@ -115,6 +116,8 @@ app.run(($location, $rootScope, $http) => { AppController, HomeController, TeamController, + GalleryController, + AlbumController, DocumentsController, CopyrightController, ContactsController, @@ -127,6 +130,14 @@ app.run(($location, $rootScope, $http) => { $scope.pageClass = 'page-schedule'; }); + app.controller('GalleryPageController', ($scope) => { + $scope.pageClass = 'page-gallery'; + }); + + app.controller('AlbumPageController', ($scope) => { + $scope.pageClass = 'page-album'; + }); + app.controller('DocsPageController', ($scope) => { $scope.pageClass = 'page-docs'; }); diff --git a/src/client/controllers/AlbumController.js b/src/client/controllers/AlbumController.js new file mode 100644 index 00000000..30980dcb --- /dev/null +++ b/src/client/controllers/AlbumController.js @@ -0,0 +1,32 @@ +export default function (app) { + app.controller('AlbumController', ($scope, $rootScope, $http, $routeParams, team, api, menu) => { + menu.activate('/gallery'); + + let year_uri = $routeParams.year; + let course_uri = $routeParams.course; + let album_uri = $routeParams.album; + + api.gallery.album(year_uri, course_uri, album_uri) + .success(album => { + album.teacherName = team.name(album['teacher']); + + $scope.album = album; + $scope.crumbs = [ + { + url: '/gallery', + name: 'Галерея' + }, + { + name: year_uri + }, + { + name: album.course + }, + { + name: album.title + } + ]; + $rootScope.title = album.title; + }); + }); +}; diff --git a/src/client/controllers/GalleryController.js b/src/client/controllers/GalleryController.js new file mode 100644 index 00000000..d0e72e0b --- /dev/null +++ b/src/client/controllers/GalleryController.js @@ -0,0 +1,22 @@ +export default function (app) { + app.controller("GalleryController", ($scope, api) => { + $scope.years = []; + + let years = [2015, 2014, 2013, 2012, 2011, 2010]; + years.forEach((year, year_index) => { + api.gallery.year(year) + .success(albums => { + if (albums.length) { + $scope.years[year_index] = { + year: year, + albums: albums.map(album => { + let preview = album.content[0]; + album.preview_url = preview.content.medium.url; + return album; + }) + }; + } + }) + }); + }); +}; diff --git a/src/client/pages/gallery.js b/src/client/pages/gallery.js deleted file mode 100644 index f98b02c1..00000000 --- a/src/client/pages/gallery.js +++ /dev/null @@ -1,114 +0,0 @@ -module.exports = function (app) { - app.directive("gFotorama", function () { - return { - restrict: "A", - link: function (scope, element, attrs) { - element.addClass('fotorama'); - var $fotorama = $(element.fotorama()); - var fotorama = $fotorama.data('fotorama'); - fotorama.setOptions({ - width: "100%", - maxheight: 500, - loop: true, - nav: "thumbs" - }); - - //$fotorama.on('fotorama:show', function (e, fotorama, extra) { - $fotorama.on('fotorama:error', function (e, fotorama, extra) { - console.log('## ' + e.type); - console.log('active frame', fotorama.activeFrame); - console.log('additional data', extra); - }); - - scope.$watch(attrs.gFotorama, function (value) { - console.log(value); - fotorama.load(value); - }); - } - } - }); - - app.controller("GalleryPageController", function ($scope, api) { - $scope.years = []; - var years = [2015, 2014, 2013, 2012, 2011, 2010]; - years.forEach(function (year, year_index) { - api.gallery.year(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; - }) - }; - } - }) - }); - } - ); - - app.controller("AlbumPageController", function ($scope, $rootScope, $http, $routeParams, team, api, menu) { - menu.activate('/gallery'); - - var year_uri = $routeParams.year; - var course_uri = $routeParams.course; - var album_uri = $routeParams.album; - api.gallery.album( - year_uri, - course_uri, - album_uri - ) - .success(function (album) { - //var preview = album.content[0]; - //album.preview_url = preview.content.medium.url; - //album.fotorama = album.content.map(productToFotorama); - - album.teacherName = team.name(album['teacher']); - - $scope.album = album; - $scope.crumbs = [ - { - url: '/gallery', - name: 'Галерея' - }, - { - //url: '/gallery/{year}'.replace('{year}', year_uri), - name: year_uri - }, - { - //url: '/gallery/{year}/{course}' - // .replace('{year}', year_uri) - // .replace('{course}', course_uri), - name: album.course - }, - { - name: album.title - } - ]; - $rootScope.title = album.title; - }); - }); -}; - -function productToFotorama(product) { - //var tpl = '
' + product.author + '
' + product.authorAge + ' лет
Предмет: {{album.course}}
-Преподаватель: {{album.teacherName}}
-{{album.description}}
-Предмет: {{album.course}}
+Преподаватель: {{album.teacherName}}
+{{album.description}}
+{{product.title | removeNewline}}
+{{product.title | removeNewline}}
-{{product.author}}
+{{product.author}}
-{{product.authorAge}} лет
+{{product.authorAge}} лет
+