angular.module('satbd.satellite.bar', ['ui.bootstrap','ngAnimate']); angular.module('satbd.satellite.bar').controller('GlobalCtrl', function($scope) { $scope.location = ''; $scope.isActive = function(location) { return $scope.location === location }; $scope.recents = function() { $scope.location='recents'; $scope.$broadcast('displayRecents') }; $scope.collections = function() { $scope.location='collections'; $scope.$broadcast('displayCollections') }; $scope.authors = function() { $scope.location='authors'; $scope.$broadcast('displayAuthors') }; $scope.search = function( query ) { $scope.location='search'; $scope.$broadcast('displaySearch', query) }; $scope.$on('recentsReady', function(event) { $scope.recents(); }); }); angular.module('satbd.satellite.bar').controller('NavbarCollapseCtrl', function ($scope, $uibModal) { $scope.isCollapsed = true; $scope.openModal = function (size) { var modalInstance = $uibModal.open({ templateUrl: 'help.html', controller: 'HelpInstanceCtrl', size: size, keyboard: true, }); }; }); angular.module('satbd.satellite.bar').controller('HelpInstanceCtrl', function($scope, $uibModalInstance) { $scope.ok = function () { $uibModalInstance.close(''); }; }); angular.module('satbd.satellite.bar').controller('RecentCtrl', function($scope, $http,$log) { $scope.albumIDs = [ ]; $scope.clear = function(event) { $scope.albumIDs = [] }; $scope.$on('displayAuthors', $scope.clear); $scope.$on('displayCollections', $scope.clear); $scope.$on('displaySearch', $scope.clear); $scope.$on('displayRecents', function(event) { $scope.clear(); $log.info('fetching recent albums'); $http.get('/api/recents').success(function(data){ for (var i = 0; i < 10; i++) { $scope.albumIDs.push(data[i]); } }); }); $scope.$emit('recentsReady') }); angular.module('satbd.satellite.bar').controller('RecentAlbumCtrl', function($scope, $http) { $scope.init_by_id = function(id) { $http.get('api/albums/'+ id).success(function (data) { $scope.album = data; }); }; });