Revisions

  • 782b71 teddyze... Thu Sep 18 02:11:14 -0700 2008
gist: 11403 Download_button fork
public
Public Clone URL: git://gist.github.com/11403.git
Embed All Files: show embed
Automatic Fading Flash Messages.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
<% flash.each do |key, msg| -%>
<%= content_tag :p, msg, :id => key -%>
<% end -%>
*/
 
/* jQuery */
$(document).ready(function() {
  setTimeout(hideFlashMessages, 10000);
});
 
function hideFlashMessages() {
  $('p#notice, p#warning, p#error').fadeOut(5000)
}
 
/* Prototype */
document.observe("dom:loaded", function() {
  setTimeout(hideFlashMessages, 10000);
});
 
function hideFlashMessages() {
  $$('p#notice, p#warning, p#error').each(function(e) {
    if (e) Effect.Fade(e, { duration: 5.0 });
  });
}