Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
0e21436a
Commit
0e21436a
authored
Jun 05, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the javascript behavior for Preference updating
parent
5f20574d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
14 deletions
+18
-14
app/assets/javascripts/profile.js.coffee
app/assets/javascripts/profile.js.coffee
+3
-6
app/views/profiles/preferences/show.html.haml
app/views/profiles/preferences/show.html.haml
+6
-8
app/views/profiles/preferences/update.js.erb
app/views/profiles/preferences/update.js.erb
+1
-0
spec/features/profiles/preferences_spec.rb
spec/features/profiles/preferences_spec.rb
+8
-0
No files found.
app/assets/javascripts/profile.js.coffee
View file @
0e21436a
class
@
Profile
class
@
Profile
constructor
:
->
constructor
:
->
$
(
'.edit_user .application-theme input, .edit_user .code-preview-theme input'
).
click
->
# Automatically submit the Preferences form when any of its radio buttons change
# Submit the form
$
(
'.js-preferences-form'
).
on
'change.preference'
,
'input[type=radio]'
,
->
$
(
'.edit_user'
).
submit
()
$
(
this
).
parents
(
'form'
).
submit
()
new
Flash
(
'Preferences saved.'
,
'notice'
)
$
(
'.update-username form'
).
on
'ajax:before'
,
->
$
(
'.update-username form'
).
on
'ajax:before'
,
->
$
(
'.loading-gif'
).
show
()
$
(
'.loading-gif'
).
show
()
...
@@ -18,7 +16,6 @@ class @Profile
...
@@ -18,7 +16,6 @@ class @Profile
$
(
'.update-notifications'
).
on
'ajax:complete'
,
->
$
(
'.update-notifications'
).
on
'ajax:complete'
,
->
$
(
this
).
find
(
'.btn-save'
).
enable
()
$
(
this
).
find
(
'.btn-save'
).
enable
()
$
(
'.js-choose-user-avatar-button'
).
bind
"click"
,
->
$
(
'.js-choose-user-avatar-button'
).
bind
"click"
,
->
form
=
$
(
this
).
closest
(
"form"
)
form
=
$
(
this
).
closest
(
"form"
)
form
.
find
(
".js-user-avatar-input"
).
click
()
form
.
find
(
".js-user-avatar-input"
).
click
()
...
...
app/views/profiles/preferences/show.html.haml
View file @
0e21436a
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
Appearance settings will be saved to your profile and made available across all devices.
Appearance settings will be saved to your profile and made available across all devices.
%hr
%hr
=
form_for
@user
,
url:
profile_preferences_path
,
remote:
true
,
method: :put
do
|
f
|
=
form_for
@user
,
url:
profile_preferences_path
,
remote:
true
,
method: :put
,
html:
{
class:
'js-preferences-form'
}
do
|
f
|
.panel.panel-default.application-theme
.panel.panel-default.application-theme
.panel-heading
.panel-heading
Application theme
Application theme
...
@@ -20,10 +20,8 @@
...
@@ -20,10 +20,8 @@
.panel-heading
.panel-heading
Code preview theme
Code preview theme
.panel-body
.panel-body
.code_highlight_opts
-
color_schemes
.
each
do
|
color_scheme_id
,
color_scheme
|
-
color_schemes
.
each
do
|
color_scheme_id
,
color_scheme
|
=
label_tag
do
=
label_tag
do
.prev
.preview
=
image_tag
"
#{
color_scheme
}
-scheme-preview.png"
=
image_tag
"
#{
color_scheme
}
-scheme-preview.png"
=
f
.
radio_button
:color_scheme_id
,
color_scheme_id
=
f
.
radio_button
:color_scheme_id
,
color_scheme_id
=
color_scheme
.
gsub
(
/[-_]+/
,
' '
).
human
ize
=
color_scheme
.
tr
(
'-_'
,
' '
).
title
ize
app/views/profiles/preferences/update.js.erb
View file @
0e21436a
// Remove body class for any previous theme, re-add current one
// Remove body class for any previous theme, re-add current one
$('body').removeClass('
<%=
Gitlab
::
Themes
.
body_classes
%>
')
$('body').removeClass('
<%=
Gitlab
::
Themes
.
body_classes
%>
')
$('body').addClass('
<%=
user_application_theme
%>
')
$('body').addClass('
<%=
user_application_theme
%>
')
new Flash('
<%=
flash
.
discard
(
:notice
)
%>
', 'notice')
spec/features/profiles/preferences_spec.rb
View file @
0e21436a
...
@@ -15,6 +15,14 @@ describe 'Profile > Preferences' do
...
@@ -15,6 +15,14 @@ describe 'Profile > Preferences' do
visit
profile_preferences_path
visit
profile_preferences_path
end
end
it
'creates a flash message'
do
choose
"user_theme_id_
#{
theme
.
id
}
"
within
(
'.flash-container'
)
do
expect
(
page
).
to
have_content
(
'Preferences saved.'
)
end
end
it
'reflects the changes immediately'
do
it
'reflects the changes immediately'
do
expect
(
page
).
to
have_selector
(
"body.
#{
default
.
css_class
}
"
)
expect
(
page
).
to
have_selector
(
"body.
#{
default
.
css_class
}
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment