2013-07-25 23:33:04 +02:00
|
|
|
angular.module('ponyfm').controller "application", [
|
|
|
|
'$scope', 'auth', '$location', 'upload', '$state', '$stateParams', 'taxonomies'
|
|
|
|
($scope, auth, $location, upload, $state, $stateParams, taxonomies) ->
|
|
|
|
$scope.auth = auth.data
|
|
|
|
$scope.$state = $state
|
|
|
|
$scope.$stateParams = $stateParams
|
|
|
|
|
|
|
|
$scope.logout = () ->
|
|
|
|
auth.logout().done -> location.reload()
|
|
|
|
|
|
|
|
$scope.isActive = (loc) -> $location.path() == loc
|
2013-07-29 22:54:53 +02:00
|
|
|
$scope.$on '$viewContentLoaded', () ->
|
|
|
|
window.setTimeout window.handleResize, 500
|
2013-07-25 23:33:04 +02:00
|
|
|
|
|
|
|
# Show loading screen here?
|
|
|
|
taxonomies.refresh()
|
2013-07-29 22:54:53 +02:00
|
|
|
|
|
|
|
$scope.mainViewAnimation = 'slide-down';
|
|
|
|
|
|
|
|
$scope.$on '$stateChangeStart', (e, newState, newParams, oldState) ->
|
|
|
|
oldIndex =
|
|
|
|
if (oldState && oldState.navigation && oldState.navigation.index)
|
|
|
|
oldState.navigation.index
|
|
|
|
else
|
|
|
|
0
|
|
|
|
|
|
|
|
newIndex =
|
|
|
|
if (newState && newState.navigation && newState.navigation.index)
|
|
|
|
newState.navigation.index
|
|
|
|
else
|
|
|
|
0
|
|
|
|
|
|
|
|
oldSubIndex =
|
|
|
|
if (oldState && oldState.navigation && oldState.navigation.subIndex)
|
|
|
|
oldState.navigation.subIndex
|
|
|
|
else
|
|
|
|
0
|
|
|
|
|
|
|
|
newSubIndex =
|
|
|
|
if (newState && newState.navigation && newState.navigation.subIndex)
|
|
|
|
newState.navigation.subIndex
|
|
|
|
else
|
|
|
|
0
|
|
|
|
|
|
|
|
$scope.mainViewAnimation = 'slide-down' if oldIndex > newIndex
|
|
|
|
$scope.mainViewAnimation = 'slide-up' if oldIndex < newIndex
|
|
|
|
$scope.mainViewAnimation = 'slide-right' if oldIndex == newIndex
|
|
|
|
|
|
|
|
$scope.subViewAnimation = 'slide-right' if oldSubIndex > newSubIndex
|
|
|
|
$scope.subViewAnimation = 'slide-left' if oldSubIndex < newSubIndex
|
|
|
|
$scope.subViewAnimation = 'slide-up' if oldSubIndex == newSubIndex
|
2013-07-25 23:33:04 +02:00
|
|
|
]
|