Commit 4dae36cd by Rocky Duan

only execude code when backbone is defined

parent 45431ae7
class @Content extends Backbone.Model if Backbone?
class @Content extends Backbone.Model
template: -> DiscussionUtil.getTemplate('_content') template: -> DiscussionUtil.getTemplate('_content')
...@@ -49,7 +50,7 @@ class @Content extends Backbone.Model ...@@ -49,7 +50,7 @@ class @Content extends Backbone.Model
@resetComments(@get('children')) @resetComments(@get('children'))
class @ContentView extends Backbone.View class @ContentView extends Backbone.View
$: (selector) -> $: (selector) ->
@$local.find(selector) @$local.find(selector)
...@@ -352,7 +353,7 @@ class @ContentView extends Backbone.View ...@@ -352,7 +353,7 @@ class @ContentView extends Backbone.View
@initBody() @initBody()
@initCommentViews() @initCommentViews()
class @Thread extends @Content class @Thread extends @Content
urlMappers: urlMappers:
'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id) 'retrieve' : -> DiscussionUtil.urlFor('retrieve_single_thread', @discussion.id, @id)
'reply' : -> DiscussionUtil.urlFor('create_comment', @id) 'reply' : -> DiscussionUtil.urlFor('create_comment', @id)
...@@ -373,9 +374,9 @@ class @Thread extends @Content ...@@ -373,9 +374,9 @@ class @Thread extends @Content
discussion_id = @get('commentable_id') discussion_id = @get('commentable_id')
return Discussion.urlFor("permanent_link_thread", discussion_id, @id) return Discussion.urlFor("permanent_link_thread", discussion_id, @id)
class @ThreadView extends @ContentView class @ThreadView extends @ContentView
class @Comment extends @Content class @Comment extends @Content
urlMappers: urlMappers:
'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id) 'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id)
'unvote': -> DiscussionUtil.urlFor("undo_vote_for_#{@get('type')}", @id) 'unvote': -> DiscussionUtil.urlFor("undo_vote_for_#{@get('type')}", @id)
...@@ -396,9 +397,9 @@ class @Comment extends @Content ...@@ -396,9 +397,9 @@ class @Comment extends @Content
count += comment.getCommentsCount() + 1 count += comment.getCommentsCount() + 1
count count
class @CommentView extends @ContentView class @CommentView extends @ContentView
class @Comments extends Backbone.Collection class @Comments extends Backbone.Collection
model: Comment model: Comment
......
class @Discussion extends Backbone.Collection if Backbone?
class @Discussion extends Backbone.Collection
model: Thread model: Thread
initialize: -> initialize: ->
...@@ -15,7 +16,7 @@ class @Discussion extends Backbone.Collection ...@@ -15,7 +16,7 @@ class @Discussion extends Backbone.Collection
@add model @add model
model model
class @DiscussionView extends Backbone.View class @DiscussionView extends Backbone.View
$: (selector) -> $: (selector) ->
@$local.find(selector) @$local.find(selector)
......
class @DiscussionModuleView extends Backbone.View if Backbone?
class @DiscussionModuleView extends Backbone.View
events: events:
"click .discussion-show": "toggleDiscussion" "click .discussion-show": "toggleDiscussion"
toggleDiscussion: (event) -> toggleDiscussion: (event) ->
......
...@@ -12,4 +12,5 @@ $ -> ...@@ -12,4 +12,5 @@ $ ->
discussion.reset(discussionData, {silent: false}) discussion.reset(discussionData, {silent: false})
view = new DiscussionView(el: elem, model: discussion) view = new DiscussionView(el: elem, model: discussion)
if window.$$annotated_content_info?
DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info) DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info)
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