mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Use new notification API
This commit is contained in:
parent
70d2aa7df0
commit
4ff62179df
@ -216,11 +216,12 @@ window.console ?=
|
|||||||
@oldScrollTop = $('.timsChatMessageContainer').scrollTop()
|
@oldScrollTop = $('.timsChatMessageContainer').scrollTop()
|
||||||
|
|
||||||
# Desktop Notifications
|
# Desktop Notifications
|
||||||
unless typeof window.webkitNotifications is 'undefined'
|
if window.Notification?
|
||||||
$('#timsChatNotify').click (event) ->
|
$('#timsChatNotify').click (event) ->
|
||||||
if $(@).data('status') and window.webkitNotifications.checkPermission() isnt 0
|
return unless $(@).data 'status'
|
||||||
window.webkitNotifications.requestPermission()
|
if window.Notification.permission isnt 'granted'
|
||||||
|
window.Notification.requestPermission (permission) ->
|
||||||
|
window.Notification.permission ?= permission
|
||||||
###
|
###
|
||||||
# Changes the chat-room.
|
# Changes the chat-room.
|
||||||
#
|
#
|
||||||
@ -480,18 +481,16 @@ window.console ?=
|
|||||||
title: $('#timsChatRoomList .activeMenuItem a').text()
|
title: $('#timsChatRoomList .activeMenuItem a').text()
|
||||||
|
|
||||||
# Desktop Notifications
|
# Desktop Notifications
|
||||||
if typeof window.webkitNotifications isnt 'undefined'
|
title = WCF.Language.get 'chat.general.notify.title'
|
||||||
if window.webkitNotifications.checkPermission() is 0
|
content = message.username + message.separator + (if message.separator is ' ' then '' else ' ') + message.message
|
||||||
title = WCF.Language.get 'chat.general.notify.title'
|
|
||||||
icon = "data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" # empty gif
|
if window.Notification?
|
||||||
content = message.username + message.separator + (if message.separator is ' ' then '' else ' ') + message.message
|
if window.Notification.permission is 'granted'
|
||||||
notification = window.webkitNotifications.createNotification icon, title, content
|
notification = new window.Notification title,
|
||||||
notification.show()
|
body: content
|
||||||
|
onclick: ->
|
||||||
# Hide notification after 10 seconds
|
notification.close()
|
||||||
setTimeout () ->
|
setTimeout notification.close, 5e3
|
||||||
notification.cancel()
|
|
||||||
, 10e3
|
|
||||||
###
|
###
|
||||||
# Refreshes the room-list.
|
# Refreshes the room-list.
|
||||||
###
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user