From d5a652182e72bf6b3abd196a7e3ed69f21a86028 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 29 May 2014 16:31:12 +1000 Subject: [PATCH] Scrolling to groups when hotlinked --- .../darkswarm/controllers/groups_controller.js.coffee | 5 ++++- app/views/groups/index.html.haml | 5 +++-- app/views/shopping_shared/_groups.html.haml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee index 8fd47c49f8..850f58b33e 100644 --- a/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/groups_controller.js.coffee @@ -1,3 +1,6 @@ -Darkswarm.controller "GroupsCtrl", ($scope, Groups) -> +Darkswarm.controller "GroupsCtrl", ($scope, Groups, $anchorScroll, $rootScope) -> $scope.Groups = Groups $scope.order = 'position' + + $rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) -> + $anchorScroll() diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 40b56e2551..c1fd5ccf8e 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -17,8 +17,9 @@ "ng-debounce" => "150", "ofn-disable-enter" => true} - .group{"ng-repeat" => "group in Groups.groups | filter:query | orderBy:order"} - + .group{"ng-repeat" => "group in Groups.groups | filter:query | orderBy:order", + name: "group{{group.id}}", + id: "group{{group.id}}"} .row.pad-top{bindonce: true} .small-12.columns .group-hero diff --git a/app/views/shopping_shared/_groups.html.haml b/app/views/shopping_shared/_groups.html.haml index cc7e4ff369..e9ebb219b3 100644 --- a/app/views/shopping_shared/_groups.html.haml +++ b/app/views/shopping_shared/_groups.html.haml @@ -2,4 +2,4 @@ %ul - for group in current_distributor.groups %li - %a{href: main_app.groups_path}= group.name + %a{href: main_app.groups_path(anchor: "#/#group#{group.id}")}= group.name