diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index db16faf..5da69b3 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -151,7 +151,7 @@ set_gettext_locale #Method defined at controllers/application_controller.rb set_flash_message :notice, _('Details successfully updated.') sign_in current_user, bypass: true # Sign in the user bypassing validation in case his password changed - redirect_to edit_user_registration_path(@tab), notice: _('Details successfully updated.') + redirect_to edit_user_registration_path(tab: @tab), notice: _('Details successfully updated.') else flash[:notice] = message.blank? ? failed_update_error(current_user, _('profile')) : message @@ -175,7 +175,7 @@ set_gettext_locale #Method defined at controllers/application_controller.rb set_flash_message :notice, _('Details successfully updated.') sign_in current_user, bypass: true # Sign in the user bypassing validation in case his password changed - redirect_to edit_user_registration_path(@tab), notice: _('Details successfully updated.') + redirect_to edit_user_registration_path(tab: @tab), notice: _('Details successfully updated.') else flash[:notice] = message.blank? ? failed_update_error(current_user, _('profile')) : message diff --git a/app/views/devise/registrations/_password_details.html.erb b/app/views/devise/registrations/_password_details.html.erb index 0b0e5eb..9a93588 100644 --- a/app/views/devise/registrations/_password_details.html.erb +++ b/app/views/devise/registrations/_password_details.html.erb @@ -1,4 +1,4 @@ -<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'password'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'password-details-tab'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %>
<%= _('If you would like to change your password please complete the following fields.') %> diff --git a/app/views/devise/registrations/_personal_details.html.erb b/app/views/devise/registrations/_personal_details.html.erb index 08a3f91..c2daadf 100644 --- a/app/views/devise/registrations/_personal_details.html.erb +++ b/app/views/devise/registrations/_personal_details.html.erb @@ -1,4 +1,4 @@ -<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'personal'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name, tab: 'personal-details-tab'), html: {method: :put, class: "roadmap-form white_background"}) do |f| %>

diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 761abf4..3c922a6 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -5,13 +5,13 @@

@@ -33,4 +33,8 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/users/_notification_preferences.html.erb b/app/views/users/_notification_preferences.html.erb index ce80fa2..81a3c58 100644 --- a/app/views/users/_notification_preferences.html.erb +++ b/app/views/users/_notification_preferences.html.erb @@ -5,7 +5,7 @@
- <%= form_tag( url_for(controller: 'users', action: 'update_preferences', tab: 'preferences', escape: false), html: {method: :put, class: "roadmap-form"}) do |f| %> + <%= form_tag( url_for(controller: 'users', action: 'update_preferences', tab: 'notification-preferences-tab', escape: false), html: {method: :put, class: "roadmap-form"}) do |f| %> <%= hidden_field_tag :user_id, @user.id %> diff --git a/lib/assets/javascripts/dmproadmap/tabs.js b/lib/assets/javascripts/dmproadmap/tabs.js index 1c68fdf..31f108b 100644 --- a/lib/assets/javascripts/dmproadmap/tabs.js +++ b/lib/assets/javascripts/dmproadmap/tabs.js @@ -11,11 +11,40 @@ if($(this).attr("href")[0] == '#'){ e.preventDefault(); - var panel = $($(this).attr("href")); + var panel = $($(this).attr("href")); panel.show().attr("aria-hidden", 'false'); $.each($(panel).siblings(), function(i, p){ $(p).hide().attr("aria-hidden", 'true'); }); } }); -}); \ No newline at end of file +}); + +function selectActiveTab(){ + var tab = getURLParameter('tab'); + if (tab != '') + { + // Unselect the other tabs + $("li[role='tab']").removeClass('active').children('a').attr('aria-selected', 'false'); + // Select the current tab + $(".tabs").find('#' + tab).attr('aria-selected', 'true').addClass('active'); + + // Display the corresponding panel if its a page anchor otherwise just follow the target + var panel = $(".tabs").find('#' + tab).children('a').attr("href"); + $(".tab-panels").find(panel).addClass('active'); + $.each($(".tab-panels").find(panel).siblings(), function(i, p){ + $(p).removeClass('active'); + }); + } +} + +function getURLParameter(sParam){ + var sPageURL = window.location.search.substring(1); + var sURLVariables = sPageURL.split('&'); + for (var i = 0; i < sURLVariables.length; i++) { + var sParameterName = sURLVariables[i].split('='); + if (sParameterName[0] == sParam){ + return sParameterName[1]; + } + } +} \ No newline at end of file