Sha256: 7da20fa401844263b28865b5ffaa4fcd00466d2ae809d2fb4affd7e0500eb134

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

$(() => {
  const $wrapper = $("#notifications");
  const $section = $wrapper.find("section#notifications-list");
  const $noNotificationsText = $wrapper.find(".empty-notifications");
  const $pagination = $wrapper.find("ul.pagination");
  const FADEOUT_TIME = 500;

  const anyNotifications = () => $wrapper.find(".card--list__item").length > 0;
  const emptyNotifications = () => {
    if (!anyNotifications()) {
      $section.remove();
      $noNotificationsText.removeClass("hide");
    }
  };

  $section.on("click", ".mark-as-read-button", (event) => {
    const $item = $(event.target).parents(".card--list__item");
    $item.fadeOut(FADEOUT_TIME, () => {
      $item.remove();
      emptyNotifications();
    });
  });

  $wrapper.on("click", ".mark-all-as-read-button", () => {
    $section.fadeOut(FADEOUT_TIME, () => {
      $pagination.remove();
      $wrapper.find(".card--list__item").remove();
      emptyNotifications();
    });
  });

  emptyNotifications();
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.11.2 app/assets/javascripts/decidim/notifications.js.es6
decidim-core-0.11.1 app/assets/javascripts/decidim/notifications.js.es6
decidim-core-0.11.0.pre1 app/assets/javascripts/decidim/notifications.js.es6