X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcomment%2Fjs%2Fcomment-new-indicator.js;h=88587d5724c31c45b86a6232094f729ba777f550;hb=f3baf763d342a5f82576890e2a8111a5aaf139dc;hp=bc7f55ec37df19121f1a1b0489085c3e44b06c46;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/comment/js/comment-new-indicator.js b/web/core/modules/comment/js/comment-new-indicator.js index bc7f55ec3..88587d572 100644 --- a/web/core/modules/comment/js/comment-new-indicator.js +++ b/web/core/modules/comment/js/comment-new-indicator.js @@ -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