A simple component to select color in the same way you select color in Adobe Photoshop
How to create a color picker?
1. Initialize the plugin
jQuery('#colorpickerField1').ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
jQuery(el).val(hex);
jQuery(el).ColorPickerHide();
},
onBeforeShow: function () {
jQuery(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
jQuery(this).ColorPickerSetColor(this.value);
});"colorpickerField1" (for this example)<input type="text" id="colorpickerField1" value="00ff00" />
| OPTION | TYPE / VALUE | DESCRIPTION |
|---|---|---|
eventName | string |
The desired event to trigger the colorpicker. Default: 'click' |
color | string or hash |
The default color. String for hex color or hash for RGB and HSB ({r:255, r:0, b:0}) . Default: 'ff0000' |
flat | boolean |
Whatever if the color picker is appended to the element or triggered by an event. Default false |
livePreview | boolean |
Whatever if the color values are filled in the fields while changing values on selector or a field. If false it may improve speed. Default true |
onShow | function |
Callback function triggered when the color picker is shown |
onBeforeShow | function |
Callback function triggered before the color picker is shown |
onHide | function |
Callback function triggered when the color picker is hidden |
onChange | function |
Callback function triggered when the color is changed |
onSubmit | function |
Callback function triggered when the color it is chosen |
| OPTION | TYPE / VALUE | DESCRIPTION |