Drupal investigation

comment-by-viewer.js 640B

123456789101112131415161718192021222324252627
  1. /**
  2. * @file
  3. * Attaches behaviors for the Comment module's "by-viewer" class.
  4. */
  5. (function ($, Drupal, drupalSettings) {
  6. 'use strict';
  7. /**
  8. * Add 'by-viewer' class to comments written by the current user.
  9. *
  10. * @type {Drupal~behavior}
  11. */
  12. Drupal.behaviors.commentByViewer = {
  13. attach: function (context) {
  14. var currentUserID = parseInt(drupalSettings.user.uid, 10);
  15. $('[data-comment-user-id]')
  16. .filter(function () {
  17. return parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID;
  18. })
  19. .addClass('by-viewer');
  20. }
  21. };
  22. })(jQuery, Drupal, drupalSettings);