File tree 4 files changed +17
-10
lines changed
app/assets/javascripts/backbone
4 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ class Kandan.Helpers.Channels
135
135
136
136
if not local and @ getActiveChannelId () == activityAttributes .channel_id and activityAttributes .action == " message" and Kandan .Helpers .Utils .browserTabFocused != true
137
137
Kandan .Helpers .Utils .notifyInTitle ()
138
- Kandan .Plugins .Notifications .playAudioNotification ()
138
+ Kandan .Plugins .Notifications .playAudioNotification (' channel ' )
139
139
Kandan .Plugins .Notifications .displayNotification (activityAttributes .user .username || activityAttributes .user .email , activityAttributes .content )
140
140
141
141
@ setPaginationData (activityAttributes .channel_id )
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ class Kandan.Plugins.MusicPlayer
7
7
@stopRegex : / ^ /stop/
8
8
@resumeRegex : / ^ /resume/
9
9
@localSongData : false
10
-
10
+ @sounds : {
11
+ channel : ' ding.wav'
12
+ attention : ' gong.mp3'
13
+ }
11
14
12
15
@playTemplate : _ .template (' <strong><a class="audio-play">playing</a> <a target="_blank" href="<%- url %>"><%- url %></a></strong>' )
13
16
@stopTemplate : _ .template (' <strong><a class="audio-play">stopping</a> the music.' )
@@ -170,8 +173,9 @@ class Kandan.Plugins.MusicPlayer
170
173
if @ audioChannel (channelId)?
171
174
@ unmute (channelId)
172
175
173
- @ playAudioNotice: ->
174
- url = @ localFileUrl (' ding.wav' )
176
+ @ playAudioNotice: (type )->
177
+ sound = @sounds [type] || ' ding.wav'
178
+ url = @ localFileUrl (sound)
175
179
player = $ (' .audio_private' )[0 ]
176
180
player .setAttribute (' src' , url)
177
181
player .play ()
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ class Kandan.Plugins.Notifications
76
76
@ onPopupNotificationsEnabled: ()->
77
77
if @ webkitNotificationsEnabled ()
78
78
@ enablePopupNotifications ()
79
-
79
+
80
80
return
81
81
82
82
# If you are wondering why the kandan icon is not displayed on OS X this is the reason:
@@ -108,7 +108,7 @@ class Kandan.Plugins.Notifications
108
108
@sound_notifications_enabled = true
109
109
$ (" .sound-notifications .enable-sound-notifications" ).remove ()
110
110
$ (" .notification.sound-notifications" ).append (@ disable_sound_notifications_template ())
111
-
111
+
112
112
return
113
113
114
114
@ disableSoundNotifications: ()->
@@ -118,7 +118,9 @@ class Kandan.Plugins.Notifications
118
118
$ (" .notification.sound-notifications" ).append (@ enable_sound_notifications_template ())
119
119
return
120
120
121
- @ playAudioNotification: ()->
122
- if @sound_notifications_enabled
123
- Kandan .Plugins .MusicPlayer .playAudioNotice ()
124
- return
121
+ @ playAudioNotification: (type )->
122
+ if @sound_notifications_enabled and not @isPlaying
123
+ @isPlaying = true
124
+ setTimeout (=> @isPlaying = false ), 1000
125
+ Kandan .Plugins .MusicPlayer .playAudioNotice (type)
126
+ return
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class Kandan.Views.ShowActivity extends Backbone.View
26
26
27
27
if user_mention_regex .test (@compiledTemplate ) || all_mention_regex .test (@compiledTemplate )
28
28
$ (@el ).addClass (" mentioned_user" )
29
+ Kandan .Plugins .Notifications ? .playAudioNotification (' attention' )
29
30
30
31
if activity .id == undefined
31
32
$ (@el ).attr (" id" , " activity-c#{ activity .cid } " )
You can’t perform that action at this time.
0 commit comments