mark-as-read.es6.js 720 B

123456789101112131415161718192021
  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. (function(window, Drupal, drupalSettings) {
  10. // When the window's "load" event is triggered, mark all enumerated nodes as
  11. // read. This still allows for Drupal behaviors (which are triggered on the
  12. // "DOMContentReady" event) to add "new" and "updated" indicators.
  13. window.addEventListener('load', () => {
  14. if (drupalSettings.history && drupalSettings.history.nodesToMarkAsRead) {
  15. Object.keys(drupalSettings.history.nodesToMarkAsRead).forEach(
  16. Drupal.history.markAsRead,
  17. );
  18. }
  19. });
  20. })(window, Drupal, drupalSettings);