Skip to content

Commit

Permalink
Moved nowThreshold and timestampRefreshInterval to kandan_settings.ym…
Browse files Browse the repository at this point in the history
…l for consistency.
  • Loading branch information
mjtko committed Mar 14, 2013
1 parent d92fb81 commit d4a857f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
11 changes: 3 additions & 8 deletions app/assets/javascripts/backbone/kandan.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ window.Kandan =
Plugins: {}

options: ->
unless @_options?
@_options = $('body').data('kandan-config')
@_options.nowThreshold = 3000
@_options.timestampRefreshInterval = 2000
return @_options

@_options ?= $('body').data('kandan-config')

# TODO this is a helper method to register plugins
# in the order required until we come up with plugin management
Expand Down Expand Up @@ -133,8 +128,8 @@ window.Kandan =
registerUtilityEvents: ()->
window.setInterval(=>
for el in $(".posted_at")
$(el).text (new Date($(el).data("timestamp"))).toRelativeTime(@options().nowThreshold)
, @options().timestampRefreshInterval)
$(el).text (new Date($(el).data("timestamp"))).toRelativeTime(@options().now_threshold)
, @options().timestamp_refresh_interval)

init: ->
channels = new Kandan.Collections.Channels()
Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/activity_base.jst.eco
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class="posted_at">
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().nowThreshold) %>
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().now_threshold) %>
</span>
<img class="avatar" src="<%= @activity.avatarUrl %>"/>

Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/message.jst.eco
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class="posted_at">
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().nowThreshold) %>
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().now_threshold) %>
</span>
<img class="avatar" src="<%= @activity.avatarUrl %>"/>

Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/user_notification.jst.eco
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class="posted_at">
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().nowThreshold) %>
<%= new Date(@activity.created_at).toRelativeTime(Kandan.options().now_threshold) %>
</span>
<img class="avatar" src="<%= @activity.avatarUrl %>"/>

Expand Down
3 changes: 3 additions & 0 deletions config/kandan_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

:avatar_url: http://gravatar.com/avatar/%{hash}?s=%{size}&d=%{fallback}
:avatar_fallback: identicon

:now_threshold: 3000
:timestamp_refresh_interval: 2000

0 comments on commit d4a857f

Please sign in to comment.