updated core to 8.6.1 via composer
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Attaches behaviors for the Comment module's "by-viewer" class.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
(function($, Drupal, drupalSettings) {
|
||||
/**
|
||||
* Add 'by-viewer' class to comments written by the current user.
|
||||
*
|
||||
@@ -13,10 +13,13 @@
|
||||
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;
|
||||
.filter(function() {
|
||||
return (
|
||||
parseInt(this.getAttribute('data-comment-user-id'), 10) ===
|
||||
currentUserID
|
||||
);
|
||||
})
|
||||
.addClass('by-viewer');
|
||||
},
|
||||
};
|
||||
}(jQuery, Drupal, drupalSettings));
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
@@ -6,47 +6,7 @@
|
||||
* installed.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, window) {
|
||||
/**
|
||||
* Renders "new" comment indicators wherever necessary.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches "new" comment indicators behavior.
|
||||
*/
|
||||
Drupal.behaviors.commentNewIndicator = {
|
||||
attach(context) {
|
||||
// Collect all "new" comment indicator placeholders (and their
|
||||
// corresponding node IDs) newer than 30 days ago that have not already
|
||||
// been read after their last comment timestamp.
|
||||
const nodeIDs = [];
|
||||
const $placeholders = $(context)
|
||||
.find('[data-comment-timestamp]')
|
||||
.once('history')
|
||||
.filter(function () {
|
||||
const $placeholder = $(this);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the node read timestamps from the server.
|
||||
Drupal.history.fetchTimestamps(nodeIDs, () => {
|
||||
processCommentNewIndicators($placeholders);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
(function($, Drupal, window) {
|
||||
/**
|
||||
* Processes the markup for "new comment" indicators.
|
||||
*
|
||||
@@ -60,7 +20,10 @@
|
||||
|
||||
$placeholders.each((index, placeholder) => {
|
||||
$placeholder = $(placeholder);
|
||||
const timestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10);
|
||||
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);
|
||||
@@ -82,10 +45,58 @@
|
||||
// If the URL points to the first new comment, then scroll to that
|
||||
// comment.
|
||||
if (window.location.hash === '#new') {
|
||||
window.scrollTo(0, $comment.offset().top - Drupal.displace.offsets.top);
|
||||
window.scrollTo(
|
||||
0,
|
||||
$comment.offset().top - Drupal.displace.offsets.top,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}(jQuery, Drupal, window));
|
||||
|
||||
/**
|
||||
* Renders "new" comment indicators wherever necessary.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches "new" comment indicators behavior.
|
||||
*/
|
||||
Drupal.behaviors.commentNewIndicator = {
|
||||
attach(context) {
|
||||
// Collect all "new" comment indicator placeholders (and their
|
||||
// corresponding node IDs) newer than 30 days ago that have not already
|
||||
// been read after their last comment timestamp.
|
||||
const nodeIDs = [];
|
||||
const $placeholders = $(context)
|
||||
.find('[data-comment-timestamp]')
|
||||
.once('history')
|
||||
.filter(function() {
|
||||
const $placeholder = $(this);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the node read timestamps from the server.
|
||||
Drupal.history.fetchTimestamps(nodeIDs, () => {
|
||||
processCommentNewIndicators($placeholders);
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, window);
|
||||
|
||||
@@ -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);
|
||||
@@ -6,52 +6,7 @@
|
||||
* installed.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
/**
|
||||
* Render "X new comments" links wherever necessary.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches new comment links behavior.
|
||||
*/
|
||||
Drupal.behaviors.nodeNewCommentsLink = {
|
||||
attach(context) {
|
||||
// Collect all "X new comments" node link placeholders (and their
|
||||
// corresponding node IDs) newer than 30 days ago that have not already
|
||||
// been read after their last comment timestamp.
|
||||
const nodeIDs = [];
|
||||
const $placeholders = $(context)
|
||||
.find('[data-history-node-last-comment-timestamp]')
|
||||
.once('history')
|
||||
.filter(function () {
|
||||
const $placeholder = $(this);
|
||||
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);
|
||||
// Hide this placeholder link until it is certain we'll need it.
|
||||
hide($placeholder);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove this placeholder link from the DOM because we won't need
|
||||
// it.
|
||||
remove($placeholder);
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform an AJAX request to retrieve node read timestamps.
|
||||
Drupal.history.fetchTimestamps(nodeIDs, () => {
|
||||
processNodeNewCommentLinks($placeholders);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
(function($, Drupal, drupalSettings) {
|
||||
/**
|
||||
* Hides a "new comment" element.
|
||||
*
|
||||
@@ -62,15 +17,17 @@
|
||||
* The placeholder element passed in as a parameter.
|
||||
*/
|
||||
function hide($placeholder) {
|
||||
return $placeholder
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and give it the 'last' class.
|
||||
.prev()
|
||||
.addClass('last')
|
||||
// Go back to the parent <li> and hide it.
|
||||
.end()
|
||||
.hide();
|
||||
return (
|
||||
$placeholder
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and give it the 'last' class.
|
||||
.prev()
|
||||
.addClass('last')
|
||||
// Go back to the parent <li> and hide it.
|
||||
.end()
|
||||
.hide()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,15 +50,17 @@
|
||||
* The placeholder element passed in as a parameter.
|
||||
*/
|
||||
function show($placeholder) {
|
||||
return $placeholder
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and remove its 'last' class, if any.
|
||||
.prev()
|
||||
.removeClass('last')
|
||||
// Go back to the parent <li> and show it.
|
||||
.end()
|
||||
.show();
|
||||
return (
|
||||
$placeholder
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and remove its 'last' class, if any.
|
||||
.prev()
|
||||
.removeClass('last')
|
||||
// Go back to the parent <li> and show it.
|
||||
.end()
|
||||
.show()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,9 +76,14 @@
|
||||
let $placeholder;
|
||||
$placeholders.each((index, placeholder) => {
|
||||
$placeholder = $(placeholder);
|
||||
const 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');
|
||||
const nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id');
|
||||
const nodeID = $placeholder
|
||||
.closest('[data-history-node-id]')
|
||||
.attr('data-history-node-id');
|
||||
const lastViewTimestamp = Drupal.history.getLastRead(nodeID);
|
||||
|
||||
// Queue this placeholder's "X new comments" link to be downloaded from
|
||||
@@ -149,11 +113,17 @@
|
||||
* Data about new comment links indexed by nodeID.
|
||||
*/
|
||||
function render(results) {
|
||||
Object.keys(results || {}).forEach((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'))
|
||||
.text(
|
||||
Drupal.formatPlural(
|
||||
results[nodeID].new_comment_count,
|
||||
'1 new comment',
|
||||
'@count new comments',
|
||||
),
|
||||
)
|
||||
.removeClass('hidden');
|
||||
show($placeholdersToUpdate[nodeID]);
|
||||
}
|
||||
@@ -162,8 +132,7 @@
|
||||
|
||||
if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) {
|
||||
render(drupalSettings.comment.newCommentsLinks.node[fieldName]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$.ajax({
|
||||
url: Drupal.url('comments/render_new_comments_node_links'),
|
||||
type: 'POST',
|
||||
@@ -173,4 +142,54 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}(jQuery, Drupal, drupalSettings));
|
||||
|
||||
/**
|
||||
* Render "X new comments" links wherever necessary.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches new comment links behavior.
|
||||
*/
|
||||
Drupal.behaviors.nodeNewCommentsLink = {
|
||||
attach(context) {
|
||||
// Collect all "X new comments" node link placeholders (and their
|
||||
// corresponding node IDs) newer than 30 days ago that have not already
|
||||
// been read after their last comment timestamp.
|
||||
const nodeIDs = [];
|
||||
const $placeholders = $(context)
|
||||
.find('[data-history-node-last-comment-timestamp]')
|
||||
.once('history')
|
||||
.filter(function() {
|
||||
const $placeholder = $(this);
|
||||
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);
|
||||
// Hide this placeholder link until it is certain we'll need it.
|
||||
hide($placeholder);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove this placeholder link from the DOM because we won't need
|
||||
// it.
|
||||
remove($placeholder);
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform an AJAX request to retrieve node read timestamps.
|
||||
Drupal.history.fetchTimestamps(nodeIDs, () => {
|
||||
processNodeNewCommentLinks($placeholders);
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
@@ -6,34 +6,6 @@
|
||||
**/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
Drupal.behaviors.nodeNewCommentsLink = {
|
||||
attach: function attach(context) {
|
||||
var nodeIDs = [];
|
||||
var $placeholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () {
|
||||
var $placeholder = $(this);
|
||||
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');
|
||||
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
|
||||
nodeIDs.push(nodeID);
|
||||
|
||||
hide($placeholder);
|
||||
return true;
|
||||
}
|
||||
|
||||
remove($placeholder);
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Drupal.history.fetchTimestamps(nodeIDs, function () {
|
||||
processNodeNewCommentLinks($placeholders);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function hide($placeholder) {
|
||||
return $placeholder.closest('.comment-new-comments').prev().addClass('last').end().hide();
|
||||
}
|
||||
@@ -90,4 +62,32 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.behaviors.nodeNewCommentsLink = {
|
||||
attach: function attach(context) {
|
||||
var nodeIDs = [];
|
||||
var $placeholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () {
|
||||
var $placeholder = $(this);
|
||||
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');
|
||||
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
|
||||
nodeIDs.push(nodeID);
|
||||
|
||||
hide($placeholder);
|
||||
return true;
|
||||
}
|
||||
|
||||
remove($placeholder);
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Drupal.history.fetchTimestamps(nodeIDs, function () {
|
||||
processNodeNewCommentLinks($placeholders);
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
Reference in New Issue
Block a user