Mercurial > hg > isophonics-drupal-site
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * @file |
Chris@0 | 3 * Attaches behaviors for the Comment module's "by-viewer" class. |
Chris@0 | 4 */ |
Chris@0 | 5 |
Chris@0 | 6 (function ($, Drupal, drupalSettings) { |
Chris@0 | 7 /** |
Chris@0 | 8 * Add 'by-viewer' class to comments written by the current user. |
Chris@0 | 9 * |
Chris@0 | 10 * @type {Drupal~behavior} |
Chris@0 | 11 */ |
Chris@0 | 12 Drupal.behaviors.commentByViewer = { |
Chris@0 | 13 attach(context) { |
Chris@0 | 14 const currentUserID = parseInt(drupalSettings.user.uid, 10); |
Chris@0 | 15 $('[data-comment-user-id]') |
Chris@0 | 16 .filter(function () { |
Chris@0 | 17 return parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID; |
Chris@0 | 18 }) |
Chris@0 | 19 .addClass('by-viewer'); |
Chris@0 | 20 }, |
Chris@0 | 21 }; |
Chris@0 | 22 }(jQuery, Drupal, drupalSettings)); |