field_ui.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function ($) {
  2. // Override core JS so it works with "button" tags.
  3. if (Drupal.fieldUIOverview && Drupal.fieldUIOverview.AJAXRefreshRows) {
  4. /**
  5. * Triggers Ajax refresh of selected rows.
  6. *
  7. * The 'format type' selects can trigger a series of changes in child rows.
  8. * The #ajax behavior is therefore not attached directly to the selects, but
  9. * triggered manually through a hidden #ajax 'Refresh' button.
  10. *
  11. * @param rows
  12. * A hash object, whose keys are the names of the rows to refresh (they
  13. * will receive the 'ajax-new-content' effect on the server side), and
  14. * whose values are the DOM element in the row that should get an Ajax
  15. * throbber.
  16. */
  17. Drupal.fieldUIOverview.AJAXRefreshRows = function (rows) {
  18. // Separate keys and values.
  19. var rowNames = [];
  20. var ajaxElements = [];
  21. $.each(rows, function (rowName, ajaxElement) {
  22. rowNames.push(rowName);
  23. ajaxElements.push(ajaxElement);
  24. });
  25. if (rowNames.length) {
  26. // Add a throbber next each of the ajaxElements.
  27. var $throbber = $('<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>');
  28. $(ajaxElements)
  29. .addClass('progress-disabled')
  30. .after($throbber);
  31. // Fire the Ajax update.
  32. $(':input[name=refresh_rows]').val(rowNames.join(' '));
  33. $(':input#edit-refresh').mousedown();
  34. // Disabled elements do not appear in POST ajax data, so we mark the
  35. // elements disabled only after firing the request.
  36. $(ajaxElements).attr('disabled', true);
  37. }
  38. };
  39. }
  40. })(jQuery);