From 4cf6ebda7bffc1a546b013205c26076ebde7d61b Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 14 May 2014 18:50:50 -0400 Subject: [PATCH] updated enableColorPicker to accept either a jQ obj or a string; updated it to be able to initialize several inputs at once --- public/src/admin.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/public/src/admin.js b/public/src/admin.js index 3d6b8c40f0..65a7504208 100644 --- a/public/src/admin.js +++ b/public/src/admin.js @@ -5,15 +5,19 @@ var admin = {}; (function() { admin.enableColorPicker = function(inputEl, callback) { - inputEl.ColorPicker({ - color: inputEl.val() || '#000', - onChange: function(hsb, hex) { - inputEl.val('#' + hex); - if (typeof callback === 'function') { - callback(hsb, hex); + (inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function() { + var $this = $(this); + + $this.ColorPicker({ + color: $this.val() || '#000', + onChange: function(hsb, hex) { + $this.val('#' + hex); + if (typeof callback === 'function') { + callback(hsb, hex); + } } - } - }); + }); + }); }; }()); \ No newline at end of file