Spry Ratings Widget

The release of Spry 1.6.1 didn't ensure the continued support for Adobe AIR but also came with a new widget called the ratings widget.

A little Ajax widget with some potential to be entirely over-used at least by me. As with most Spry widgets its ridiculously easy to use and setup. But not wanting to stop there I decided to create a custom component that would make it even easier oh and hook into a database to save the results (mySql only at this point).

I still need to clean up the code a little bit and add a few more features, but will put it up on RIAForge when it's prettier and documented :).

Currently to create a Spry Rating Widget you need one line of code:

<cfoutput>#createobject("component","rating").newWidget('ratingwidget','Rate this Post!',5,'../assets/js/','../assets/css/')#</cfoutput>

Resulting in widget that looks like:


The function header looks like this:

<cffunction name="newWidget" access="public" output="true" returntype="void">
   <cfargument name="ratingName" type="string" required="true" hint="This should be unique">
   <cfargument name="ratingTitle" type="string" required="true" hint="Title that will appear to the user">
   <cfargument name="ratingNumber" type="numeric" required="true" hint="Max number of stars">
   <cfargument name="pathToSpryJS" type="string" required="true" hint="relative or absolute web path to Spry widget JS files">
   <cfargument name="pathToSpryCSS" type="string" required="true" hint="relative or absolute web path to Spry widget CSS files">

I decided to make the path to the Spry CSS and JS as separate arguments to provide the most flexibility in directory structure. The argument list will probably grow a little bit more as I add a few more features but those will probably become optional parameters.

Happy coding...

Comments