Improving the navigation by moving it all to a service, adding a generic icon

This commit is contained in:
Will Marshall
2014-03-28 12:15:08 +11:00
parent 12b1a1b0e9
commit e1465352d0
16 changed files with 91 additions and 27 deletions

View File

@@ -0,0 +1,9 @@
window.AccountSidebarCtrl = Darkswarm.controller "AccountSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) ->
$scope.path = "/account"
Navigation.paths.push $scope.path
$scope.active = ->
$location.path() == $scope.path
$scope.select = ->
Navigation.navigate($scope.path)

View File

@@ -1,12 +1,14 @@
window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser) ->
window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) ->
$scope.spree_user = SpreeUser.spree_user
$scope.path = "/forgot"
$scope.sent = false
Navigation.paths.push $scope.path
$scope.active = ->
$location.path() == '/forgot'
$location.path() == $scope.path
$scope.select = ->
$location.path("/forgot")
Navigation.navigate($scope.path)
$scope.submit = ->
if $scope.spree_user.email != null

View File

@@ -1,11 +1,14 @@
window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location, SpreeUser) ->
window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) ->
$scope.spree_user = SpreeUser.spree_user
$scope.path = "/login"
Navigation.paths.push $scope.path
$scope.active = ->
$location.path() == '/login'
$location.path() == $scope.path
$scope.select = ->
$location.path("/login")
Navigation.navigate($scope.path)
$scope.submit = ->
$http.post("/user/spree_user/sign_in", {spree_user: $scope.spree_user}).success (data)->

View File

@@ -1,12 +1,10 @@
window.MenuCtrl = Darkswarm.controller "MenuCtrl", ($scope, $location) ->
window.MenuCtrl = Darkswarm.controller "MenuCtrl", ($scope, Navigation) ->
$scope.toggleLogin = ->
if $location.path() == "/login"
$location.path("/")
else
$location.path("login")
Navigation.navigate "/login"
$scope.toggleSignup = ->
if $location.path() == "/signup"
$location.path("/")
else
$location.path("signup")
Navigation.navigate "/signup"
$scope.toggle = ->
Navigation.navigate()

View File

@@ -1,3 +1,6 @@
window.SidebarCtrl = Darkswarm.controller "SidebarCtrl", ($scope, $location) ->
$scope.sidebarPaths = ["/login", "/signup", "/forgot", "/account"]
$scope.active = ->
$location.path() in ["/login", "/signup", "/forgot"]
$location.path() in $scope.sidebarPaths

View File

@@ -1,14 +1,16 @@
window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location, SpreeUser) ->
window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) ->
$scope.spree_user = SpreeUser.spree_user
$scope.path = "/signup"
Navigation.paths.push $scope.path
$scope.errors =
email: null
password: null
$scope.active = ->
$location.path() == '/signup'
$location.path() == $scope.path
$scope.select = ->
$location.path("/signup")
Navigation.navigate($scope.path)
$scope.submit = ->
$http.post("/user/spree_user", {spree_user: $scope.spree_user}).success (data)->

View File

@@ -0,0 +1,12 @@
Darkswarm.factory 'Navigation', ($location) ->
new class Navigation
paths: []
path: null
navigate: (path = false)->
@path = path || @path || @paths[0]
if $location.path() == @path
$location.path("/")
else
$location.path(@path)