color_field_widget_grid.jquery.js 907 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @file
  3. * Javascript for Color Field.
  4. */
  5. (function ($, Drupal) {
  6. 'use strict';
  7. /**
  8. * Enables grid widget on color elements.
  9. *
  10. * @type {Drupal~behavior}
  11. *
  12. * @prop {Drupal~behaviorAttach} attach
  13. * Attaches a grid widget to a color input element.
  14. */
  15. Drupal.behaviors.color_field_jquery_simple_color = {
  16. attach: function (context, settings) {
  17. var $context = $(context);
  18. var settings = settings.color_field.color_field_widget_grid;
  19. $context.find('.js-color-field-widget-grid__color').each(function (index, element) {
  20. var $element = $(element);
  21. $element.simpleColor({
  22. cellWidth: settings.cell_width,
  23. cellHeight: settings.cell_height,
  24. cellMargin: settings.cell_margin,
  25. boxWidth: settings.box_width,
  26. boxHeight: settings.box_height
  27. });
  28. });
  29. }
  30. };
  31. })(jQuery, Drupal);