WordPress.org

Ready to get started?Download WordPress

Forums

Any good theme option samples multi farbtastic (2 posts)

  1. Digital Raindrops
    Member
    Posted 3 years ago #

    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

  2. snowboardmommy
    Member
    Posted 2 years ago #

    Hi David,

    Did you ever have any luck with this? I have been searching too but unable to find any solid, working examples of using more than one instance of farbtastic, other than to have a million individual instances for every field where I want to choose a color ... not ideal

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic