From 237e4d43229847bb69aadcfa6e6aca517128913b Mon Sep 17 00:00:00 2001 From: TrueKuehli Date: Mon, 1 Oct 2018 14:15:05 +0200 Subject: Documented the code better and made some minor fixes --- .../src/modules/ui/notification-banner.js | 42 ++++++++++++++-------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'WebInterface/NodeJSServer/src/modules/ui/notification-banner.js') diff --git a/WebInterface/NodeJSServer/src/modules/ui/notification-banner.js b/WebInterface/NodeJSServer/src/modules/ui/notification-banner.js index d14845e..395db94 100644 --- a/WebInterface/NodeJSServer/src/modules/ui/notification-banner.js +++ b/WebInterface/NodeJSServer/src/modules/ui/notification-banner.js @@ -1,4 +1,13 @@ +/** + * Class for controlling the Notification banner + */ export default class BannerController { + /** + * Creates references to objects and hides notification banner + * @param {string} bannerId ID of Notification Banner + * @param {string} textP ID of Notification Banner text field + * @param {string} dismissBtn ID of dismiss button + */ constructor(bannerId, textP, dismissBtn) { this.banner = document.getElementById(bannerId); this.bannerText = document.getElementById(textP); @@ -9,12 +18,20 @@ export default class BannerController { this.banner.classList.add('hidden'); } + /** + * Registers dismissing via the dismiss button + */ register() { this.dismissBtn.addEventListener('click', () => { this.dismissCurrent(); }); } + /** + * Pushes a new message to the notification banner and shows it + * @param {string} name Name to register notification (referenced in hide) + * @param {string} text Notification text + */ show(name, text) { let bannerItem = {name, text, 'html': false}; this.bannerMsgs.push(bannerItem); @@ -22,6 +39,10 @@ export default class BannerController { this.update(); } + /** + * Removes notification from banner + * @param {string} name Name, that the notification was registered under + */ hide(name) { if (!name) { this.bannerMsgs = []; @@ -37,11 +58,18 @@ export default class BannerController { } } + /** + * Dismisses the currently shown message + */ dismissCurrent() { this.hide(this.current); } + /** + * Updates the notification banner with the most recent message + */ update() { + // TODO: Show if multiple messages are there if (this.bannerMsgs.length === 0) { this.banner.classList.add('hidden'); return; @@ -58,18 +86,4 @@ export default class BannerController { this.current = name; } - - showPersistence() { - let text = `Storage persistence is disabled, so in-browser storage of created Wikis might not work.\n` + - `Click here to enable storage persistence.`; - let bannerItem = {'name': 'persistence', text, 'html': true}; - this.bannerMsgs.push(bannerItem); - this.update(); - } } -- cgit v1.2.3-54-g00ecf