diff options
author | Alex Pott <alex.a.pott@googlemail.com> | 2021-12-18 06:12:16 +0000 |
---|---|---|
committer | Alex Pott <alex.a.pott@googlemail.com> | 2021-12-18 06:12:16 +0000 |
commit | f1e57201c28dbc62dd07239c7d803b6d760ed44a (patch) | |
tree | 2c0359ed31b0a78632c2ac8d8407ff8e8b8df419 /core/modules/comment/js | |
parent | 00ad1d7572f27c272b5b7fc70941016989b0cfa1 (diff) | |
download | drupal-f1e57201c28dbc62dd07239c7d803b6d760ed44a.tar.gz drupal-f1e57201c28dbc62dd07239c7d803b6d760ed44a.zip |
Issue #3253148 by mherchel, longwave, ckrina, droplet: Remove IE from core's browserlist, remove non-essential CSS importing and recompile assets
Diffstat (limited to 'core/modules/comment/js')
-rw-r--r-- | core/modules/comment/js/comment-by-viewer.js | 5 | ||||
-rw-r--r-- | core/modules/comment/js/comment-new-indicator.js | 33 | ||||
-rw-r--r-- | core/modules/comment/js/node-new-comments-link.js | 33 |
3 files changed, 37 insertions, 34 deletions
diff --git a/core/modules/comment/js/comment-by-viewer.js b/core/modules/comment/js/comment-by-viewer.js index c255a10fc00b..3f47ceeaab27 100644 --- a/core/modules/comment/js/comment-by-viewer.js +++ b/core/modules/comment/js/comment-by-viewer.js @@ -7,11 +7,12 @@ (function ($, Drupal, drupalSettings) { Drupal.behaviors.commentByViewer = { - attach: function attach(context) { - var currentUserID = parseInt(drupalSettings.user.uid, 10); + 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);
\ No newline at end of file diff --git a/core/modules/comment/js/comment-new-indicator.js b/core/modules/comment/js/comment-new-indicator.js index 22ec2069fd04..64416bd63a0a 100644 --- a/core/modules/comment/js/comment-new-indicator.js +++ b/core/modules/comment/js/comment-new-indicator.js @@ -7,18 +7,18 @@ (function ($, Drupal, window) { function processCommentNewIndicators(placeholders) { - var isFirstNewComment = true; - var newCommentString = Drupal.t('new'); - var $placeholder; - placeholders.forEach(function (placeholder) { + let isFirstNewComment = true; + const newCommentString = Drupal.t('new'); + let $placeholder; + placeholders.forEach(placeholder => { $placeholder = $(placeholder); - var timestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); - var $node = $placeholder.closest('[data-history-node-id]'); - var nodeID = $node.attr('data-history-node-id'); - var lastViewTimestamp = Drupal.history.getLastRead(nodeID); + const timestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); + const $node = $placeholder.closest('[data-history-node-id]'); + const nodeID = $node.attr('data-history-node-id'); + const lastViewTimestamp = Drupal.history.getLastRead(nodeID); if (timestamp > lastViewTimestamp) { - var $comment = $(placeholder).removeClass('hidden').text(newCommentString).closest('.js-comment').addClass('new'); + const $comment = $(placeholder).removeClass('hidden').text(newCommentString).closest('.js-comment').addClass('new'); if (isFirstNewComment) { isFirstNewComment = false; @@ -33,12 +33,12 @@ } Drupal.behaviors.commentNewIndicator = { - attach: function attach(context) { - var nodeIDs = []; - var placeholders = once('history', '[data-comment-timestamp]', context).filter(function (placeholder) { - var $placeholder = $(placeholder); - var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); - var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); + attach(context) { + const nodeIDs = []; + const placeholders = once('history', '[data-comment-timestamp]', context).filter(placeholder => { + const $placeholder = $(placeholder); + const commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); + const nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { nodeIDs.push(nodeID); @@ -52,9 +52,10 @@ return; } - Drupal.history.fetchTimestamps(nodeIDs, function () { + Drupal.history.fetchTimestamps(nodeIDs, () => { processCommentNewIndicators(placeholders); }); } + }; })(jQuery, Drupal, window);
\ No newline at end of file diff --git a/core/modules/comment/js/node-new-comments-link.js b/core/modules/comment/js/node-new-comments-link.js index 4136308f5860..ebac99a578f7 100644 --- a/core/modules/comment/js/node-new-comments-link.js +++ b/core/modules/comment/js/node-new-comments-link.js @@ -19,15 +19,15 @@ } function processNodeNewCommentLinks(placeholders) { - var $placeholdersToUpdate = {}; - var fieldName = 'comment'; - var $placeholder; - placeholders.forEach(function (placeholder) { + const $placeholdersToUpdate = {}; + let fieldName = 'comment'; + let $placeholder; + placeholders.forEach(placeholder => { $placeholder = $(placeholder); - var timestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); + const timestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); fieldName = $placeholder.attr('data-history-node-field-name'); - var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); - var lastViewTimestamp = Drupal.history.getLastRead(nodeID); + const nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); + const lastViewTimestamp = Drupal.history.getLastRead(nodeID); if (timestamp > lastViewTimestamp) { $placeholdersToUpdate[nodeID] = $placeholder; @@ -35,14 +35,14 @@ remove($placeholder); } }); - var nodeIDs = Object.keys($placeholdersToUpdate); + const nodeIDs = Object.keys($placeholdersToUpdate); if (nodeIDs.length === 0) { return; } function render(results) { - Object.keys(results || {}).forEach(function (nodeID) { + Object.keys(results || {}).forEach(nodeID => { if ($placeholdersToUpdate.hasOwnProperty(nodeID)) { $placeholdersToUpdate[nodeID].attr('href', results[nodeID].first_new_comment_link).text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments')).removeClass('hidden'); show($placeholdersToUpdate[nodeID]); @@ -67,12 +67,12 @@ } Drupal.behaviors.nodeNewCommentsLink = { - attach: function attach(context) { - var nodeIDs = []; - var placeholders = once('history', '[data-history-node-last-comment-timestamp]', context).filter(function (placeholder) { - var $placeholder = $(placeholder); - var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); - var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); + attach(context) { + const nodeIDs = []; + const placeholders = once('history', '[data-history-node-last-comment-timestamp]', context).filter(placeholder => { + const $placeholder = $(placeholder); + const lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); + const nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) { nodeIDs.push(nodeID); @@ -88,9 +88,10 @@ return; } - Drupal.history.fetchTimestamps(nodeIDs, function () { + Drupal.history.fetchTimestamps(nodeIDs, () => { processNodeNewCommentLinks(placeholders); }); } + }; })(jQuery, Drupal, drupalSettings);
\ No newline at end of file |