Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3a254380
Commit
3a254380
authored
Aug 29, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hook up comment counts
parent
f683d375
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
lms/static/coffee/src/discussion/models/discussion_user.coffee
+3
-6
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+4
-0
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
+3
-0
lms/static/coffee/src/discussion/views/thread_response_view.coffee
+18
-0
No files found.
lms/static/coffee/src/discussion/models/discussion_user.coffee
View file @
3a254380
class
@
DiscussionUser
constructor
:
(
content_info
)
->
@
content_info
=
content_info
class
@
DiscussionUser
extends
Backbone
.
Model
following
:
(
thread
)
->
_
.
include
(
@
content_info
[
'subscribed_thread_ids'
]
,
thread
.
id
)
_
.
include
(
@
get
(
'subscribed_thread_ids'
)
,
thread
.
id
)
voted
:
(
thread
)
->
_
.
include
(
@
content_info
[
'upvoted_ids'
]
,
thread
.
id
)
_
.
include
(
@
get
(
'upvoted_ids'
)
,
thread
.
id
)
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
3a254380
...
...
@@ -28,9 +28,13 @@ class @DiscussionThreadView extends Backbone.View
renderResponse
:
(
response
)
=>
view
=
new
ThreadResponseView
(
model
:
response
)
view
.
on
"comment:add"
,
@
addComment
view
.
render
()
@
$
(
".responses"
).
append
(
view
.
el
)
addComment
:
=>
@
model
.
trigger
"comment:add"
toggleVote
:
->
@
$
(
".vote-btn"
).
toggleClass
(
"is-cast"
)
if
@
$
(
".vote-btn"
).
hasClass
(
"is-cast"
)
...
...
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
View file @
3a254380
...
...
@@ -7,6 +7,7 @@ class @ThreadListItemView extends Backbone.View
@
model
.
on
"change"
,
@
render
@
model
.
on
"thread:follow"
,
@
follow
@
model
.
on
"thread:unfollow"
,
@
unfollow
@
model
.
on
"comment:add"
,
@
addComment
render
:
=>
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
if
window
.
user
.
following
(
@
model
)
...
...
@@ -19,3 +20,5 @@ class @ThreadListItemView extends Backbone.View
@
$
(
"a"
).
addClass
(
"followed"
)
unfollow
:
=>
@
$
(
"a"
).
removeClass
(
"followed"
)
addComment
:
=>
@
$
(
".comments-count"
).
html
(
parseInt
(
@
$
(
".comments-count"
).
html
())
+
1
)
lms/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
3a254380
...
...
@@ -3,6 +3,8 @@ class @ThreadResponseView extends Backbone.View
template
:
_
.
template
(
$
(
"#thread-response-template"
).
html
())
events
:
"click .vote-btn"
:
"toggleVote"
"submit form"
:
"submitComment"
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
if
window
.
user
.
voted
(
@
model
)
...
...
@@ -48,3 +50,19 @@ class @ThreadResponseView extends Backbone.View
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
submitComment
:
->
url
=
@
model
.
urlFor
(
'reply'
)
body
=
@
$
(
".comment-form-input"
).
val
()
comment
=
new
Comment
(
body
:
body
,
created_at
:
(
new
Date
()).
toISOString
(),
username
:
window
.
user
.
get
(
"username"
))
@
renderComment
(
comment
)
@
trigger
"comment:add"
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
url
:
url
type
:
"POST"
dataType
:
'json'
data
:
body
:
body
false
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment