Monthly Archives for December 2007
29
DEC
Colour Picker Rails Plugin
Posted by Adam Posted in Rails Plugins 9 comments
A useful form helper to provide an easy to use colour picker field. Using this plugin you can simply provide a colour field with an integrated javascript colour picker.

Installation Instructions
1. Install the plugin into your Rails application
./script/plugin install http://svn.plasticrain.com/stuff/rails/plugins/colour_picker
This will automatically copy some required resources into the appropriate locations. The colour_picker.js file which powers all the javascript actions will be copied into public/javascripts. Also, a new folder will be created in your public/images folder to contain two required images – a spacer and alternative button icon.
You need to include the javascript in your application’s layout.
<%=javascript_include_tag 'colour_picker'%>
Within your form, simply call the ‘colour_field’ method:
<%=colour_field :object, :method%>

Usage Examples
Use the colour field with a graphical swatch icon rather than a button:
<%=colour_field :object, :method, :use_swatch_icon => true%>
Change the label of the default button:
<%=colour_field :object, :method, {}, {:value => 'Choose a colour' }%>
Code
Subversion – http://svn.plasticrain.com/stuff/rails/plugins/colour_picker