Commit d6bece9b by Matthew Mongeau

Move user to window. Mark followed threads in list view.

parent 4735ce0a
......@@ -4,7 +4,6 @@ class @DiscussionRouter extends Backbone.Router
":forum_name/threads/:thread_id" : "showThread"
initialize: (options) ->
@user = options['user']
@discussion = options['discussion']
@nav = new DiscussionThreadListView(collection: @discussion, el: $(".post-list"))
@nav.on "thread:selected", @navigateToThread
......@@ -16,7 +15,7 @@ class @DiscussionRouter extends Backbone.Router
showThread: (forum_name, thread_id) ->
@nav.setActiveThread(thread_id)
thread = @discussion.get(thread_id)
view = new DiscussionThreadView(el: $(".discussion-column"), model: thread, user: @user)
view = new DiscussionThreadView(el: $(".discussion-column"), model: thread)
view.render()
navigateToThread: (thread_id) =>
......
......@@ -5,7 +5,6 @@ class @DiscussionThreadView extends Backbone.View
template: _.template($("#thread-template").html())
initialize: (options) ->
@user = options['user']
@model.bind "change", @updateModelDetails
@$el.html(@template(@model.toJSON()))
......@@ -13,10 +12,10 @@ class @DiscussionThreadView extends Backbone.View
@$(".votes-count-number").html(@model.get("votes")["up_count"])
render: ->
if @user.following(@model)
if window.user.following(@model)
@$(".dogear").addClass("is-followed")
if @user.voted(@model)
if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast")
@$("span.timeago").timeago()
@renderResponses()
......
......@@ -7,6 +7,8 @@ class @ThreadListItemView extends Backbone.View
@model.on "change", @render
render: =>
@$el.html(@template(@model.toJSON()))
if window.user.following(@model)
@$("a").addClass("followed")
@
threadSelected: ->
@trigger("thread:selected", @model.id)
......
......@@ -143,10 +143,10 @@
$$contents = {}
$$discussions = {}
$(document).ready(function() {
var user = new DiscussionUser(JSON.parse("${user_info | escapejs}"));
window.user = new DiscussionUser(JSON.parse("${user_info | escapejs}"));
var discussion = new Discussion(JSON.parse("${threads | escapejs}"));
var app = new DiscussionRouter({user: user, discussion: discussion})
var app = new DiscussionRouter({discussion: discussion})
Backbone.history.start({pushState: true, root: "/courses/${course_id}/discussion/forum/"})
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment