mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Moving our sidebar to a service for maximum awesomesauce
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
13
app/assets/javascripts/darkswarm/services/sidebar.js.coffee
Normal file
13
app/assets/javascripts/darkswarm/services/sidebar.js.coffee
Normal 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])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user