Skip to content

Commit

Permalink
Merge branch 'master-133' of https://github.com/mjtko/kandan into 150
Browse files Browse the repository at this point in the history
Fixes #150.
  • Loading branch information
jrgifford committed Mar 1, 2013
2 parents 42873da + 6031deb commit 7ba3ca6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/backbone/helpers/channels.js.coffee
Expand Up @@ -135,7 +135,7 @@ class Kandan.Helpers.Channels

if not local and @getActiveChannelId() == activityAttributes.channel_id and activityAttributes.action == "message" and Kandan.Helpers.Utils.browserTabFocused != true
Kandan.Helpers.Utils.notifyInTitle()
Kandan.Plugins.Notifications.playAudioNotification()
Kandan.Plugins.Notifications.playAudioNotification('channel')
Kandan.Plugins.Notifications.displayNotification(activityAttributes.user.username || activityAttributes.user.email, activityAttributes.content)

@setPaginationData(activityAttributes.channel_id)
Expand Down
10 changes: 7 additions & 3 deletions app/assets/javascripts/backbone/plugins/music_player.js.coffee
Expand Up @@ -7,7 +7,10 @@ class Kandan.Plugins.MusicPlayer
@stopRegex: /^/stop/
@resumeRegex: /^/resume/
@localSongData: false

@sounds: {
channel: 'ding.wav'
attention: 'gong.mp3'
}

@playTemplate: _.template('<strong><a class="audio-play">playing</a> <a target="_blank" href="<%- url %>"><%- url %></a></strong>')
@stopTemplate: _.template('<strong><a class="audio-play">stopping</a> the music.')
Expand Down Expand Up @@ -170,8 +173,9 @@ class Kandan.Plugins.MusicPlayer
if @audioChannel(channelId)?
@unmute(channelId)

@playAudioNotice: ->
url = @localFileUrl('ding.wav')
@playAudioNotice: (type)->
sound = @sounds[type] || 'ding.wav'
url = @localFileUrl(sound)
player = $('.audio_private')[0]
player.setAttribute('src', url)
player.play()
Expand Down
14 changes: 8 additions & 6 deletions app/assets/javascripts/backbone/plugins/notifications.js.coffee
Expand Up @@ -76,7 +76,7 @@ class Kandan.Plugins.Notifications
@onPopupNotificationsEnabled: ()->
if @webkitNotificationsEnabled()
@enablePopupNotifications()

return

# If you are wondering why the kandan icon is not displayed on OS X this is the reason:
Expand Down Expand Up @@ -108,7 +108,7 @@ class Kandan.Plugins.Notifications
@sound_notifications_enabled = true
$(".sound-notifications .enable-sound-notifications").remove()
$(".notification.sound-notifications").append(@disable_sound_notifications_template())

return

@disableSoundNotifications: ()->
Expand All @@ -118,7 +118,9 @@ class Kandan.Plugins.Notifications
$(".notification.sound-notifications").append(@enable_sound_notifications_template())
return

@playAudioNotification: ()->
if @sound_notifications_enabled
Kandan.Plugins.MusicPlayer.playAudioNotice()
return
@playAudioNotification: (type)->
if @sound_notifications_enabled and not @isPlaying
@isPlaying = true
setTimeout (=> @isPlaying = false), 1000
Kandan.Plugins.MusicPlayer.playAudioNotice(type)
return
Expand Up @@ -27,6 +27,7 @@ class Kandan.Views.ShowActivity extends Backbone.View

if user_mention_regex.test(@compiledTemplate) || all_mention_regex.test(@compiledTemplate)
$(@el).addClass("mentioned_user")
Kandan.Plugins.Notifications?.playAudioNotification('attention')

if activity.id == undefined
$(@el).attr("id", "activity-c#{activity.cid}")
Expand Down

0 comments on commit 7ba3ca6

Please sign in to comment.