diff --git a/CHANGELOG.md b/CHANGELOG.md index df017e29..f4d2de0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - client - file browser now remembers the last displayed directory + - allow dismissing notifications by clicking on them ## 1.26.2 diff --git a/resources/docs/docs/user-interface/client.md b/resources/docs/docs/user-interface/client.md index b48599ea..a7a05e0d 100644 --- a/resources/docs/docs/user-interface/client.md +++ b/resources/docs/docs/user-interface/client.md @@ -42,7 +42,7 @@ It is the main component, it contains all the widgets and takes all the availabl ## 4. Notifications -Notifications appear in the lower right corner, they are usually used to convey server status information. +Notifications appear in the lower right corner, they are usually used to convey server status information and can be dismissed with a single click. ## 5. Modals diff --git a/src/client/ui/notifications.js b/src/client/ui/notifications.js index 1c9547f0..3a5e1324 100644 --- a/src/client/ui/notifications.js +++ b/src/client/ui/notifications.js @@ -1,5 +1,6 @@ var html = require('nanohtml'), - morph = require('nanomorph') + morph = require('nanomorph'), + UiWidget = require('./ui-widget') var DEFAULT_DURATION = 3500 @@ -53,15 +54,22 @@ class Toast { } -class Notifications { +class Notifications extends UiWidget { - constructor() { + constructor(options) { + + super(options) - this.container = DOM.get('#notifications')[0] this.toasts = [] this.loop = null + this.container.addEventListener('fast-click', (e)=>{ + for (var toast of this.toasts) { + if (toast.html.contains(e.target)) this.remove(toast) + } + }) + } add(data) { @@ -118,4 +126,4 @@ class Notifications { } -module.exports = new Notifications() +module.exports = new Notifications({selector: '#notifications'})