Mercurial > hg > cmmr2012-drupal-site
diff core/modules/comment/js/comment-new-indicator.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 |
line wrap: on
line diff
--- a/core/modules/comment/js/comment-new-indicator.js Thu Feb 28 11:14:44 2019 +0000 +++ b/core/modules/comment/js/comment-new-indicator.js Thu Feb 28 13:11:55 2019 +0000 @@ -6,31 +6,6 @@ **/ (function ($, Drupal, window) { - Drupal.behaviors.commentNewIndicator = { - attach: function attach(context) { - var nodeIDs = []; - var $placeholders = $(context).find('[data-comment-timestamp]').once('history').filter(function () { - var $placeholder = $(this); - var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); - var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); - if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { - nodeIDs.push(nodeID); - return true; - } - - return false; - }); - - if ($placeholders.length === 0) { - return; - } - - Drupal.history.fetchTimestamps(nodeIDs, function () { - processCommentNewIndicators($placeholders); - }); - } - }; - function processCommentNewIndicators($placeholders) { var isFirstNewComment = true; var newCommentString = Drupal.t('new'); @@ -57,4 +32,29 @@ } }); } + + Drupal.behaviors.commentNewIndicator = { + attach: function attach(context) { + var nodeIDs = []; + var $placeholders = $(context).find('[data-comment-timestamp]').once('history').filter(function () { + var $placeholder = $(this); + var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); + var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); + if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { + nodeIDs.push(nodeID); + return true; + } + + return false; + }); + + if ($placeholders.length === 0) { + return; + } + + Drupal.history.fetchTimestamps(nodeIDs, function () { + processCommentNewIndicators($placeholders); + }); + } + }; })(jQuery, Drupal, window); \ No newline at end of file