Hi Guys,
I am writing a plugin for creating child themes, and I have no jQuery knowledge to speak of, and I want to use the same color picker as WordPress uses.
I have had a dig in the admin files for an example, I found the background-color example, this has a script just for the one textbox, as does the header text, but I cannot find an example with multi textboxes.
I have copied the background color js and added it to pastebin:
http://digitalraindrops.pastebin.com/p4TXqL75
I can add a class (.color) to all color boxes, but I do not know how to code the following scenario.
Make the script above dynamic, so whichever textbox has the focus can set and return from the color picker.
I found this code for a .focus script which I am trying to adapt and merge with the above code.
$(document).ready(function() {
var f = jQuery.farbtastic('#pickcolor');
var selected;
jQuery('.color')
.each(function () { f.linkTo(this); })
.focus(function() {
if (selected) {
jQuery(selected).removeClass('color-selected');
}
f.linkTo(this);
jQuery(selected = this).addClass('color-selected');
});
});
</script>
I will add a class of .color to the text boxes, and the id will be used to store the result.
If I can get some code working then I will post a good working theme options solution for all to use!
Thanks in advance!
David