From 61c90ad7a4bb9828f189b8f3ff4870c597a1c907 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 16 Dec 2010 10:20:11 -0700 Subject: [PATCH] Make colorpicker work with abbreviated hex values --- horde/js/colorpicker.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/horde/js/colorpicker.js b/horde/js/colorpicker.js index b933e0d12..a393080b5 100644 --- a/horde/js/colorpicker.js +++ b/horde/js/colorpicker.js @@ -15,8 +15,12 @@ var ColorPicker = Class.create({ initialize: function(options) { + if (options.color) { + options.color = Color.normalizehex(options.color); + } + this.options = Object.extend({ - color: 'ffffff', + color: '#ffffff', update: [], draggable: false, resizable: false, @@ -296,6 +300,21 @@ var ColorPicker = Class.create({ */ var Color = { + normalizehex: function(h) + { + if (h.substring(0, 1) == '#') { + h = h.substring(1); + } + + if (h.length == 3) { + h = h.charAt(0).times(2) + + h.charAt(1).times(2) + + h.charAt(2).times(2); + } + + return '#' + h; + }, + hsv2hex: function(h) { return Color.rgb2hex(Color.hsv2rgb(h)); -- 2.11.0