From a89ba6e57d547bd4ae5d97c31fcca9a9cbf29678 Mon Sep 17 00:00:00 2001 From: Richard Parnaby-King Date: Tue, 13 Jun 2017 11:43:06 +0100 Subject: [PATCH] Create spectrum.js If there is a label for the element, when the label is clicked on, show the colour picker for this element. --- spectrum.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spectrum.js b/spectrum.js index e129e184..53b91273 100644 --- a/spectrum.js +++ b/spectrum.js @@ -239,6 +239,19 @@ isEmpty = !initialColor, allowEmpty = opts.allowEmpty && !isInputTypeColor; + //If there is a label for this element, when clicked on, show the colour picker + var thisId = boundElement.attr('id'); + if(thisId !== undefined && thisId.length > 0) { + var label = $('label[for="'+thisId+'"]'); + if(label.length) { + label.on('click', function(e){ + e.preventDefault(); + boundElement.spectrum('show'); + return false; + }); + } + } + function applyOptions() { if (opts.showPaletteOnly) {