Better handling of the home page hubs

This commit is contained in:
Will Marshall
2014-04-23 12:58:34 +10:00
parent c5f8e2e123
commit f5b32ebd3f
5 changed files with 25 additions and 11 deletions

View File

@@ -0,0 +1,11 @@
Darkswarm.controller "HubNodeCtrl", ($scope, Navigation, $location, $anchorScroll) ->
$scope.toggle = ->
Navigation.navigate $scope.hub.path
$scope.active = ->
$location.path() == $scope.hub.path
if $scope.active()
console.log "scrolling baby"
$anchorScroll()

View File

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

View File

@@ -7,7 +7,3 @@
display: block
&:first-child
cursor: pointer
&.closed
&:hover, &:active, &:focus
background: white
border: 1px solid $clr-strong

View File

@@ -2,7 +2,14 @@
hub
display: block
strong
color: $clr-strong
border: 1px solid transparent
&.closed
&:hover, &:active, &:focus
background: white
border: 1px solid $clr-strong
&.open
border: 1px solid $clr-strong
p

View File

@@ -30,11 +30,12 @@
.row{bindonce: true}
.small-12.columns
.active_table
%hub.row{"ng-repeat" => "hub in filteredHubs = (hubs | filterHubs:query)",
"ng-class" => "{'open' : open}"}
"ng-class" => "{'closed' : !active(), 'open' : active()}",
"ng-controller" => "HubNodeCtrl",
id: "{{hub.path}}"}
.small-12.columns
.row.active_table_row{"ng-click" => "open = !open", "ng-class" => "{'closed' : !open}"}
.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !active()}"}
.columns.small-4
%strong {{ hub.name }}
.columns.small-3
@@ -46,7 +47,7 @@
.columns.small-1.text-right
%i{"ng-class" => "{'fi-arrow-down' : !open, 'fi-arrow-up' : open}"}
.row.active_table_row{"ng-if" => "open"}
.row.active_table_row{"ng-show" => "active()"}
.columns.small-4
%strong Shop for
%p
@@ -65,7 +66,7 @@
%li Shiny Olives
%li Love in the Time of Cholera
.row.active_table_row{"ng-if" => "open"}
.row.active_table_row{"ng-show" => "active()"}
.columns.small-11
%a{"bo-href" => "hub.path"}
Shop at