Commit a2a7c809 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use flash message for notification across app

parent df9550c7
class Flash
constructor: (message, type)->
flash = $(".flash-container")
flash.html("")
$('<div/>',
class: "flash-#{type}",
text: message
).appendTo(".flash-container")
flash.click -> $(@).fadeOut()
flash.show()
setTimeout (-> flash.fadeOut()), 5000
@Flash = Flash
$ -> $ ->
$('.edit_user .application-theme input, .edit_user .code-preview-theme input').click -> $('.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 # Submit the form
$('.edit_user').submit() $('.edit_user').submit()
# Go up the hierarchy and show the corresponding submission feedback element new Flash("Appearance settings saved", "notice")
$(@).closest('fieldset').find('.update-feedback').show('highlight', {color: '#DFF0D8'}, 500)
$('.update-username form').on 'ajax:before', -> $('.update-username form').on 'ajax:before', ->
$('.loading-gif').show() $('.loading-gif').show()
...@@ -17,6 +13,6 @@ $ -> ...@@ -17,6 +13,6 @@ $ ->
$('.update-username form').on 'ajax:complete', -> $('.update-username form').on 'ajax:complete', ->
$(this).find('.btn-save').enableButton() $(this).find('.btn-save').enableButton()
$(this).find('.loading-gif').hide() $(this).find('.loading-gif').hide()
$('.update-notifications').on 'ajax:complete', -> $('.update-notifications').on 'ajax:complete', ->
$(this).find('.btn-save').enableButton() $(this).find('.btn-save').enableButton()
.save-status-fixed {
position: fixed;
left: 20px;
bottom: 50px;
}
.update-notifications { .update-notifications {
margin-bottom: 0; margin-bottom: 0;
label { label {
......
.application-theme, .code-preview-theme {
.update-feedback {
color: #468847;
float: right;
}
}
.themes_opts { .themes_opts {
padding-left: 20px; padding-left: 20px;
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
%fieldset.application-theme %fieldset.application-theme
%legend %legend
Application theme Application theme
.update-feedback.hide
%i.icon-ok
Saved
.themes_opts .themes_opts
= label_tag do = label_tag do
.prev.default .prev.default
...@@ -42,9 +39,6 @@ ...@@ -42,9 +39,6 @@
%fieldset.code-preview-theme %fieldset.code-preview-theme
%legend %legend
Code preview theme Code preview theme
.update-feedback.hide
%i.icon-ok
Saved
.code_highlight_opts .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
......
...@@ -56,12 +56,3 @@ ...@@ -56,12 +56,3 @@
- @users_projects.each do |users_project| - @users_projects.each do |users_project|
- notification = Notification.new(users_project) - notification = Notification.new(users_project)
= render 'settings', type: 'project', membership: users_project, notification: notification = render 'settings', type: 'project', membership: users_project, notification: notification
.save-status-fixed
%span.update-success.cgreen.hide
%i.icon-ok
Saved
%span.update-failed.cred.hide
%i.icon-remove
Failed
- if @saved - if @saved
:plain :plain
$('.save-status-fixed .update-success').showAndHide(); new Flash("Notification settings saved", "notice")
- else - else
:plain :plain
$('.save-status-fixed .update-failed').showAndHide(); new Flash("Failed to save new settings", "alert")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment