Skip to content

Commit

Permalink
allowed window duration to be configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fiorato committed Dec 25, 2008
1 parent b15754e commit 7d9499e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README
Expand Up @@ -30,14 +30,15 @@ In your view put the following:
Then when you'd like the Growl window to appear:

<script type="text/javascript" language="javascript">
Growl.show("/images/download.png", "Foo Bar.pdf", "File is ready for download.");
Growl.show("/images/download.png", "Foo Bar.pdf", "File is ready for download.", 5000);
</script>

Growl.show method takes 3 arguments:

image - 32x32 icon
title - title of the growl
message - the growl message
duration - the length of time (in milliseconds) that the growl window shows

Authors
=======
Expand Down
16 changes: 11 additions & 5 deletions public/javascripts/growl4rails.js
Expand Up @@ -80,12 +80,18 @@ var Growl = Class.create({
});

this.growl_container.observe('mouseout', function(event) {
this.timeout = setTimeout("Growl.hide()",5000);
this.timeout = setTimeout("Growl.hide()", 3000);
Growl.unhighlight();
});
},

show: function(img, title, message) {
show: function(img, title, message, duration) {

if(duration)
this.duration = duration;
else
this.duration = 5000;

if(this.showing) return;
this.showing = true;

Expand Down Expand Up @@ -169,7 +175,7 @@ var Growl = Class.create({
Effect.Appear(this.growl_right);
}

this.timeout = setTimeout("Growl.hide()",5000);
this.timeout = setTimeout("Growl.hide()", this.duration);
},

hide: function() {
Expand Down Expand Up @@ -217,9 +223,9 @@ Event.observe(window, 'load', function(event) {
_growl = new Growl();
});

Growl.show = function(img, title, message) {
Growl.show = function(img, title, message, duration) {
if(!_growl) _growl = new Growl();
_growl.show(img, title, message);
_growl.show(img, title, message, duration);
};

Growl.hide = function() {
Expand Down

0 comments on commit 7d9499e

Please sign in to comment.