Back in November I wanted a mechanism to communicate messages after an ajax request to my PageSite users. I experimented with a number of things and initially had a terribly ugly manipulation of the green and red message boxes you'll see on this type from time to time. There were a couple of big problems though, first the code was originally written for Prototype so it sucked, and second it was not very portable. Ultimately I wanted something that looked good, was well written and could be reused in a number of different ways.
When PageSite was converted to using jQuery for all of its javascript I rehashed a lot of stuff. There was some old javascript code that had been floating around since 2004 when I first prototyped out PageSite 4.0's admin panel. To cut to the chase... I stumbled across Humanized Messages, which was close to what I wanted to do, but not yet there. This plugin got me to thinking, though, what I'd really like is something that looked like Growl. For those not on OS X, take a look at the website and you'll see that Growl is a system-wide notification system.
As a result, while Erich was out here visiting I fleshed out an initial concept. I called it jGrowl, spinning off of the OS X solution. It's pretty simple to use out of the box:
// Normal notification
$.jGrowl("Here is my message!");
// Sticky notification
$.jGrowl("This message is stuck!", { sticky: true });
Today I sat down and cleaned up some of the plugin, namely I removed a dependency on the metadata plugin in favor of $.fn.data() and I also namespaced all of the events, which should allow you to attach other events to the jGrowl nodes and deal with them without jGrowl unbinding them on you.
The plugin still needs some work, I'm not sure how much I like styling it with javascript - at the same rate, I like the idea of styling different notifications differently as well. I'd also like to see some callback options, the animations customizable and I'd like to potentially add some internal sorting using the "header" option. These things, though, will come in time - for now I just want to get the plugin out so I can get some feedback.
Updated 03/24/08: The plugin is available at: http://stanlemon.net/files/jgrowl-1.0.2.zip, please let me know what you think!
Post Comment: