Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / js / comment-new-indicator.js
index d5f0a4f45c88ff6f800be1bd452f532a1fa44564..bc7f55ec37df19121f1a1b0489085c3e44b06c46 100644 (file)
@@ -1,66 +1,40 @@
 /**
- * @file
- * Attaches behaviors for the Comment module's "new" indicator.
- *
- * May only be loaded for authenticated users, with the History module
- * installed.
- */
+* DO NOT EDIT THIS FILE.
+* See the following change record for more information,
+* https://www.drupal.org/node/2815083
+* @preserve
+**/
 
 (function ($, Drupal, window) {
-
-  'use strict';
-
-  /**
-   * Renders "new" comment indicators wherever necessary.
-   *
-   * @type {Drupal~behavior}
-   *
-   * @prop {Drupal~behaviorAttach} attach
-   *   Attaches "new" comment indicators behavior.
-   */
   Drupal.behaviors.commentNewIndicator = {
-    attach: function (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.
+    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;
-          }
-          else {
-            return false;
-          }
-        });
+      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;
       }
 
-      // Fetch the node read timestamps from the server.
       Drupal.history.fetchTimestamps(nodeIDs, function () {
         processCommentNewIndicators($placeholders);
       });
     }
   };
 
-  /**
-   * Processes the markup for "new comment" indicators.
-   *
-   * @param {jQuery} $placeholders
-   *   The elements that should be processed.
-   */
   function processCommentNewIndicators($placeholders) {
     var isFirstNewComment = true;
     var newCommentString = Drupal.t('new');
-    var $placeholder;
+    var $placeholder = void 0;
 
     $placeholders.each(function (index, placeholder) {
       $placeholder = $(placeholder);
       var lastViewTimestamp = Drupal.history.getLastRead(nodeID);
 
       if (timestamp > lastViewTimestamp) {
-        // Turn the placeholder into an actual "new" indicator.
-        var $comment = $(placeholder)
-          .removeClass('hidden')
-          .text(newCommentString)
-          .closest('.js-comment')
-          // Add 'new' class to the comment, so it can be styled.
-          .addClass('new');
+        var $comment = $(placeholder).removeClass('hidden').text(newCommentString).closest('.js-comment').addClass('new');
 
-        // Insert "new" anchor just before the "comment-<cid>" anchor if
-        // this is the first new comment in the DOM.
         if (isFirstNewComment) {
           isFirstNewComment = false;
           $comment.prev().before('<a id="new" />');
-          // 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);
           }
@@ -92,5 +57,4 @@
       }
     });
   }
-
-})(jQuery, Drupal, window);
+})(jQuery, Drupal, window);
\ No newline at end of file