Reworking the way the Sidebar works

This commit is contained in:
Will Marshall
2014-03-24 14:25:44 +11:00
parent 93db813b3a
commit 0690fcda48
9 changed files with 37 additions and 29 deletions

View File

@@ -1,14 +1,13 @@
window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http) ->
window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location) ->
$scope.spree_user = {
remember_me: 0
}
$scope.active = ->
$scope.active_sidebar == '/login'
$location.path() == '/login'
$scope.submit = ->
$http.post("/user/spree_user/sign_in", {spree_user: $scope.spree_user}).success (data)->
location.href = location.origin + location.pathname # Strips out hash fragments
.error (data) ->
$scope.errors = data.message

View File

@@ -0,0 +1,12 @@
window.MenuCtrl = Darkswarm.controller "MenuCtrl", ($scope, $location) ->
$scope.toggleLogin = ->
if $location.path() == "/login"
$location.url("/")
else
$location.url("login#sidebar")
$scope.toggleSignup = ->
if $location.path() == "/signup"
$location.url("/")
else
$location.url("signup#sidebar")

View File

@@ -1,8 +1,3 @@
window.SidebarCtrl = Darkswarm.controller "SidebarCtrl", ($scope, $location) ->
$scope.$watch ->
$location.path()
, ->
$scope.active_sidebar = $location.path()
$scope.active = ->
return "active" if $scope.active_sidebar != null and $scope.active_sidebar != ""
$location.hash() == "sidebar"

View File

@@ -1,11 +1,11 @@
window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http) ->
window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location) ->
$scope.spree_user = {}
$scope.errors =
email: null
password: null
$scope.active = ->
$scope.active_sidebar == '/signup'
$location.path() == '/signup'
$scope.submit = ->
$http.post("/user/spree_user", {spree_user: $scope.spree_user}).success (data)->