node.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function ($) {
  2. Drupal.behaviors.nodeFieldsetSummaries = {
  3. attach: function (context) {
  4. $('fieldset.node-form-revision-information', context).drupalSetSummary(function (context) {
  5. var revisionCheckbox = $('.form-item-revision input', context);
  6. // Return 'New revision' if the 'Create new revision' checkbox is checked,
  7. // or if the checkbox doesn't exist, but the revision log does. For users
  8. // without the "Administer content" permission the checkbox won't appear,
  9. // but the revision log will if the content type is set to auto-revision.
  10. if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $('.form-item-log textarea', context).length)) {
  11. return Drupal.t('New revision');
  12. }
  13. return Drupal.t('No revision');
  14. });
  15. $('fieldset.node-form-author', context).drupalSetSummary(function (context) {
  16. var name = $('.form-item-name input', context).val() || Drupal.settings.anonymous,
  17. date = $('.form-item-date input', context).val();
  18. return date ?
  19. Drupal.t('By @name on @date', { '@name': name, '@date': date }) :
  20. Drupal.t('By @name', { '@name': name });
  21. });
  22. $('fieldset.node-form-options', context).drupalSetSummary(function (context) {
  23. var vals = [];
  24. $('input:checked', context).parent().each(function () {
  25. vals.push(Drupal.checkPlain($.trim($(this).text())));
  26. });
  27. if (!$('.form-item-status input', context).is(':checked')) {
  28. vals.unshift(Drupal.t('Not published'));
  29. }
  30. return vals.join(', ');
  31. });
  32. }
  33. };
  34. })(jQuery);