X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcomment%2Fjs%2Fcomment-by-viewer.es6.js;fp=web%2Fcore%2Fmodules%2Fcomment%2Fjs%2Fcomment-by-viewer.es6.js;h=db561539a94941f3e6d788a5284d7cb3c3fa2dcd;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/comment/js/comment-by-viewer.es6.js b/web/core/modules/comment/js/comment-by-viewer.es6.js new file mode 100644 index 000000000..db561539a --- /dev/null +++ b/web/core/modules/comment/js/comment-by-viewer.es6.js @@ -0,0 +1,22 @@ +/** + * @file + * Attaches behaviors for the Comment module's "by-viewer" class. + */ + +(function ($, Drupal, drupalSettings) { + /** + * Add 'by-viewer' class to comments written by the current user. + * + * @type {Drupal~behavior} + */ + Drupal.behaviors.commentByViewer = { + attach(context) { + const currentUserID = parseInt(drupalSettings.user.uid, 10); + $('[data-comment-user-id]') + .filter(function () { + return parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID; + }) + .addClass('by-viewer'); + }, + }; +}(jQuery, Drupal, drupalSettings));