Mercurial > hg > isophonics-drupal-site
annotate core/modules/comment/js/comment-by-viewer.es6.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
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@17 | 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@17 | 16 .filter(function() { |
Chris@17 | 17 return ( |
Chris@17 | 18 parseInt(this.getAttribute('data-comment-user-id'), 10) === |
Chris@17 | 19 currentUserID |
Chris@17 | 20 ); |
Chris@0 | 21 }) |
Chris@0 | 22 .addClass('by-viewer'); |
Chris@0 | 23 }, |
Chris@0 | 24 }; |
Chris@17 | 25 })(jQuery, Drupal, drupalSettings); |