From a94236483e26785dcaf97fb10e863f82348eb068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 11 May 2021 08:22:51 +0200 Subject: Let apps toggle an unread counter on app icons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Louis Chemineau Signed-off-by: Julius Härtl --- core/src/components/MainMenu.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/src') diff --git a/core/src/components/MainMenu.js b/core/src/components/MainMenu.js index 74ca3de1c5e..3b5aa19245e 100644 --- a/core/src/components/MainMenu.js +++ b/core/src/components/MainMenu.js @@ -32,6 +32,26 @@ import OC from '../OC' * If the screen is bigger, the main menu is not a toggle any more. */ export const setUp = () => { + + Object.assign(OC, { + setNavigationCounter(id, counter) { + const appmenuElement = document.getElementById('appmenu').querySelector('[data-id="' + id + '"] svg') + const appsElement = document.getElementById('apps').querySelector('[data-id="' + id + '"] svg') + if (counter === 0) { + appmenuElement.classList.remove('has-unread') + appsElement.classList.remove('has-unread') + appmenuElement.getElementsByTagName('image')[0].style.mask = '' + appsElement.getElementsByTagName('image')[0].style.mask = '' + } else { + appmenuElement.classList.add('has-unread') + appsElement.classList.add('has-unread') + appmenuElement.getElementsByTagName('image')[0].style.mask = 'url(#hole)' + appsElement.getElementsByTagName('image')[0].style.mask = 'url(#hole)' + } + document.getElementById('appmenu').querySelector('[data-id="' + id + '"] .unread-counter').textContent = counter + document.getElementById('apps').querySelector('[data-id="' + id + '"] .unread-counter').textContent = counter + }, + }) // init the more-apps menu OC.registerMenu($('#more-apps > a'), $('#navigation')) -- cgit v1.2.3