Wednesday, January 21, 2009

Update to Growl4Rails

Growl4Rails is now production ready. I've added the ability to show multiple growls at once, as well as improved support for IE. Here's a screen shot of the multiple Growls:

Unfortunately, the multiple growls thing was an entire rewrite of the code, so the usage is quite different.

Now, when you setup the includes, you specify default duration and max number of growls to show. These arguments are optional and will default to 3000 milliseconds and 3, respectively.

<%= growl4rails_includes(3000, 5) %>

Also, when showing the growls, the args are now a single hash, with named keys:

<script type="text/javascript" language="javascript">
title:"Foo Bar.pdf",
message:"File is ready for download."

When you want to handle the click event, you can wire up the event like so:

var growl_id = Growl4Rails.showGrowl({
title:"Foo Bar.pdf",
message:"File is ready for download."
document.observe(growl_id + ':clicked', function(event) {
console.log('Growl %s was clicked.', Event.findElement(event).id);

Again, it's open source, so if you want to contribute, or if you have any feedback, you can check out the project on GitHub.


Alfredo said...

tempted to use this to display the flash messages :)

Jim Fiorato said...

Go for it! Let me know how it works out for you.

Alex said...

Why is this a Rails plugin and not a JavaScript library?

Jim Fiorato said...

Hey Alex,

That's really all it is. The Rails plugin part just makes it really easy to distribute on to Rails apps. Given a small amount of effort you can tack on to any site Rails/HTML/Django/.NET.


mikedc55 said...

You my friend, are awesome

Jim Fiorato said...

For those that were wondering about using this without rails, I put up a blog post on how to do it.

TeamCo said...

Nice, but whats about title or messsage alignment?

Jim Fiorato said...

TeamCo, can you be more specific?

Caleb Cohoon said...

Thank you so much! This is perfect. :) I got it setup in no time.

Alexis said...

Hi Jim,

I made a port of your library to use it as a symfony plugin (php):


Jim Fiorato said...

Hey Alexis,

This is great. Thanks for letting me know.


Yellow Blade said...

Công ty vận chuyển hàng hóa nội địa chúng tôi xin giới thiệu các dịch vụ vận chuyển, dịch vụ ship hàng uy tín để phục vụ nhu cầu Tết của quý khách hàng. Cụ thể chúng tôi sẽ cung cấp dịch vụ chuyển quà tết. Chúng tôi sẽ giúp bạn vận chuyển hàng hóa đến tay người thân, bạn bè ở xa một cách nhanh chóng nhất. Đảm bảo giá cả hợp lý chất lượng dịch vụ tuyệt vời. Ngoài ra chúng tôi còn cung cấp nhiều dịch vụ khác như dịch vụ ship hàng cod, giao hàng cho shop, dịch vụ chuyển phát nhanh trong nước,... Nếu cần chuyển hàng hãy nhớ liên hệ với chúng tôi nhé.