FlexiColorPicker icon indicating copy to clipboard operation
FlexiColorPicker copied to clipboard

Allow more that one picker per document

Open grubshka opened this issue 12 years ago • 1 comments

Only the first picker of the document is working, probably because of the "id" used for the gradient. You could handle this by adding a counter in the ColorPicker object, and changing the id and the fill value after the cloneNode.

grubshka avatar Jun 26 '12 21:06 grubshka

Simple patch :)

192a193,194
>     var pickerCounter = 0;
> 
201a204
>         ++pickerCounter;
210,211c213,223
<             slideElement.appendChild(slide.cloneNode(true));
<             pickerElement.appendChild(picker.cloneNode(true));
---
>             var clonedSlide = slide.cloneNode(true);
>             clonedSlide.firstChild.firstChild.setAttribute("id", "gradient-hsv-" + pickerCounter);
>             clonedSlide.lastChild.setAttribute("fill", "url(#gradient-hsv-" + pickerCounter + ")");
>             slideElement.appendChild(clonedSlide);
> 
>             var clonedPicker = picker.cloneNode(true);
>             clonedPicker.firstChild.firstChild.setAttribute("id", "gradient-black-" + pickerCounter);
>             clonedPicker.firstChild.lastChild.setAttribute("id", "gradient-white-" + pickerCounter);
>             clonedPicker.childNodes[1].setAttribute("fill", "url(#gradient-white-" + pickerCounter + ")");
>             clonedPicker.childNodes[2].setAttribute("fill", "url(#gradient-black-" + pickerCounter + ")");
>             pickerElement.appendChild(clonedPicker);

grubshka avatar Jun 26 '12 21:06 grubshka