tinyColorPicker icon indicating copy to clipboard operation
tinyColorPicker copied to clipboard

Close color picker

Open ob7 opened this issue 9 years ago • 8 comments

I would like to close the color picker from an outside event somehow.

ob7 avatar Oct 19 '16 23:10 ob7

Nevermind, just found $(select).colorPicker.destroy();

ob7 avatar Oct 19 '16 23:10 ob7

Actually this does more than I need.... any way to just trigger a close instead of destroying the entire thing?

ob7 avatar Oct 19 '16 23:10 ob7

Heres the issue I'm having.

When using a button to clear the styles present, even when targeting a specific selector, its the last color picker that was open that gets targeted...

If no color has been toggled since the document loaded, and the button tries to fire a change event to the color picker to clear the value, it breaks altogether with an error: Uncaught TypeError: Cannot read property '_colorMode' of undefined

Which can be fixed by calling a click on the element. But its all really hacky. Need to just clear the value on any element based on selector whether its been clicked on or not.

So unlike all the other folks who switched to a different color picker first issue they had, I've got to get this figured out because this color picker is the most intelligent one I've ever seen before.

Whats .tcp for/do in the javascript??? Whats tcp abbreviate? Trigger Color Picker??

ob7 avatar Oct 20 '16 00:10 ob7

Hi @ob7 , sorry for the late answer, but I'm on the road a lot and at work it's not possible for me to contribute to private things ;o) To answer the last question, what is tcp: Look at https://api.jquery.com/event.namespace/ It's only a name space for jQuery events to be able to control them better (it means TinyColorPicker -> tcp) I will answer the rest of the questions as soon as possible...

PitPik avatar Oct 24 '16 13:10 PitPik

Hey PitPik, no worries. The good news is I've completed extending the picker to support gradients! And it works quite well. The picker works as a solid color picker at first, but when the user selects a gradient marker or adds a gradient marker, the color picker switches to being a gradient maker. Hopefully I'll have a live demo soon. It'll be the first color picker (that I personally know of) that integrates gradients right into it, supporting both solid color or gradient building. I don't think I would have been able to do this with any other color picker, so great job on what you built!

Adding gradient support was about 700 lines of code though! Including the renderCallBack, which is where most of the magic happens. Includes ability to set gradient direction as well.

Heres a screenshot: Color Picker With Gradient

ob7 avatar Oct 25 '16 07:10 ob7

What about

$(select).colorPicker.toggle()

vanowm avatar May 08 '17 18:05 vanowm

when I add this style:

html, body { height: 100%; }

the colorPicker could be close when clicking on some place around.

1Cr18Ni9 avatar Mar 23 '18 08:03 1Cr18Ni9

Try:

$('elm').colorPicker('close');

justingolden21 avatar Feb 01 '19 05:02 justingolden21