QR notification fixes.

This commit is contained in:
ccd0 2015-03-14 10:50:35 -07:00
parent 29afe88625
commit 2824f3cde4
2 changed files with 15 additions and 19 deletions

View File

@ -170,7 +170,7 @@ QR =
QR.setCustomCooldown enabled QR.setCustomCooldown enabled
$.set 'customCooldownEnabled', enabled $.set 'customCooldownEnabled', enabled
error: (err) -> error: (err, focusOverride) ->
QR.open() QR.open()
if typeof err is 'string' if typeof err is 'string'
el = $.tn err el = $.tn err
@ -179,28 +179,24 @@ QR =
el.removeAttribute 'style' el.removeAttribute 'style'
if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent
QR.captcha.setup true QR.captcha.setup true
QR.notify el
alert el.textContent if d.hidden and not QR.cooldown.auto
notify: (el) ->
notice = new Notice 'warning', el notice = new Notice 'warning', el
unless Header.areNotificationsEnabled and d.hidden QR.notifications.push notice
QR.notifications.push notice unless Header.areNotificationsEnabled
else alert el.textContent if d.hidden and not QR.cooldown.auto
else if d.hidden or not (focusOverride or d.hasFocus())
notif = new Notification el.textContent, notif = new Notification el.textContent,
body: el.textContent body: el.textContent
icon: Favicon.logo icon: Favicon.logo
notif.onclick = -> window.focus() notif.onclick = -> window.focus()
<% if (type === 'crx') { %> if chrome?
# Firefox automatically closes notifications # Firefox automatically closes notifications
# so we can't control the onclose properly. # so we can't control the onclose properly.
notif.onclose = -> notice.close() notif.onclose = -> notice.close()
notif.onshow = -> notif.onshow = ->
setTimeout -> setTimeout ->
notif.onclose = null notif.onclose = null
notif.close() notif.close()
, 7 * $.SECOND , 7 * $.SECOND
<% } %>
notifications: [] notifications: []

View File

@ -170,7 +170,7 @@ QR.post = class
e.stopPropagation() e.stopPropagation()
@rm() if @ in QR.posts @rm() if @ in QR.posts
$.on rmAll, 'click', QR.post.rmErrored $.on rmAll, 'click', QR.post.rmErrored
QR.error div QR.error div, true
fileError: (message) -> fileError: (message) ->
@error 'file-error', "#{@filename}: #{message}" @error 'file-error', "#{@filename}: #{message}"