@@ -16,13 +16,12 @@ window.Kandan =
16
16
Data : {}
17
17
Plugins : {}
18
18
19
- options:
20
- broadcaster: "<%= Kandan::Config.options[:broadcaster][:name] %> "
21
- perPage : <%= Kandan::Config.options[:per_page] %>
22
- nowThreshold: 3000
23
- timestampRefreshInterval: 2000
24
- avatarUrl: "<%= Kandan::Config.options[:avatar_url] %> "
25
- avatarFallback: "<%= Kandan::Config.options[:avatar_fallback] %> "
19
+ options : ->
20
+ unless @_options ?
21
+ @_options = $ (' body' ).data (' kandan-config' )
22
+ @_options .nowThreshold = 3000
23
+ @_options .timestampRefreshInterval = 2000
24
+ return @_options
26
25
27
26
28
27
# TODO this is a helper method to register plugins
@@ -69,7 +68,7 @@ window.Kandan =
69
68
70
69
71
70
initBroadcasterAndSubscribe : ()->
72
- Kandan.broadcaster = eval "new Kandan.Broadcasters.#{@options.broadcaster}Broadcaster()"
71
+ Kandan .broadcaster = eval " new Kandan.Broadcasters.#{ @ options () .broadcaster . name } Broadcaster()"
73
72
Kandan .broadcaster .subscribe " /channels/*"
74
73
@ registerAppEvents ()
75
74
@@ -80,10 +79,10 @@ window.Kandan =
80
79
81
80
$ (document ).data (' active-channel-id' ,
82
81
Kandan .Helpers .Channels .getChannelIdByTabIndex (ui .index ))
83
-
84
- #the need for the delay feels hacky to me.
82
+
83
+ # the need for the delay feels hacky to me.
85
84
# It is there because the chat area has to render before scrollHeight can be determined.
86
- theId = Kandan.Helpers.Channels.getActiveChannelId()
85
+ theId = Kandan .Helpers .Channels .getActiveChannelId ()
87
86
delay = (ms , func ) -> setTimeout func, ms
88
87
delay 1 , -> Kandan .Helpers .Channels .scrollToLatestMessage (theId)
89
88
Kandan .Data .Channels .runCallbacks (' change' )
@@ -134,8 +133,8 @@ window.Kandan =
134
133
registerUtilityEvents : ()->
135
134
window .setInterval (=>
136
135
for el in $ (" .posted_at" )
137
- $(el).text (new Date($(el).data("timestamp"))).toRelativeTime(@options.nowThreshold)
138
- , @options.timestampRefreshInterval)
136
+ $ (el).text (new Date ($ (el).data (" timestamp" ))).toRelativeTime (@ options () .nowThreshold )
137
+ , @ options () .timestampRefreshInterval )
139
138
140
139
init : ->
141
140
channels = new Kandan.Collections.Channels ()
0 commit comments