Skip to content

Commit

Permalink
Keep track of the unread activities for display in the browser tab
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed Apr 11, 2012
1 parent 43365db commit c21ed2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/backbone/helpers/utils.js.coffee
@@ -1,9 +1,12 @@
class Kandan.Helpers.Utils
@unreadActivities = 0

@browserTabFocused: true

@notifyInTitleIfRequired: ->
$(document).attr('title', '(new) Kandan') if @browserTabFocused != true
if @browserTabFocused != true
@unreadActivities += 1
$(document).attr('title', "(#{@unreadActivities}) Kandan")

@months: [
"January"
Expand All @@ -20,6 +23,9 @@ class Kandan.Helpers.Utils
,"December"
]

@resetUnreadActivities: () ->
@unreadActivities = 0

@time_to_string: (time) ->
return time if (typeof time != "object")
am = time.getHours() < 12
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Expand Up @@ -41,6 +41,7 @@ window.Kandan =

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

Expand Down

0 comments on commit c21ed2b

Please sign in to comment.