Uhhhh no... I'm not going to just tell you what to do, I've given you a perfectly good link already which tells you everything you need to know. Just follow it and look at it... I bet you never did your homework at school either did you?...
// $Id$
// Global killswitch: only run if we are in a supported browser.
if (Drupal.jsEnabled) {
$(document).ready(function () {
// initiate farbtastic colorpicker
var farb = $.farbtastic("div.colorpicker");
$("input.color_textfield").each(function () {
// set the background colors of all of the textfields appropriately
$("table#tablemanager-example-table " + this.name).css("background-color", farb.color);
farb.linkTo(this);
// update the farbtastic colorpicker and example table when this textfield is clicked
$(this).click(function () {
$("table#tablemanager-example-table " + this.name).css("background-color", farb.color);
farb.linkTo(this);
});
});
});
}
Using code stolen completely from both the color module and the colorpicker module with absolutely no thought on my part. It's not finished as I'm doing other theme stuff with it, but it's a good starting point. If it doesn't work it's because I've removed parts of it I've added myself to simplify what you're looking at (and so I may have broken it, don't think so though?)
It's better to use .focus() in tablemanager.js in the above example as this will capture tabbing into the textfield as well as clicking onto the textfields. You can find an implementation of using multiple textfields with farbtastic based on the above technique in the theme settings of the MO6 theme.
Comments
This'll help;
This'll help; http://drupal.org/project/colorpicker
Pobster
Drupal 6
How is it possible to use the _core_ modul "color" with the color picker for moduls in Drupal 6?
Do you want me to post the
Do you want me to post the same thing again?...
Two seconds of browsing over the code and I wrote this;
Okay so it's not the best way to call it, but it works fine.
Pobster
Thanks!
And for more than one element?
Uhhhh no... I'm not going
Uhhhh no... I'm not going to just tell you what to do, I've given you a perfectly good link already which tells you everything you need to know. Just follow it and look at it... I bet you never did your homework at school either did you?...
Pobster
Hmmm okay so I've just seen
Hmmm okay so I've just seen that you've actually contributed modules so you're not quite the slacker I assumed you are ;o)
Take a look at this which I've written for my own Tablemanager module;
tablemanager.css.inc
tablemanager.js
Using code stolen completely from both the color module and the colorpicker module with absolutely no thought on my part. It's not finished as I'm doing other theme stuff with it, but it's a good starting point. If it doesn't work it's because I've removed parts of it I've added myself to simplify what you're looking at (and so I may have broken it, don't think so though?)
Pobster
Use .focus() instead of .click()
It's better to use .focus() in tablemanager.js in the above example as this will capture tabbing into the textfield as well as clicking onto the textfields. You can find an implementation of using multiple textfields with farbtastic based on the above technique in the theme settings of the MO6 theme.