field_example.js 700 B

12345678910111213141516171819202122232425
  1. /**
  2. * @file
  3. * Javascript for Field Example.
  4. */
  5. /**
  6. * Provides a farbtastic colorpicker for the fancier widget.
  7. */
  8. (function ($) {
  9. Drupal.behaviors.field_example_colorpicker = {
  10. attach: function(context) {
  11. $(".edit-field-example-colorpicker").live("focus", function(event) {
  12. var edit_field = this;
  13. var picker = $(this).closest('div').parent().find(".field-example-colorpicker");
  14. // Hide all color pickers except this one.
  15. $(".field-example-colorpicker").hide();
  16. $(picker).show();
  17. $.farbtastic(picker, function(color) {
  18. edit_field.value = color;
  19. }).setColor(edit_field.value);
  20. });
  21. }
  22. }
  23. })(jQuery);