2 * Bootstrap Colorpicker
3 * http://mjolnic.github.io/bootstrap-colorpicker/
5 * Originally written by (c) 2012 Stefan Petre
6 * Licensed under the Apache License v2.0
7 * http://www.apache.org/licenses/LICENSE-2.0.txt
14 if (typeof exports === 'object') {
15 module.exports = factory(window.jQuery);
16 } else if (typeof define === 'function' && define.amd) {
17 define(['jquery'], factory);
18 } else if (window.jQuery && !window.jQuery.fn.colorpicker) {
19 factory(window.jQuery);
26 var Color = function(val, customColors) {
33 this.origFormat = null; // original string format
35 $.extend(this.colors, customColors);
38 if (val.toLowerCase !== undefined) {
42 } else if (val.h !== undefined) {
50 // 140 predefined colors from the HTML Colors spec
52 "aliceblue": "#f0f8ff",
53 "antiquewhite": "#faebd7",
55 "aquamarine": "#7fffd4",
60 "blanchedalmond": "#ffebcd",
62 "blueviolet": "#8a2be2",
64 "burlywood": "#deb887",
65 "cadetblue": "#5f9ea0",
66 "chartreuse": "#7fff00",
67 "chocolate": "#d2691e",
69 "cornflowerblue": "#6495ed",
70 "cornsilk": "#fff8dc",
73 "darkblue": "#00008b",
74 "darkcyan": "#008b8b",
75 "darkgoldenrod": "#b8860b",
76 "darkgray": "#a9a9a9",
77 "darkgreen": "#006400",
78 "darkkhaki": "#bdb76b",
79 "darkmagenta": "#8b008b",
80 "darkolivegreen": "#556b2f",
81 "darkorange": "#ff8c00",
82 "darkorchid": "#9932cc",
84 "darksalmon": "#e9967a",
85 "darkseagreen": "#8fbc8f",
86 "darkslateblue": "#483d8b",
87 "darkslategray": "#2f4f4f",
88 "darkturquoise": "#00ced1",
89 "darkviolet": "#9400d3",
90 "deeppink": "#ff1493",
91 "deepskyblue": "#00bfff",
93 "dodgerblue": "#1e90ff",
94 "firebrick": "#b22222",
95 "floralwhite": "#fffaf0",
96 "forestgreen": "#228b22",
98 "gainsboro": "#dcdcdc",
99 "ghostwhite": "#f8f8ff",
101 "goldenrod": "#daa520",
104 "greenyellow": "#adff2f",
105 "honeydew": "#f0fff0",
106 "hotpink": "#ff69b4",
107 "indianred": "#cd5c5c",
111 "lavender": "#e6e6fa",
112 "lavenderblush": "#fff0f5",
113 "lawngreen": "#7cfc00",
114 "lemonchiffon": "#fffacd",
115 "lightblue": "#add8e6",
116 "lightcoral": "#f08080",
117 "lightcyan": "#e0ffff",
118 "lightgoldenrodyellow": "#fafad2",
119 "lightgrey": "#d3d3d3",
120 "lightgreen": "#90ee90",
121 "lightpink": "#ffb6c1",
122 "lightsalmon": "#ffa07a",
123 "lightseagreen": "#20b2aa",
124 "lightskyblue": "#87cefa",
125 "lightslategray": "#778899",
126 "lightsteelblue": "#b0c4de",
127 "lightyellow": "#ffffe0",
129 "limegreen": "#32cd32",
131 "magenta": "#ff00ff",
133 "mediumaquamarine": "#66cdaa",
134 "mediumblue": "#0000cd",
135 "mediumorchid": "#ba55d3",
136 "mediumpurple": "#9370d8",
137 "mediumseagreen": "#3cb371",
138 "mediumslateblue": "#7b68ee",
139 "mediumspringgreen": "#00fa9a",
140 "mediumturquoise": "#48d1cc",
141 "mediumvioletred": "#c71585",
142 "midnightblue": "#191970",
143 "mintcream": "#f5fffa",
144 "mistyrose": "#ffe4e1",
145 "moccasin": "#ffe4b5",
146 "navajowhite": "#ffdead",
148 "oldlace": "#fdf5e6",
150 "olivedrab": "#6b8e23",
152 "orangered": "#ff4500",
154 "palegoldenrod": "#eee8aa",
155 "palegreen": "#98fb98",
156 "paleturquoise": "#afeeee",
157 "palevioletred": "#d87093",
158 "papayawhip": "#ffefd5",
159 "peachpuff": "#ffdab9",
163 "powderblue": "#b0e0e6",
166 "rosybrown": "#bc8f8f",
167 "royalblue": "#4169e1",
168 "saddlebrown": "#8b4513",
170 "sandybrown": "#f4a460",
171 "seagreen": "#2e8b57",
172 "seashell": "#fff5ee",
175 "skyblue": "#87ceeb",
176 "slateblue": "#6a5acd",
177 "slategray": "#708090",
179 "springgreen": "#00ff7f",
180 "steelblue": "#4682b4",
183 "thistle": "#d8bfd8",
185 "turquoise": "#40e0d0",
189 "whitesmoke": "#f5f5f5",
191 "yellowgreen": "#9acd32",
192 "transparent": "transparent"
194 _sanitizeNumber: function(val) {
195 if (typeof val === 'number') {
198 if (isNaN(val) || (val === null) || (val === '') || (val === undefined)) {
201 if (val.toLowerCase !== undefined) {
202 return parseFloat(val);
206 isTransparent: function(strVal) {
210 strVal = strVal.toLowerCase().trim();
211 return (strVal === 'transparent') || (strVal.match(/#?00000000/)) || (strVal.match(/(rgba|hsla)\(0,0,0,0?\.?0\)/));
213 rgbaIsTransparent: function(rgba) {
214 return ((rgba.r === 0) && (rgba.g === 0) && (rgba.b === 0) && (rgba.a === 0));
216 //parse a string to HSB
217 setColor: function(strVal) {
218 strVal = strVal.toLowerCase().trim();
220 if (this.isTransparent(strVal)) {
228 this.value = this.stringToHSB(strVal) || {
233 }; // if parser fails, defaults to black
237 stringToHSB: function(strVal) {
238 strVal = strVal.toLowerCase();
240 if (typeof this.colors[strVal] !== 'undefined') {
241 strVal = this.colors[strVal];
246 $.each(this.stringParsers, function(i, parser) {
247 var match = parser.re.exec(strVal),
248 values = match && parser.parse.apply(that, [match]),
249 format = alias || parser.format || 'rgba';
251 if (format.match(/hsla?/)) {
252 result = that.RGBtoHSB.apply(that, that.HSLtoRGB.apply(that, values));
254 result = that.RGBtoHSB.apply(that, values);
256 that.origFormat = format;
263 setHue: function(h) {
264 this.value.h = 1 - h;
266 setSaturation: function(s) {
269 setBrightness: function(b) {
270 this.value.b = 1 - b;
272 setAlpha: function(a) {
273 this.value.a = parseInt((1 - a) * 100, 10) / 100;
275 toRGB: function(h, s, b, a) {
285 X = C * (1 - Math.abs(h % 2 - 1));
289 R += [C, X, 0, 0, X, C][h];
290 G += [X, C, C, X, 0, 0][h];
291 B += [0, 0, X, C, C, X][h];
293 r: Math.round(R * 255),
294 g: Math.round(G * 255),
295 b: Math.round(B * 255),
299 toHex: function(h, s, b, a) {
300 var rgb = this.toRGB(h, s, b, a);
301 if (this.rgbaIsTransparent(rgb)) {
302 return 'transparent';
304 return '#' + ((1 << 24) | (parseInt(rgb.r) << 16) | (parseInt(rgb.g) << 8) | parseInt(rgb.b)).toString(16).substr(1);
306 toHSL: function(h, s, b, a) {
307 h = h || this.value.h;
308 s = s || this.value.s;
309 b = b || this.value.b;
310 a = a || this.value.a;
315 if (L > 0 && L <= 1) {
331 toAlias: function(r, g, b, a) {
332 var rgb = this.toHex(r, g, b, a);
333 for (var alias in this.colors) {
334 if (this.colors[alias] === rgb) {
340 RGBtoHSB: function(r, g, b, a) {
346 V = Math.max(r, g, b);
347 C = V - Math.min(r, g, b);
348 H = (C === 0 ? null :
349 V === r ? (g - b) / C :
350 V === g ? (b - r) / C + 2 :
353 H = ((H + 360) % 6) * 60 / 360;
354 S = C === 0 ? 0 : C / V;
356 h: this._sanitizeNumber(H),
359 a: this._sanitizeNumber(a)
362 HueToRGB: function(p, q, h) {
369 return p + (q - p) * h * 6;
370 } else if ((h * 2) < 1) {
372 } else if ((h * 3) < 2) {
373 return p + (q - p) * ((2 / 3) - h) * 6;
378 HSLtoRGB: function(h, s, l, a) {
391 var tr = h + (1 / 3);
393 var tb = h - (1 / 3);
395 var r = Math.round(this.HueToRGB(p, q, tr) * 255);
396 var g = Math.round(this.HueToRGB(p, q, tg) * 255);
397 var b = Math.round(this.HueToRGB(p, q, tb) * 255);
398 return [r, g, b, this._sanitizeNumber(a)];
400 toString: function(format) {
401 format = format || 'rgba';
407 if (this.rgbaIsTransparent(c)) {
408 return 'transparent';
410 return 'rgb(' + c.r + ',' + c.g + ',' + c.b + ')';
416 return 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')';
422 return 'hsl(' + Math.round(c.h * 360) + ',' + Math.round(c.s * 100) + '%,' + Math.round(c.l * 100) + '%)';
428 return 'hsla(' + Math.round(c.h * 360) + ',' + Math.round(c.s * 100) + '%,' + Math.round(c.l * 100) + '%,' + c.a + ')';
437 return this.toAlias() || this.toHex();
445 // a set of RE's that can match strings and generate color tuples.
446 // from John Resig color plugin
447 // https://github.com/jquery/jquery-color/
449 re: /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,
451 parse: function(execResult) {
460 re: /rgb\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
462 parse: function(execResult) {
464 2.55 * execResult[1],
465 2.55 * execResult[2],
466 2.55 * execResult[3],
471 re: /rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
473 parse: function(execResult) {
482 re: /rgba\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
484 parse: function(execResult) {
486 2.55 * execResult[1],
487 2.55 * execResult[2],
488 2.55 * execResult[3],
493 re: /hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
495 parse: function(execResult) {
504 re: /hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
506 parse: function(execResult) {
515 re: /#?([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
517 parse: function(execResult) {
519 parseInt(execResult[1], 16),
520 parseInt(execResult[2], 16),
521 parseInt(execResult[3], 16),
526 re: /#?([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
528 parse: function(execResult) {
530 parseInt(execResult[1] + execResult[1], 16),
531 parseInt(execResult[2] + execResult[2], 16),
532 parseInt(execResult[3] + execResult[3], 16),
537 colorNameToHex: function(name) {
538 if (typeof this.colors[name.toLowerCase()] !== 'undefined') {
539 return this.colors[name.toLowerCase()];
547 horizontal: false, // horizontal mode layout ?
548 inline: false, //forces to show the colorpicker as an inline element
549 color: false, //forces a color
550 format: false, //forces a format
551 input: 'input', // children input selector
552 container: false, // container selector
553 component: '.add-on, .input-group-addon', // children component selector
558 callLeft: 'setSaturation',
559 callTop: 'setBrightness'
578 callLeft: 'setSaturation',
579 callTop: 'setBrightness'
590 callLeft: 'setAlpha',
594 template: '<div class="colorpicker dropdown-menu">' +
595 '<div class="colorpicker-saturation"><i><b></b></i></div>' +
596 '<div class="colorpicker-hue"><i></i></div>' +
597 '<div class="colorpicker-alpha"><i></i></div>' +
598 '<div class="colorpicker-color"><div /></div>' +
599 '<div class="colorpicker-selectors"></div>' +
606 var Colorpicker = function(element, options) {
607 this.element = $(element).addClass('colorpicker-element');
608 this.options = $.extend(true, {}, defaults, this.element.data(), options);
609 this.component = this.options.component;
610 this.component = (this.component !== false) ? this.element.find(this.component) : false;
611 if (this.component && (this.component.length === 0)) {
612 this.component = false;
614 this.container = (this.options.container === true) ? this.element : this.options.container;
615 this.container = (this.container !== false) ? $(this.container) : false;
617 // Is the element an input? Should we search inside for any input?
618 this.input = this.element.is('input') ? this.element : (this.options.input ?
619 this.element.find(this.options.input) : false);
620 if (this.input && (this.input.length === 0)) {
624 this.color = new Color(this.options.color !== false ? this.options.color : this.getValue(), this.options.colorSelectors);
625 this.format = this.options.format !== false ? this.options.format : this.color.origFormat;
627 if (this.options.color !== false) {
628 this.updateInput(this.color);
629 this.updateData(this.color);
633 this.picker = $(this.options.template);
634 if (this.options.customClass) {
635 this.picker.addClass(this.options.customClass);
637 if (this.options.inline) {
638 this.picker.addClass('colorpicker-inline colorpicker-visible');
640 this.picker.addClass('colorpicker-hidden');
642 if (this.options.horizontal) {
643 this.picker.addClass('colorpicker-horizontal');
645 if (this.format === 'rgba' || this.format === 'hsla' || this.options.format === false) {
646 this.picker.addClass('colorpicker-with-alpha');
648 if (this.options.align === 'right') {
649 this.picker.addClass('colorpicker-right');
651 if (this.options.inline === true) {
652 this.picker.addClass('colorpicker-no-arrow');
654 if (this.options.colorSelectors) {
655 var colorpicker = this;
656 $.each(this.options.colorSelectors, function(name, color) {
657 var $btn = $('<i />').css('background-color', color).data('class', name);
658 $btn.click(function() {
659 colorpicker.setValue($(this).css('background-color'));
661 colorpicker.picker.find('.colorpicker-selectors').append($btn);
663 this.picker.find('.colorpicker-selectors').show();
665 this.picker.on('mousedown.colorpicker touchstart.colorpicker', $.proxy(this.mousedown, this));
666 this.picker.appendTo(this.container ? this.container : $('body'));
669 if (this.input !== false) {
671 'keyup.colorpicker': $.proxy(this.keyup, this)
674 'change.colorpicker': $.proxy(this.change, this)
676 if (this.component === false) {
678 'focus.colorpicker': $.proxy(this.show, this)
681 if (this.options.inline === false) {
683 'focusout.colorpicker': $.proxy(this.hide, this)
688 if (this.component !== false) {
690 'click.colorpicker': $.proxy(this.show, this)
694 if ((this.input === false) && (this.component === false)) {
696 'click.colorpicker': $.proxy(this.show, this)
700 // for HTML5 input[type='color']
701 if ((this.input !== false) && (this.component !== false) && (this.input.attr('type') === 'color')) {
704 'click.colorpicker': $.proxy(this.show, this),
705 'focus.colorpicker': $.proxy(this.show, this)
710 $($.proxy(function() {
711 this.element.trigger('create');
715 Colorpicker.Color = Color;
717 Colorpicker.prototype = {
718 constructor: Colorpicker,
719 destroy: function() {
720 this.picker.remove();
721 this.element.removeData('colorpicker').off('.colorpicker');
722 if (this.input !== false) {
723 this.input.off('.colorpicker');
725 if (this.component !== false) {
726 this.component.off('.colorpicker');
728 this.element.removeClass('colorpicker-element');
729 this.element.trigger({
733 reposition: function() {
734 if (this.options.inline !== false || this.options.container) {
737 var type = this.container && this.container[0] !== document.body ? 'position' : 'offset';
738 var element = this.component || this.element;
739 var offset = element[type]();
740 if (this.options.align === 'right') {
741 offset.left -= this.picker.outerWidth() - element.outerWidth();
744 top: offset.top + element.outerHeight(),
749 if (this.isDisabled()) {
752 this.picker.addClass('colorpicker-visible').removeClass('colorpicker-hidden');
754 $(window).on('resize.colorpicker', $.proxy(this.reposition, this));
755 if (e && (!this.hasInput() || this.input.attr('type') === 'color')) {
756 if (e.stopPropagation && e.preventDefault) {
761 if (this.options.inline === false) {
762 $(window.document).on({
763 'mousedown.colorpicker': $.proxy(this.hide, this)
766 this.element.trigger({
772 this.picker.addClass('colorpicker-hidden').removeClass('colorpicker-visible');
773 $(window).off('resize.colorpicker', this.reposition);
775 'mousedown.colorpicker': this.hide
778 this.element.trigger({
783 updateData: function(val) {
784 val = val || this.color.toString(this.format);
785 this.element.data('color', val);
788 updateInput: function(val) {
789 val = val || this.color.toString(this.format);
790 if (this.input !== false) {
791 if (this.options.colorSelectors) {
792 var color = new Color(val, this.options.colorSelectors);
793 var alias = color.toAlias();
794 if (typeof this.options.colorSelectors[alias] !== 'undefined') {
798 this.input.prop('value', val);
802 updatePicker: function(val) {
803 if (val !== undefined) {
804 this.color = new Color(val, this.options.colorSelectors);
806 var sl = (this.options.horizontal === false) ? this.options.sliders : this.options.slidersHorz;
807 var icns = this.picker.find('i');
808 if (icns.length === 0) {
811 if (this.options.horizontal === false) {
812 sl = this.options.sliders;
813 icns.eq(1).css('top', sl.hue.maxTop * (1 - this.color.value.h)).end()
814 .eq(2).css('top', sl.alpha.maxTop * (1 - this.color.value.a));
816 sl = this.options.slidersHorz;
817 icns.eq(1).css('left', sl.hue.maxLeft * (1 - this.color.value.h)).end()
818 .eq(2).css('left', sl.alpha.maxLeft * (1 - this.color.value.a));
821 'top': sl.saturation.maxTop - this.color.value.b * sl.saturation.maxTop,
822 'left': this.color.value.s * sl.saturation.maxLeft
824 this.picker.find('.colorpicker-saturation').css('backgroundColor', this.color.toHex(this.color.value.h, 1, 1, 1));
825 this.picker.find('.colorpicker-alpha').css('backgroundColor', this.color.toHex());
826 this.picker.find('.colorpicker-color, .colorpicker-color div').css('backgroundColor', this.color.toString(this.format));
829 updateComponent: function(val) {
830 val = val || this.color.toString(this.format);
831 if (this.component !== false) {
832 var icn = this.component.find('i').eq(0);
833 if (icn.length > 0) {
835 'backgroundColor': val
839 'backgroundColor': val
845 update: function(force) {
847 if ((this.getValue(false) !== false) || (force === true)) {
848 // Update input/data only if the current value is not empty
849 val = this.updateComponent();
850 this.updateInput(val);
851 this.updateData(val);
852 this.updatePicker(); // only update picker if value is not empty
857 setValue: function(val) { // set color manually
858 this.color = new Color(val, this.options.colorSelectors);
860 this.element.trigger({
866 getValue: function(defaultValue) {
867 defaultValue = (defaultValue === undefined) ? '#000000' : defaultValue;
869 if (this.hasInput()) {
870 val = this.input.val();
872 val = this.element.data('color');
874 if ((val === undefined) || (val === '') || (val === null)) {
875 // if not defined or empty, return default
880 hasInput: function() {
881 return (this.input !== false);
883 isDisabled: function() {
884 if (this.hasInput()) {
885 return (this.input.prop('disabled') === true);
889 disable: function() {
890 if (this.hasInput()) {
891 this.input.prop('disabled', true);
892 this.element.trigger({
895 value: this.getValue()
902 if (this.hasInput()) {
903 this.input.prop('disabled', false);
904 this.element.trigger({
907 value: this.getValue()
918 mousedown: function(e) {
919 if (!e.pageX && !e.pageY && e.originalEvent) {
920 e.pageX = e.originalEvent.touches[0].pageX;
921 e.pageY = e.originalEvent.touches[0].pageY;
926 var target = $(e.target);
928 //detect the slider and set the limits and callbacks
929 var zone = target.closest('div');
930 var sl = this.options.horizontal ? this.options.slidersHorz : this.options.sliders;
931 if (!zone.is('.colorpicker')) {
932 if (zone.is('.colorpicker-saturation')) {
933 this.currentSlider = $.extend({}, sl.saturation);
934 } else if (zone.is('.colorpicker-hue')) {
935 this.currentSlider = $.extend({}, sl.hue);
936 } else if (zone.is('.colorpicker-alpha')) {
937 this.currentSlider = $.extend({}, sl.alpha);
941 var offset = zone.offset();
942 //reference to guide's style
943 this.currentSlider.guide = zone.find('i')[0].style;
944 this.currentSlider.left = e.pageX - offset.left;
945 this.currentSlider.top = e.pageY - offset.top;
946 this.mousePointer = {
950 //trigger mousemove to move the guide to the current position
952 'mousemove.colorpicker': $.proxy(this.mousemove, this),
953 'touchmove.colorpicker': $.proxy(this.mousemove, this),
954 'mouseup.colorpicker': $.proxy(this.mouseup, this),
955 'touchend.colorpicker': $.proxy(this.mouseup, this)
956 }).trigger('mousemove');
960 mousemove: function(e) {
961 if (!e.pageX && !e.pageY && e.originalEvent) {
962 e.pageX = e.originalEvent.touches[0].pageX;
963 e.pageY = e.originalEvent.touches[0].pageY;
970 this.currentSlider.maxLeft,
971 this.currentSlider.left + ((e.pageX || this.mousePointer.left) - this.mousePointer.left)
977 this.currentSlider.maxTop,
978 this.currentSlider.top + ((e.pageY || this.mousePointer.top) - this.mousePointer.top)
981 this.currentSlider.guide.left = left + 'px';
982 this.currentSlider.guide.top = top + 'px';
983 if (this.currentSlider.callLeft) {
984 this.color[this.currentSlider.callLeft].call(this.color, left / this.currentSlider.maxLeft);
986 if (this.currentSlider.callTop) {
987 this.color[this.currentSlider.callTop].call(this.color, top / this.currentSlider.maxTop);
989 // Change format dynamically
990 // Only occurs if user choose the dynamic format by
991 // setting option format to false
992 if (this.currentSlider.callTop === 'setAlpha' && this.options.format === false) {
994 // Converting from hex / rgb to rgba
995 if (this.color.value.a !== 1) {
996 this.format = 'rgba';
997 this.color.origFormat = 'rgba';
1000 // Converting from rgba to hex
1002 this.format = 'hex';
1003 this.color.origFormat = 'hex';
1008 this.element.trigger({
1009 type: 'changeColor',
1014 mouseup: function(e) {
1015 e.stopPropagation();
1018 'mousemove.colorpicker': this.mousemove,
1019 'touchmove.colorpicker': this.mousemove,
1020 'mouseup.colorpicker': this.mouseup,
1021 'touchend.colorpicker': this.mouseup
1025 change: function(e) {
1028 keyup: function(e) {
1029 if ((e.keyCode === 38)) {
1030 if (this.color.value.a < 1) {
1031 this.color.value.a = Math.round((this.color.value.a + 0.01) * 100) / 100;
1034 } else if ((e.keyCode === 40)) {
1035 if (this.color.value.a > 0) {
1036 this.color.value.a = Math.round((this.color.value.a - 0.01) * 100) / 100;
1040 this.color = new Color(this.input.val(), this.options.colorSelectors);
1041 // Change format dynamically
1042 // Only occurs if user choose the dynamic format by
1043 // setting option format to false
1044 if (this.color.origFormat && this.options.format === false) {
1045 this.format = this.color.origFormat;
1047 if (this.getValue(false) !== false) {
1049 this.updateComponent();
1050 this.updatePicker();
1053 this.element.trigger({
1054 type: 'changeColor',
1056 value: this.input.val()
1061 $.colorpicker = Colorpicker;
1063 $.fn.colorpicker = function(option) {
1064 var pickerArgs = arguments,
1067 var $returnValue = this.each(function() {
1068 var $this = $(this),
1069 inst = $this.data('colorpicker'),
1070 options = ((typeof option === 'object') ? option : {});
1071 if ((!inst) && (typeof option !== 'string')) {
1072 $this.data('colorpicker', new Colorpicker(this, options));
1074 if (typeof option === 'string') {
1075 rv = inst[option].apply(inst, Array.prototype.slice.call(pickerArgs, 1));
1079 if (option === 'getValue') {
1082 return $returnValue;
1085 $.fn.colorpicker.constructor = Colorpicker;