Show current following status in list view.
This commit is contained in:
@@ -421,6 +421,12 @@ if Backbone?
|
||||
@set('thread', @)
|
||||
super()
|
||||
|
||||
follow: ->
|
||||
@trigger "thread:follow"
|
||||
|
||||
unfollow: ->
|
||||
@trigger "thread:unfollow"
|
||||
|
||||
class @ThreadView extends @ContentView
|
||||
|
||||
class @Comment extends @Content
|
||||
|
||||
@@ -44,8 +44,10 @@ class @DiscussionThreadView extends Backbone.View
|
||||
@$(".dogear").toggleClass("is-followed")
|
||||
url = null
|
||||
if @$(".dogear").hasClass("is-followed")
|
||||
@model.follow()
|
||||
url = @model.urlFor("follow")
|
||||
else
|
||||
@model.unfollow()
|
||||
url = @model.urlFor("unfollow")
|
||||
DiscussionUtil.safeAjax
|
||||
$elem: $elem
|
||||
|
||||
@@ -5,11 +5,17 @@ class @ThreadListItemView extends Backbone.View
|
||||
"click a": "threadSelected"
|
||||
initialize: ->
|
||||
@model.on "change", @render
|
||||
@model.on "thread:follow", @follow
|
||||
@model.on "thread:unfollow", @unfollow
|
||||
render: =>
|
||||
@$el.html(@template(@model.toJSON()))
|
||||
if window.user.following(@model)
|
||||
@$("a").addClass("followed")
|
||||
@follow()
|
||||
@
|
||||
threadSelected: ->
|
||||
@trigger("thread:selected", @model.id)
|
||||
false
|
||||
follow: =>
|
||||
@$("a").addClass("followed")
|
||||
unfollow: =>
|
||||
@$("a").removeClass("followed")
|
||||
|
||||
Reference in New Issue
Block a user