xaguilars/bootstrap-colorpicker — pull request #3 by tiagoblackcode (2012-11-28 21:10:35+00:00)
Title: Added a color palette and the option to provide an input selector in the component mode.

First of all, thanks for both yours and the original author's work in making this neat plugin. I had some requirements this plugin didn't provided so I added them.

First, when the colorpicker is used within a component (`.input-append` or `.input-prepend`) I've added an option that accepts an input selector to place the color code into. This input is searched within the component and is passed through the `data-color-input` attribute in the top `

` element of the component. It's goes something like this:

```

```

This allows you to change the color of a given input (for instance when color-labeling categories or something like that) while hiding the technical details of the color used. In the code above, the "This remains untouched" input does not change accordingly to the color selected, but the `hidden` input does. The selector only looks for the input INSIDE the component so that one can dynamically add components (as you do with a has_many association) without having to worry in re-writing the input's id.

Secondly, I also added the option to provide a color palette. This palette draws inside the dropdown menu and accepts a set of colors through the `data-color-palette` attribute like this:

```

```

This allows you to provide some templated colors so the user can select them. It is much like the colorpicker Mac OS provides but with predefined colors instead of custom ones. I wrapped the palette inside a table so that the spacing between the different palette items are equal. The `data-color-palette` accepts only a JSON array and does not do any kind of validations. For what I've seen, this accepts the colors in the same various formats as css.

Please provide some feedback, improvements and such.

Best regards,
Tiago Melo