diff --git a/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee new file mode 100644 index 0000000000..504a78cb32 --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/hub_node_controller.js.coffee @@ -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() + diff --git a/app/assets/javascripts/darkswarm/services/navigation.js.coffee b/app/assets/javascripts/darkswarm/services/navigation.js.coffee index a89523dbff..05a73caf04 100644 --- a/app/assets/javascripts/darkswarm/services/navigation.js.coffee +++ b/app/assets/javascripts/darkswarm/services/navigation.js.coffee @@ -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 diff --git a/app/assets/stylesheets/darkswarm/active_table.css.sass b/app/assets/stylesheets/darkswarm/active_table.css.sass index 9363d8b4f2..ff530d606d 100644 --- a/app/assets/stylesheets/darkswarm/active_table.css.sass +++ b/app/assets/stylesheets/darkswarm/active_table.css.sass @@ -7,7 +7,3 @@ display: block &:first-child cursor: pointer - &.closed - &:hover, &:active, &:focus - background: white - border: 1px solid $clr-strong diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index 1878ec04e2..fc1f9228e3 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -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 diff --git a/app/views/darkswarm/index.html.haml b/app/views/darkswarm/index.html.haml index 1cecc1e09a..6208a61928 100644 --- a/app/views/darkswarm/index.html.haml +++ b/app/views/darkswarm/index.html.haml @@ -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