Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
4 * https://www.drupal.org/node/2815083 | 4 * https://www.drupal.org/node/2815083 |
5 * @preserve | 5 * @preserve |
6 **/ | 6 **/ |
7 | 7 |
8 (function ($, Drupal, window) { | 8 (function ($, Drupal, window) { |
9 Drupal.behaviors.commentNewIndicator = { | |
10 attach: function attach(context) { | |
11 var nodeIDs = []; | |
12 var $placeholders = $(context).find('[data-comment-timestamp]').once('history').filter(function () { | |
13 var $placeholder = $(this); | |
14 var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); | |
15 var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); | |
16 if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { | |
17 nodeIDs.push(nodeID); | |
18 return true; | |
19 } | |
20 | |
21 return false; | |
22 }); | |
23 | |
24 if ($placeholders.length === 0) { | |
25 return; | |
26 } | |
27 | |
28 Drupal.history.fetchTimestamps(nodeIDs, function () { | |
29 processCommentNewIndicators($placeholders); | |
30 }); | |
31 } | |
32 }; | |
33 | |
34 function processCommentNewIndicators($placeholders) { | 9 function processCommentNewIndicators($placeholders) { |
35 var isFirstNewComment = true; | 10 var isFirstNewComment = true; |
36 var newCommentString = Drupal.t('new'); | 11 var newCommentString = Drupal.t('new'); |
37 var $placeholder = void 0; | 12 var $placeholder = void 0; |
38 | 13 |
55 } | 30 } |
56 } | 31 } |
57 } | 32 } |
58 }); | 33 }); |
59 } | 34 } |
35 | |
36 Drupal.behaviors.commentNewIndicator = { | |
37 attach: function attach(context) { | |
38 var nodeIDs = []; | |
39 var $placeholders = $(context).find('[data-comment-timestamp]').once('history').filter(function () { | |
40 var $placeholder = $(this); | |
41 var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); | |
42 var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); | |
43 if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { | |
44 nodeIDs.push(nodeID); | |
45 return true; | |
46 } | |
47 | |
48 return false; | |
49 }); | |
50 | |
51 if ($placeholders.length === 0) { | |
52 return; | |
53 } | |
54 | |
55 Drupal.history.fetchTimestamps(nodeIDs, function () { | |
56 processCommentNewIndicators($placeholders); | |
57 }); | |
58 } | |
59 }; | |
60 })(jQuery, Drupal, window); | 60 })(jQuery, Drupal, window); |