Q.PALETTE Question

4 views
Skip to first unread message

Rog

unread,
Aug 5, 2010, 6:03:18 AM8/5/10
to Qutensil
Is it possible to use anything other than an input element.

What I would like to do is have a square DIV and click on that to
bring up the palette. Then once the user clicks a colour, set the
back ground colour of the DIV to whatever they picked ?

At all possible ?

Thanks.

wonderingwout

unread,
Aug 5, 2010, 6:23:11 AM8/5/10
to Qutensil
Hi Rog,

What you're asking is perfectly possible.
This is how I would do it:

- Inside the div you want to be click you put an input element with
zero padding and margin, 100% width and height and opacity:0.
All Q modules need to be attached to an input and in this way the
input is present but not at all visible.

- Than you add an onPick or onChange callback which is setting the
background-color of the div:

document.observe('q:loaded', function() {
new Q.Palette("id_of_the_input", {
colors: ['#31332E','#585C53','#868C7F','#E0E3DC'],
onPick: function(hex) {
$("id_of_the_div").setStyle({ backgroundColor: hex });
}
});
});

Geetings,
Wout

Rog

unread,
Aug 6, 2010, 9:36:11 AM8/6/10
to Qutensil
Hi Wout,

That worked perfectly thanks :)

I just want to say this piece of kit you have made is brilliant.

I was so glad to find it after having spent what seemed like days
looking for a modern colour picker.

Your other tools look very useful and attractive too, I am sure I can
make good use of this.

Going off topic a little, I noticed your plans are to move to
scripty2. Will the 'old' prototype version still be available or
should I download all the docs while I have the chance ?

I am just put off a little by scripty2 as I tried some of the demos in
Chrome and they don't work - early days I know, but I am hoping to get
my project up and running soon.

I will get some funds into my PayPal account and send you a
donation :)

Many thanks,

Rog.

wonderingwout

unread,
Aug 6, 2010, 10:54:25 AM8/6/10
to Qutensil
Thanks, I'm glad you appreciate it!

What you are describing was exactly the reason why I started building
Q.
It's hard to find libraries that are still in development.

Don't be afraid of scripty2 support.
Both scriptaculous and scripty will work with Q.

Greets.
Wout

Rog

unread,
Aug 6, 2010, 11:07:17 AM8/6/10
to Qutensil
Yes, much appreciated :)

Got one little thing to fix on my coloured DIV thingy.

In Chrome and FF, it works as I wish - I get a coloured square.

In IE8 I am getting the coloured square, but it contains the hex
colour :

http://i799.photobucket.com/albums/yy275/Rogad/misc/minorproblem.jpg

Not sure why that is, I really dislike IE, but have you an idea of how
to make the hex value not show up like that ?

Many Thanks :)

Boys Abroad

unread,
Aug 6, 2010, 11:25:02 AM8/6/10
to qute...@googlegroups.com
That's probably because IE doesn't understand opacity in css. You
shoud set it with filter:alpha... Protoype' setOpacity funtion will do
that for you.

Gr.
Wout

http://cktail.com
http://wout.cktail.com

Sent from my iPhone

Rog

unread,
Aug 6, 2010, 11:33:44 AM8/6/10
to Qutensil
Spot on !

Yes that was the problem - setOpacity fixed it.

Thanks :)

On Aug 6, 4:25 pm, Boys Abroad <w...@boysabroad.com> wrote:
> That's probably because IE doesn't understand opacity in css. You  
> shoud set it with filter:alpha... Protoype' setOpacity funtion will do  
> that for you.
>
> Gr.
> Wout
>
> http://cktail.comhttp://wout.cktail.com
>
> Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages