./script/plugin install git://github.com/autodata/picky-color.git
First of all you have to include the
picky_color.js to your layout :
Warning: This color-picker uses the prototype and scriptaculous librairies, therefore the corresponding js files have to be included to, if it's not the case, you just have to add the following line before the
For the case 2 and 3 of this example I will act as if I have to put a color picker for the field color of my model post
This plugin offer 3 way to use the helper :
Using it like a tag from FormTagHelper.
<%= picky_color_tag "my_color", "000000" %>
Using it as a FormHelper
<%= picky_color :post, :color %>
Using it in the Formbuilder
<% form_for(@post) do |f| %> <%= f.picky_color :color %> <% end %>
It is of course possible to add any html option in addition to these parameters as a Hash as last parameter of the methods. They will be applied on the input text field :
<%= picky_color :post, :color, :class => "my_sexy_class" %>
In addition to the html options, you have at your disposal 3 custom parameters : draggable, close_text and default
:close_texttakes a string and is the text of the confirm button of the color picker, default is "OK"
:draggabletakes a boolean and set if the color picker is draggable or not, default is false
:defaulttakes a string and is the default color shown by the color picker, default is "000000"
<%= picky_color :post, :color, :draggable => true, :close_text => "ColorMe!", :default => "0fe" %>
Authors and credits
Author of the plugin : Morgan Hotonnier Original author of the picker : Brandon Arbini/Sevenwire
Thanks to wildgoose, the author of the rails calendar_date_select plugin, whose code helped me a lot to figure out how to integrate my helper in the built-in formbuilder
A special thanks to Gabriel Laskar, who helped me a lot for this plugin, which is my first one. "Merci papi Gabi!"
Comments and suggestions
It's my first plugin therefore I'm sure my code is a mess and deserve a lot of improvements, all suggestions are really welcome!
Copyright (c) 2008 Morgan Hotonnier firstname.lastname@example.org, released under the MIT license