summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--users/app/assets/javascripts/users.js.coffee8
-rw-r--r--users/app/controllers/users_controller.rb2
-rw-r--r--users/app/helpers/users_helper.rb5
-rw-r--r--users/app/views/users/edit.html.haml4
4 files changed, 16 insertions, 3 deletions
diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee
index 0c1fb55..86bacee 100644
--- a/users/app/assets/javascripts/users.js.coffee
+++ b/users/app/assets/javascripts/users.js.coffee
@@ -24,7 +24,15 @@ srp.error = (message) ->
pollUsers = (query, process) ->
$.get( "/users.json", query: query).done(process)
+followLocationHash = ->
+ location = window.location.hash
+ if location
+ href_select = 'a[href="' + location + '"]'
+ link = $(href_select)
+ link.tab('show') if link
+
$(document).ready ->
+ followLocationHash()
$('#new_user').submit preventDefault
$('#new_user').submit srp.signup
$('#new_session').submit preventDefault
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 811e8e5..feb66c8 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -36,7 +36,7 @@ class UsersController < ApplicationController
else
flash[:error] = @user.errors.full_messages
end
- respond_with @user, :location => edit_user_path(@user)
+ respond_with @user, :location => edit_user_path(@user, :anchor => :email)
end
def destroy
diff --git a/users/app/helpers/users_helper.rb b/users/app/helpers/users_helper.rb
index b017bca..6d76d6f 100644
--- a/users/app/helpers/users_helper.rb
+++ b/users/app/helpers/users_helper.rb
@@ -29,4 +29,9 @@ module UsersHelper
classes << (@user.new_record? ? 'new' : 'edit')
classes.compact
end
+
+ def email_settings?
+ params[:user] &&
+ params[:user].keys.detect{|key| key.index('email')}
+ end
end
diff --git a/users/app/views/users/edit.html.haml b/users/app/views/users/edit.html.haml
index 92ab71b..a2a0942 100644
--- a/users/app/views/users/edit.html.haml
+++ b/users/app/views/users/edit.html.haml
@@ -1,9 +1,9 @@
.span8.offset2
%h2=t :settings
%ul.nav.nav-tabs
- %li.active
+ %li{:class => email_settings? ? :inactive : :active}
%a{:href => '#account', 'data-toggle' => 'tab'}Account
- %li
+ %li{:class => email_settings? ? :active : :inactive}
%a{:href => '#email', 'data-toggle' => 'tab'}Email
.tab-content