Commit f2e1c8b709f9467cc8671b9f25286bece7002e3e
Exists in
master
and in
4 other branches
Merge pull request #2138 from jouve/refactor_flash
refactor flash
Showing
4 changed files
with
12 additions
and
19 deletions
Show diff stats
app/assets/javascripts/main.js.coffee
| @@ -33,6 +33,11 @@ $ -> | @@ -33,6 +33,11 @@ $ -> | ||
| 33 | # Bottom tooltip | 33 | # Bottom tooltip |
| 34 | $('.has_bottom_tooltip').tooltip(placement: 'bottom') | 34 | $('.has_bottom_tooltip').tooltip(placement: 'bottom') |
| 35 | 35 | ||
| 36 | + # Flash | ||
| 37 | + if (flash = $("#flash-container")).length > 0 | ||
| 38 | + flash.click -> $(@).slideUp("slow") | ||
| 39 | + flash.slideDown "slow" | ||
| 40 | + setTimeout (-> flash.slideUp("slow")), 3000 | ||
| 36 | 41 | ||
| 37 | # Disable form buttons while a form is submitting | 42 | # Disable form buttons while a form is submitting |
| 38 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> | 43 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> |
app/assets/stylesheets/common.scss
| @@ -68,7 +68,7 @@ table a code { | @@ -68,7 +68,7 @@ table a code { | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /** FLASH message **/ | 70 | /** FLASH message **/ |
| 71 | -#flash_container { | 71 | +#flash-container { |
| 72 | height: 50px; | 72 | height: 50px; |
| 73 | position: fixed; | 73 | position: fixed; |
| 74 | z-index: 10001; | 74 | z-index: 10001; |
| @@ -79,6 +79,8 @@ table a code { | @@ -79,6 +79,8 @@ table a code { | ||
| 79 | background: white; | 79 | background: white; |
| 80 | cursor: pointer; | 80 | cursor: pointer; |
| 81 | border-bottom: 1px solid #ccc; | 81 | border-bottom: 1px solid #ccc; |
| 82 | + text-align: center; | ||
| 83 | + display: none; | ||
| 82 | 84 | ||
| 83 | h4 { | 85 | h4 { |
| 84 | color: #666; | 86 | color: #666; |
app/views/layouts/_flash.html.haml
| 1 | -- if alert || notice | ||
| 2 | - - text = alert || notice | ||
| 3 | - %div{style: "display:none", id: "flash_container"} | ||
| 4 | - %center | ||
| 5 | - %h4= text | ||
| 6 | - :javascript | ||
| 7 | - $(function(){ | ||
| 8 | - $("#flash_container").slideDown("slow"); | ||
| 9 | - $("#flash_container").click(function(){ | ||
| 10 | - $(this).slideUp("slow"); | ||
| 11 | - }); | ||
| 12 | - setTimeout("hideFlash()",3000); | ||
| 13 | - }); | ||
| 14 | - | ||
| 15 | - function hideFlash(){ | ||
| 16 | - $("#flash_container").slideUp("slow"); | ||
| 17 | - } | 1 | +- if text = alert || notice |
| 2 | + #flash-container | ||
| 3 | + %h4= text |
app/views/layouts/devise.html.haml