prawnsalad/KiwiIRC — pull request #638 by spadgos (2014-12-17 16:17:31+00:00)
Title: Abstract desktop notifications to a class

The state of the desktop notifications is a bit weird. There's duplicated code checking for browser support (differently in each case), and a few bugs with hiding the settings.

This PR abstracts the code to a helper class and provides a simple interface for creating and closing notifications.

```js
// example usage:
_kiwi.global.utils.notifications
.create('Title', { icon: 'icon.png', body: 'Body text' })
.closeAfter(5000)
.on('close', function () { doSomething(); });
```

Important things to note:
- this drops support for `window.webkitNotifications` and `navigator.mozNotification`, since Chrome and Firefox also dropped that support a while back.
- there's no fallback for IE. Not much you can really do about that...
- clicking the notification will focus the KiwiIRC tab
- If the user has previously allowed or blocked desktop notifications, there's nothing you can do from the code to override that or ask them again. In this case, I hide the button on the settings page, since it *can't* do anything. Perhaps what would be nicer would be to display a message says "Desktop notifications are enabled/disabled." along with instructions on how to change that (in case you accidentally blocked it once and want to change it). The only problem though is that it would require some new language strings, and I don't know the process for that, so I just left it out.