Drupal investigation

node.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @file
  3. * Defines Javascript behaviors for the node module.
  4. */
  5. (function ($, Drupal, drupalSettings) {
  6. 'use strict';
  7. /**
  8. * Behaviors for tabs in the node edit form.
  9. *
  10. * @type {Drupal~behavior}
  11. *
  12. * @prop {Drupal~behaviorAttach} attach
  13. * Attaches summary behavior for tabs in the node edit form.
  14. */
  15. Drupal.behaviors.nodeDetailsSummaries = {
  16. attach: function (context) {
  17. var $context = $(context);
  18. $context.find('.node-form-author').drupalSetSummary(function (context) {
  19. var $authorContext = $(context);
  20. var name = $authorContext.find('.field--name-uid input').val();
  21. var date = $authorContext.find('.field--name-created input').val();
  22. if (name && date) {
  23. return Drupal.t('By @name on @date', {'@name': name, '@date': date});
  24. }
  25. else if (name) {
  26. return Drupal.t('By @name', {'@name': name});
  27. }
  28. else if (date) {
  29. return Drupal.t('Authored on @date', {'@date': date});
  30. }
  31. });
  32. $context.find('.node-form-options').drupalSetSummary(function (context) {
  33. var $optionsContext = $(context);
  34. var vals = [];
  35. if ($optionsContext.find('input').is(':checked')) {
  36. $optionsContext.find('input:checked').next('label').each(function () {
  37. vals.push(Drupal.checkPlain($.trim($(this).text())));
  38. });
  39. return vals.join(', ');
  40. }
  41. else {
  42. return Drupal.t('Not promoted');
  43. }
  44. });
  45. }
  46. };
  47. })(jQuery, Drupal, drupalSettings);