From 38b730d21ca8e3a9cf2ec88193ddaf986178827e Mon Sep 17 00:00:00 2001 From: Daniel VanMullen Date: Tue, 31 Mar 2015 13:30:09 -0400 Subject: [PATCH] Adding support for numeric Hex values When a numeric hex value is given to this method (example: #222222) it skips the hex processing block and goes to return this, which achieves the wrong result. This adds support for detecting numeric hex's and processing properly. --- js/colpick.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/colpick.js b/js/colpick.js index d77432a..1f6750c 100644 --- a/js/colpick.js +++ b/js/colpick.js @@ -407,7 +407,13 @@ For usage and examples: colpick.com/plugin //Sets a color as new and current (default) setColor: function(col, setCurrent) { setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent; - if (typeof col == 'string') { + if ((typeof col == 'string') || (typeof col == 'number')) { + if (typeof col == 'number') { + col = col.toString(); + if (col.length == 3) { + col = col+col; + } + } col = hexToHsb(col); } else if (col.r != undefined && col.g != undefined && col.b != undefined) { col = rgbToHsb(col);