What about a colorpicker element? currently there's a module for that but apparently it won't be ported anytime soon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

minorOffense’s picture

Here's an attempt to get the color picker element into the module. To test, you'll have to use Opera 11.

Also, this patch was made to the Drupal 7.x code. If it's good, I can port to 6.x

minorOffense’s picture

lelizondo’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

I get Hunk #2 failed when applying with patch command

If I use git apply I also get two errors.

lelizondo’s picture

FileSize
1.79 KB

I've remade the patch since the previous one didn't apply. Here is the same exact patch.

Anyway, I tested the patch with Opera 11 like you said but it didn't work, here is the important part in case I'm using it wrong.

<?php
// ...
  $form['links']['links_color'] = array(
    '#type' => "colorfield",
    '#title' => t('Links color'),
    '#value' => '#ccc',
    //'#default_value' => theme_get_setting('links_color'),
    '#description' => t("Select the link color"),
  );
// ...
lelizondo’s picture

FileSize
2.04 KB

Ok, so here is a working patch.

First, you have to download the JsColor zip from http://jscolor.com/download.php
Extract it to the module directory and rename it to jscolor

Apply the patch. Now you can select a color from a color picker.

The only reason because I choose jscolor over other color pickers is that was the easiest one to implement, all it needed was the color class to be added to the input

I tested this with Firefox 3.6.x and it worked.

lelizondo’s picture

Status: Active » Needs review
lelizondo’s picture

Status: Needs review » Active

It seems like we can use Farbtastic that already comes with core and avoid having to download a new library.

Here is a nice patch that uses the Farbtastic color picker if anyone wants to jump in and take it as an example. http://drupal.org/files/issues/env_ind_farbtastic_picker_60422_0.patch

I'll work tonight with this.

minorOffense’s picture

Sorry, I was reading the color input element docs on some HTML5 sites and they said it was only properly implemented in Opera 11.

I didn't include any javascript libraries because I understood the w3c docs on the input type color as not requiring any. I was assuming the browser would just handle all that.

As for the bad patch, that's my bad. I'm still getting used to this whole git thing. I may have started working from the wrong branch (I think it was a branch for fixing the horizontal tabs, the git instructions for the project link to it for some reason).

I'll keep reading and help out as best I can. Well done with the patch though!

Pere Orga’s picture

Adding related issue.