Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/comment/js/node-new-comments-link.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, drupalSettings) { | 8 (function ($, Drupal, drupalSettings) { |
9 Drupal.behaviors.nodeNewCommentsLink = { | |
10 attach: function attach(context) { | |
11 var nodeIDs = []; | |
12 var $placeholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () { | |
13 var $placeholder = $(this); | |
14 var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); | |
15 var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); | |
16 if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) { | |
17 nodeIDs.push(nodeID); | |
18 | |
19 hide($placeholder); | |
20 return true; | |
21 } | |
22 | |
23 remove($placeholder); | |
24 return false; | |
25 }); | |
26 | |
27 if ($placeholders.length === 0) { | |
28 return; | |
29 } | |
30 | |
31 Drupal.history.fetchTimestamps(nodeIDs, function () { | |
32 processNodeNewCommentLinks($placeholders); | |
33 }); | |
34 } | |
35 }; | |
36 | |
37 function hide($placeholder) { | 9 function hide($placeholder) { |
38 return $placeholder.closest('.comment-new-comments').prev().addClass('last').end().hide(); | 10 return $placeholder.closest('.comment-new-comments').prev().addClass('last').end().hide(); |
39 } | 11 } |
40 | 12 |
41 function remove($placeholder) { | 13 function remove($placeholder) { |
88 dataType: 'json', | 60 dataType: 'json', |
89 success: render | 61 success: render |
90 }); | 62 }); |
91 } | 63 } |
92 } | 64 } |
65 | |
66 Drupal.behaviors.nodeNewCommentsLink = { | |
67 attach: function attach(context) { | |
68 var nodeIDs = []; | |
69 var $placeholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () { | |
70 var $placeholder = $(this); | |
71 var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); | |
72 var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); | |
73 if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) { | |
74 nodeIDs.push(nodeID); | |
75 | |
76 hide($placeholder); | |
77 return true; | |
78 } | |
79 | |
80 remove($placeholder); | |
81 return false; | |
82 }); | |
83 | |
84 if ($placeholders.length === 0) { | |
85 return; | |
86 } | |
87 | |
88 Drupal.history.fetchTimestamps(nodeIDs, function () { | |
89 processNodeNewCommentLinks($placeholders); | |
90 }); | |
91 } | |
92 }; | |
93 })(jQuery, Drupal, drupalSettings); | 93 })(jQuery, Drupal, drupalSettings); |