Moving our sidebar to a service for maximum awesomesauce

This commit is contained in:
Will Marshall
2014-04-25 13:49:44 +10:00
parent 57a65f815e
commit b0ecadcb28
6 changed files with 21 additions and 19 deletions

View File

@@ -1,12 +1,2 @@
Darkswarm.controller "AuthenticationActionsCtrl", ($scope, Navigation, storage) ->
$scope.toggleLogin = ->
Navigation.navigate "/login"
$scope.toggleSignup = ->
Navigation.navigate "/signup"
$scope.toggleSignup = ->
Navigation.navigate "/signup"
$scope.toggle = (path = null)->
Navigation.navigate(path)
Darkswarm.controller "AuthenticationActionsCtrl", ($scope, Navigation, storage, Sidebar) ->
$scope.Sidebar = Sidebar

View File

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

View File

@@ -0,0 +1,13 @@
Darkswarm.factory "Sidebar", ($location, Navigation)->
new class Sidebar
paths: ["/login", "/signup", "/forgot", "/account"]
active: ->
$location.path() in @paths
toggle: ->
if Navigation.path in @paths
Navigation.navigate(Navigation.path)
else
Navigation.navigate(@paths[0])

View File

@@ -17,6 +17,7 @@
.columns.small-11
%a{"bo-href" => "hub.path", "ng-show" => "!emptiesCart()"}
Shop at
%strong {{ hub.name }}
%a{"ng-click" => "changeHub()", "ng-show" => "emptiesCart()"}
Change hub to

View File

@@ -2,8 +2,9 @@
%section.top-bar-section
%ul.left{"ng-controller" => "AuthenticationActionsCtrl"}
%li
%a.icon{"ng-click" => "toggle()"}
%a.icon{"ng-click" => "Sidebar.toggle()"}
%i.fi-list
%li= link_to image_tag("ofn_logo_small.png"), root_path
%li.divider
- if spree_current_user.nil?

View File

@@ -1,5 +1,5 @@
%section#sidebar{ role: "complementary", "ng-controller" => "SidebarCtrl",
"ng-class" => "{'active' : active()}"}
"ng-class" => "{'active' : Sidebar.active()}"}
- if spree_current_user.nil?
%tabset