Version 1
[yaffs-website] / web / core / modules / history / js / mark-as-read.js
1 /**
2  * @file
3  * Marks the nodes listed in drupalSettings.history.nodesToMarkAsRead as read.
4  *
5  * Uses the History module JavaScript API.
6  *
7  * @see Drupal.history
8  */
9
10 (function (window, Drupal, drupalSettings) {
11
12   'use strict';
13
14   // When the window's "load" event is triggered, mark all enumerated nodes as
15   // read. This still allows for Drupal behaviors (which are triggered on the
16   // "DOMContentReady" event) to add "new" and "updated" indicators.
17   window.addEventListener('load', function () {
18     if (drupalSettings.history && drupalSettings.history.nodesToMarkAsRead) {
19       Object.keys(drupalSettings.history.nodesToMarkAsRead).forEach(Drupal.history.markAsRead);
20     }
21   });
22
23 })(window, Drupal, drupalSettings);