Improve user feedback on the Profile > Design page
- Header changes immediately without a page reload - Lets the user know that we actually saved their setting when changed
This commit is contained in:
parent
0046409970
commit
30a66c065a
7 changed files with 73 additions and 12 deletions
10
app/assets/javascripts/profile.js.coffee
Normal file
10
app/assets/javascripts/profile.js.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
$ ->
|
||||
$('.edit_user .application-theme input, .edit_user .code-preview-theme input').click ->
|
||||
# Hide any previous submission feedback
|
||||
$('.edit_user .update-feedback').hide()
|
||||
|
||||
# Submit the form
|
||||
$('.edit_user').submit()
|
||||
|
||||
# Go up the hierarchy and show the corresponding submission feedback element
|
||||
$(@).closest('fieldset').find('.update-feedback').show('highlight', {color: '#DFF0D8'}, 500)
|
|
@ -1,3 +1,10 @@
|
|||
.application-theme, .code-preview-theme {
|
||||
.update-feedback {
|
||||
color: #468847;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
.themes_opts {
|
||||
padding-left:20px;
|
||||
|
||||
|
|
|
@ -9,7 +9,11 @@ class ProfileController < ApplicationController
|
|||
|
||||
def update
|
||||
@user.update_attributes(params[:user])
|
||||
redirect_to :back
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def token
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
= form_for @user, url: profile_update_path, remote: true, method: :put do |f|
|
||||
%fieldset
|
||||
%legend Application theme
|
||||
%fieldset.application-theme
|
||||
%legend
|
||||
Application theme
|
||||
.update-feedback.hide
|
||||
%i.icon-ok
|
||||
Saved
|
||||
.themes_opts
|
||||
= label_tag do
|
||||
.prev.default
|
||||
|
@ -29,8 +33,12 @@
|
|||
%br
|
||||
.clearfix
|
||||
|
||||
%fieldset
|
||||
%legend Code review
|
||||
%fieldset.code-preview-theme
|
||||
%legend
|
||||
Code preview theme
|
||||
.update-feedback.hide
|
||||
%i.icon-ok
|
||||
Saved
|
||||
.code_highlight_opts
|
||||
= label_tag do
|
||||
.prev
|
||||
|
@ -42,10 +50,3 @@
|
|||
= image_tag "dark.png"
|
||||
= f.radio_button :dark_scheme, true
|
||||
Dark code preview
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
$(".edit_user input").bind("click", function() {
|
||||
$(".edit_user").submit();
|
||||
});
|
||||
})
|
||||
|
|
9
app/views/profile/update.js.erb
Normal file
9
app/views/profile/update.js.erb
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Remove body class for any previous theme, re-add current one
|
||||
$('body').removeClass('ui_basic ui_mars ui_modern ui_gray ui_color')
|
||||
$('body').addClass('<%= app_theme %>')
|
||||
|
||||
// Re-render the header to reflect the new theme
|
||||
$('header').html('<%= escape_javascript(render("layouts/head_panel", title: "Profile")) %>')
|
||||
|
||||
// Re-initialize header tooltips
|
||||
$('.has_bottom_tooltip').tooltip({placement: 'bottom'})
|
Loading…
Add table
Add a link
Reference in a new issue