refactor flash

* make unobtrusive js
* convert js to coffee
This commit is contained in:
Cyril 2012-11-29 22:51:51 +01:00
parent c177593e2c
commit a9a5497915
4 changed files with 12 additions and 19 deletions

View file

@ -33,6 +33,11 @@ $ ->
# Bottom tooltip # Bottom tooltip
$('.has_bottom_tooltip').tooltip(placement: 'bottom') $('.has_bottom_tooltip').tooltip(placement: 'bottom')
# Flash
if (flash = $("#flash-container")).length > 0
flash.click -> $(@).slideUp("slow")
flash.slideDown "slow"
setTimeout (-> flash.slideUp("slow")), 3000
# Disable form buttons while a form is submitting # Disable form buttons while a form is submitting
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->

View file

@ -68,7 +68,7 @@ table a code {
} }
/** FLASH message **/ /** FLASH message **/
#flash_container { #flash-container {
height: 50px; height: 50px;
position: fixed; position: fixed;
z-index: 10001; z-index: 10001;
@ -79,6 +79,8 @@ table a code {
background: white; background: white;
cursor: pointer; cursor: pointer;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
text-align: center;
display: none;
h4 { h4 {
color: #666; color: #666;

View file

@ -1,17 +1,3 @@
- if alert || notice - if text = alert || notice
- text = alert || notice #flash-container
%div{style: "display:none", id: "flash_container"}
%center
%h4= text %h4= text
:javascript
$(function(){
$("#flash_container").slideDown("slow");
$("#flash_container").click(function(){
$(this).slideUp("slow");
});
setTimeout("hideFlash()",3000);
});
function hideFlash(){
$("#flash_container").slideUp("slow");
}

View file

@ -2,5 +2,5 @@
%html{ lang: "en"} %html{ lang: "en"}
= render "layouts/head" = render "layouts/head"
%body.ui_basic.login-page %body.ui_basic.login-page
= render partial: "layouts/flash" = render "layouts/flash"
.container= yield .container= yield