diff --git a/Gemfile b/Gemfile index 057fd34d3e..4d8389bd2c 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,7 @@ group :assets do gem 'uglifier', '>= 1.0.3' gem 'turbo-sprockets-rails3' + gem 'foundation-icons-sass-rails' end gem "foundation-rails" diff --git a/Gemfile.lock b/Gemfile.lock index bdd90bf6b8..971e536da5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -262,6 +262,9 @@ GEM nokogiri (~> 1.5) ruby-hmac formatador (0.2.4) + foundation-icons-sass-rails (3.0.0) + railties (>= 3.1.1) + sass-rails (>= 3.1.1) foundation-rails (5.2.1.0) railties (>= 3.1.0) sass (>= 3.2.0) @@ -509,6 +512,7 @@ DEPENDENCIES eaterprises_feature! factory_girl_rails faker + foundation-icons-sass-rails foundation-rails foundation_rails_helper! geocoder diff --git a/app/assets/javascripts/darkswarm/controllers/account_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/account_sidebar_controller.js.coffee new file mode 100644 index 0000000000..d049f4639f --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/account_sidebar_controller.js.coffee @@ -0,0 +1,9 @@ +window.AccountSidebarCtrl = Darkswarm.controller "AccountSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) -> + $scope.path = "/account" + Navigation.paths.push $scope.path + + $scope.active = -> + $location.path() == $scope.path + + $scope.select = -> + Navigation.navigate($scope.path) diff --git a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee index f0e708f2f7..e3c272a3af 100644 --- a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee @@ -1,12 +1,14 @@ -window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser) -> +window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) -> $scope.spree_user = SpreeUser.spree_user + $scope.path = "/forgot" $scope.sent = false + Navigation.paths.push $scope.path $scope.active = -> - $location.path() == '/forgot' + $location.path() == $scope.path $scope.select = -> - $location.path("/forgot") + Navigation.navigate($scope.path) $scope.submit = -> if $scope.spree_user.email != null diff --git a/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee index e3d0d20d25..54b10b0b4a 100644 --- a/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee @@ -1,11 +1,14 @@ -window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location, SpreeUser) -> +window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) -> $scope.spree_user = SpreeUser.spree_user + $scope.path = "/login" + Navigation.paths.push $scope.path $scope.active = -> - $location.path() == '/login' + $location.path() == $scope.path $scope.select = -> - $location.path("/login") + Navigation.navigate($scope.path) + $scope.submit = -> $http.post("/user/spree_user/sign_in", {spree_user: $scope.spree_user}).success (data)-> diff --git a/app/assets/javascripts/darkswarm/controllers/menu_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/menu_controller.js.coffee index cd5a4ce5fc..895a3853a2 100644 --- a/app/assets/javascripts/darkswarm/controllers/menu_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/menu_controller.js.coffee @@ -1,12 +1,10 @@ -window.MenuCtrl = Darkswarm.controller "MenuCtrl", ($scope, $location) -> +window.MenuCtrl = Darkswarm.controller "MenuCtrl", ($scope, Navigation) -> + $scope.toggleLogin = -> - if $location.path() == "/login" - $location.path("/") - else - $location.path("login") + Navigation.navigate "/login" $scope.toggleSignup = -> - if $location.path() == "/signup" - $location.path("/") - else - $location.path("signup") + Navigation.navigate "/signup" + + $scope.toggle = -> + Navigation.navigate() diff --git a/app/assets/javascripts/darkswarm/controllers/sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/sidebar_controller.js.coffee index 6f0b954116..fc606b0393 100644 --- a/app/assets/javascripts/darkswarm/controllers/sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/sidebar_controller.js.coffee @@ -1,3 +1,6 @@ window.SidebarCtrl = Darkswarm.controller "SidebarCtrl", ($scope, $location) -> + $scope.sidebarPaths = ["/login", "/signup", "/forgot", "/account"] + $scope.active = -> - $location.path() in ["/login", "/signup", "/forgot"] + $location.path() in $scope.sidebarPaths + diff --git a/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee index 5c1c80ce23..14c924e275 100644 --- a/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee @@ -1,14 +1,16 @@ -window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location, SpreeUser) -> +window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location, SpreeUser, Navigation) -> $scope.spree_user = SpreeUser.spree_user + $scope.path = "/signup" + Navigation.paths.push $scope.path $scope.errors = email: null password: null $scope.active = -> - $location.path() == '/signup' + $location.path() == $scope.path $scope.select = -> - $location.path("/signup") + Navigation.navigate($scope.path) $scope.submit = -> $http.post("/user/spree_user", {spree_user: $scope.spree_user}).success (data)-> diff --git a/app/assets/javascripts/darkswarm/services/navigation.js.coffee b/app/assets/javascripts/darkswarm/services/navigation.js.coffee new file mode 100644 index 0000000000..a89523dbff --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/navigation.js.coffee @@ -0,0 +1,12 @@ +Darkswarm.factory 'Navigation', ($location) -> + new class Navigation + paths: [] + path: null + + navigate: (path = false)-> + @path = path || @path || @paths[0] + + if $location.path() == @path + $location.path("/") + else + $location.path(@path) diff --git a/app/assets/stylesheets/darkswarm/all.scss b/app/assets/stylesheets/darkswarm/all.scss index 44e8ea248c..7c3f9de2d5 100644 --- a/app/assets/stylesheets/darkswarm/all.scss +++ b/app/assets/stylesheets/darkswarm/all.scss @@ -7,3 +7,4 @@ *= require foundation *= require_tree . */ +@import 'foundation-icons'; diff --git a/app/assets/stylesheets/darkswarm/header.css.sass b/app/assets/stylesheets/darkswarm/header.css.sass index 5d1764b8e1..5c4bdb13be 100644 --- a/app/assets/stylesheets/darkswarm/header.css.sass +++ b/app/assets/stylesheets/darkswarm/header.css.sass @@ -1,6 +1,10 @@ /*body { background: #ff0000; }*/ nav.top-bar margin-bottom: 0px + a.icon + line-height: auto + font-size: 1.75em + color: white body > section[role='main'] padding: 0px diff --git a/app/views/layouts/darkswarm.html.haml b/app/views/layouts/darkswarm.html.haml index 048e8a9dc1..51aaca837d 100644 --- a/app/views/layouts/darkswarm.html.haml +++ b/app/views/layouts/darkswarm.html.haml @@ -22,6 +22,4 @@ = yield #footer - - = yield :scripts diff --git a/app/views/shared/_login_sidebar.html.haml b/app/views/shared/_login_sidebar.html.haml index b5b05ca245..3f7ca15b0d 100644 --- a/app/views/shared/_login_sidebar.html.haml +++ b/app/views/shared/_login_sidebar.html.haml @@ -3,8 +3,10 @@ active: "active()", select: "select()"} %form{"ng-submit" => "submit()"} - .alert-box.alert{"ng-show" => "errors != null"} - {{ errors }} + .row + .large-12.columns + .alert-box.alert{"ng-show" => "errors != null"} + {{ errors }} .row .large-12.columns %label{for: "email"} Email diff --git a/app/views/shared/_menu.html.haml b/app/views/shared/_menu.html.haml index fe0faf1143..2ef3b3d566 100644 --- a/app/views/shared/_menu.html.haml +++ b/app/views/shared/_menu.html.haml @@ -1,6 +1,9 @@ %nav.top-bar %section.top-bar-section %ul.left{"ng-controller" => "MenuCtrl"} + %li + %a.icon{"ng-click" => "toggle()"} + %i.fi-list %li= link_to image_tag("ofn_logo_small.png"), root_path %li.divider - if spree_current_user.nil? diff --git a/app/views/shared/_sidebar.html.haml b/app/views/shared/_sidebar.html.haml index d4c96f4a33..fa903565d6 100644 --- a/app/views/shared/_sidebar.html.haml +++ b/app/views/shared/_sidebar.html.haml @@ -1,7 +1,13 @@ %section#sidebar{ role: "complementary", "ng-controller" => "SidebarCtrl", "ng-class" => "{'active' : active()}"} - %tabset - = render partial: "shared/login_sidebar" - = render partial: "shared/signup_sidebar" - = render partial: "shared/forgot_sidebar" + + - if spree_current_user.nil? + %tabset + = render partial: "shared/login_sidebar" + = render partial: "shared/signup_sidebar" + = render partial: "shared/forgot_sidebar" + - else + #account{"ng-controller" => "AccountSidebarCtrl"} + .row + You have an account! Well done = yield :sidebar diff --git a/spec/javascripts/unit/darkswarm/navigation.js.coffee b/spec/javascripts/unit/darkswarm/navigation.js.coffee new file mode 100644 index 0000000000..6630f8f955 --- /dev/null +++ b/spec/javascripts/unit/darkswarm/navigation.js.coffee @@ -0,0 +1,16 @@ +describe 'Navigation service', -> + Navigation = null + + beforeEach -> + module 'Darkswarm' + inject ($injector)-> + Navigation = $injector.get("Navigation") + + it "caches the path provided", -> + Navigation.navigate "/foo" + expect(Navigation.path).toEqual "/foo" + + it "defaults to the first path in the list", -> + Navigation.paths = ["/test", "/bar"] + Navigation.navigate() + expect(Navigation.path).toEqual "/test"