Replace QR alerts with desktop notifications. #1053

This commit is contained in:
Mayhem 2013-08-17 17:43:31 +02:00
parent c64792f35c
commit 253a4a8fbe
2 changed files with 12 additions and 2 deletions

View File

@ -25,4 +25,5 @@ class Notice
setTimeout @close, @timeout * $.SECOND if @timeout
close: =>
$.off d, 'visibilitychange', @add
$.rm @el

View File

@ -111,8 +111,17 @@ QR =
if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent
# Focus the captcha input on captcha error.
QR.captcha.nodes.input.focus()
alert el.textContent if d.hidden
QR.notifications.push new Notice 'warning', el
notice = new Notice 'warning', el
QR.notifications.push notice
return unless d.hidden
notif = new Notification el.textContent,
iconUrl: Favicon.empty
notif.onclick = -> window.focus()
notif.onclose = -> notice.close()
setTimeout ->
notif.onclose = null
notif.close()
, 5 * $.SECOND
notifications: []
cleanNotifications: ->
for notification in QR.notifications