comparison core/modules/comment/js/comment-by-viewer.es6.js @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID;
18 })
19 .addClass('by-viewer');
20 },
21 };
22 }(jQuery, Drupal, drupalSettings));