tabs.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function ($) {
  2. 'use strict';
  3. Drupal.FieldGroup = Drupal.FieldGroup || {};
  4. Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {};
  5. /**
  6. * Implements Drupal.FieldGroup.processHook().
  7. */
  8. Drupal.FieldGroup.Effects.processTabs = {
  9. execute: function (context, settings, group_info) {
  10. if (group_info.context === 'form') {
  11. // Add required fields mark to any element containing required fields
  12. var direction = group_info.settings.direction;
  13. $(context).find('[data-' + direction + '-tabs-panes] details').once('fieldgroup-effects').each(function () {
  14. var $this = $(this);
  15. if (typeof $(this).data(direction + 'Tab') !== 'undefined') {
  16. if ($this.is('.required-fields') && ($this.find('[required]').length > 0 || $this.find('.form-required').length > 0)) {
  17. $this.data(direction + 'Tab').link.find('strong:first').addClass('form-required');
  18. }
  19. if ($('.error', $this).length) {
  20. $this.data(direction + 'Tab').link.parent().addClass('error');
  21. Drupal.FieldGroup.setGroupWithfocus($this);
  22. $this.data(direction + 'Tab').focus();
  23. }
  24. }
  25. });
  26. }
  27. }
  28. };
  29. })(jQuery, Modernizr);