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

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
1 /** 1 /**
2 * @file 2 * @file
3 * Attaches behaviors for the Comment module's "by-viewer" class. 3 * Attaches behaviors for the Comment module's "by-viewer" class.
4 */ 4 */
5 5
6 (function ($, Drupal, drupalSettings) { 6 (function($, Drupal, drupalSettings) {
7 /** 7 /**
8 * Add 'by-viewer' class to comments written by the current user. 8 * Add 'by-viewer' class to comments written by the current user.
9 * 9 *
10 * @type {Drupal~behavior} 10 * @type {Drupal~behavior}
11 */ 11 */
12 Drupal.behaviors.commentByViewer = { 12 Drupal.behaviors.commentByViewer = {
13 attach(context) { 13 attach(context) {
14 const currentUserID = parseInt(drupalSettings.user.uid, 10); 14 const currentUserID = parseInt(drupalSettings.user.uid, 10);
15 $('[data-comment-user-id]') 15 $('[data-comment-user-id]')
16 .filter(function () { 16 .filter(function() {
17 return parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID; 17 return (
18 parseInt(this.getAttribute('data-comment-user-id'), 10) ===
19 currentUserID
20 );
18 }) 21 })
19 .addClass('by-viewer'); 22 .addClass('by-viewer');
20 }, 23 },
21 }; 24 };
22 }(jQuery, Drupal, drupalSettings)); 25 })(jQuery, Drupal, drupalSettings);