Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / comment / js / comment-by-viewer.es6.js
1 /**
2  * @file
3  * Attaches behaviors for the Comment module's "by-viewer" class.
4  */
5
6 (function($, Drupal, drupalSettings) {
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(context) {
14       const currentUserID = parseInt(drupalSettings.user.uid, 10);
15       $('[data-comment-user-id]')
16         .filter(function() {
17           return (
18             parseInt(this.getAttribute('data-comment-user-id'), 10) ===
19             currentUserID
20           );
21         })
22         .addClass('by-viewer');
23     },
24   };
25 })(jQuery, Drupal, drupalSettings);