Skip to content

Commit

Permalink
Adds notification in the windoe title if the window/tab is inactive
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 5, 2012
1 parent 0cc5d17 commit 6343d95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ class Kandan.Helpers.Channels
@scrollToLatestMessage(channelId) if @pastAutoScrollThreshold(channelId)



@add_message: (activityAttributes, state)->
@channel_activities_el(activityAttributes.channel_id)
.append(@new_activity_view(activityAttributes).render().el)
@flushActivities(activityAttributes.channel_id)
Kandan.Helpers.Utils.notifyInTitleIfRequired()
@set_pagination_data(activityAttributes.channel_id)


Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/backbone/helpers/utils.js.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
class Kandan.Helpers.Utils

@browserTabFocused: true

@notifyInTitleIfRequired: ->
$(document).attr('title', '(new) Kandan') if @browserTabFocused != true

@months: [
"January"
,"February"
Expand Down
10 changes: 10 additions & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ window.Kandan =
action: data.event.split("#")[1]
})

$(window).focus(->
Kandan.Helpers.Utils.browserTabFocused = true
$(document).attr('title', 'Kandan')
)

$(window).blur(->
Kandan.Helpers.Utils.browserTabFocused = false
)


initBroadcasterAndSubscribe: ()->
Kandan.broadcaster = new Kandan.Broadcasters.FayeBroadcaster()
Kandan.broadcaster.subscribe "/channels/*"
Expand Down

0 comments on commit 6343d95

Please sign in to comment.