From 3451ad0f3df69a392bd96b7d94749fabc567b777 Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Sat, 3 Feb 2024 19:31:48 +0100 Subject: [PATCH] ref: notifications without jquery --- .../js/core/components/notifications.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/EMS/admin-ui-bundle/assets/js/core/components/notifications.js b/EMS/admin-ui-bundle/assets/js/core/components/notifications.js index 6d15e5af7..a8a50ef2d 100644 --- a/EMS/admin-ui-bundle/assets/js/core/components/notifications.js +++ b/EMS/admin-ui-bundle/assets/js/core/components/notifications.js @@ -1,4 +1,3 @@ -import $ from 'jquery' import { Toast, Modal } from 'bootstrap' class Notifications { @@ -8,13 +7,13 @@ class Notifications { startActivity () { if (++this.counter > 0) { - $('#ajax-activity').addClass('fa-spin') + document.getElementById('ajax-activity').classList.add("fa-spin") } } stopActivity () { if (--this.counter === 0) { - $('#ajax-activity').removeClass('fa-spin') + document.getElementById('ajax-activity').classList.remove("fa-spin") } } @@ -22,21 +21,19 @@ class Notifications { if (!Array.isArray(messages) || messages.length === 0) { return } - const activityList = $('ul#activity-log') + const activityList = document.getElementById('activity-log') for (let index = 0; index < messages.length; ++index) { - const message = $($.parseHTML(messages[index])) - activityList.append(`
  • ${messages[index]}
  • `) + const listItem = document.createElement('li') + listItem.innerHTML = messages[index] + listItem.setAttribute('title', listItem.textContent) + activityList.insertAdjacentElement("beforeend", listItem) } this.updateCounter() } updateCounter () { - const numberOfElem = $('ul#activity-log>li').length - if (numberOfElem) { - $('#activity-counter').text(numberOfElem) - } else { - $('#activity-counter').empty() - } + const numberOfElem = document.querySelectorAll('ul#activity-log>li').length + document.getElementById('activity-counter').innerHTML = 0 === numberOfElem ? '' : numberOfElem } addNoticeMessages (notices) {