color_field_widget_grid.jquery.js 965 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. $context.find('.js-color-field-widget-grid__color').each(function (index, element) {
  19. var $element = $(element);
  20. var widgetSettings = settings.color_field.color_field_widget_grid[$(this).attr('id')];
  21. $element.simpleColor({
  22. cellWidth: widgetSettings.cell_width,
  23. cellHeight: widgetSettings.cell_height,
  24. cellMargin: widgetSettings.cell_margin,
  25. boxWidth: widgetSettings.box_width,
  26. boxHeight: widgetSettings.box_height
  27. });
  28. });
  29. }
  30. };
  31. })(jQuery, Drupal);