Skip to content

Commit 6343d95

Browse files
committedApr 5, 2012
Adds notification in the windoe title if the window/tab is inactive
Signed-off-by: Akash Manohar J <akash@akash.im>
1 parent 0cc5d17 commit 6343d95

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 

‎app/assets/javascripts/backbone/helpers/channels.js.coffee.erb

+2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ class Kandan.Helpers.Channels
121121
@scrollToLatestMessage(channelId) if @pastAutoScrollThreshold(channelId)
122122

123123

124+
124125
@add_message: (activityAttributes, state)->
125126
@channel_activities_el(activityAttributes.channel_id)
126127
.append(@new_activity_view(activityAttributes).render().el)
127128
@flushActivities(activityAttributes.channel_id)
129+
Kandan.Helpers.Utils.notifyInTitleIfRequired()
128130
@set_pagination_data(activityAttributes.channel_id)
129131

130132

‎app/assets/javascripts/backbone/helpers/utils.js.coffee

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
class Kandan.Helpers.Utils
22

3+
@browserTabFocused: true
4+
5+
@notifyInTitleIfRequired: ->
6+
$(document).attr('title', '(new) Kandan') if @browserTabFocused != true
7+
38
@months: [
49
"January"
510
,"February"

‎app/assets/javascripts/backbone/kandan.js.coffee

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ window.Kandan =
3939
action: data.event.split("#")[1]
4040
})
4141

42+
$(window).focus(->
43+
Kandan.Helpers.Utils.browserTabFocused = true
44+
$(document).attr('title', 'Kandan')
45+
)
46+
47+
$(window).blur(->
48+
Kandan.Helpers.Utils.browserTabFocused = false
49+
)
50+
51+
4252
initBroadcasterAndSubscribe: ()->
4353
Kandan.broadcaster = new Kandan.Broadcasters.FayeBroadcaster()
4454
Kandan.broadcaster.subscribe "/channels/*"

0 commit comments

Comments
 (0)
Please sign in to comment.