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
10887ab1
Commit
10887ab1
authored
Sep 04, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix voting.
parent
00abf08d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
15 deletions
+39
-15
lms/static/coffee/src/discussion/content.coffee
+8
-0
lms/static/coffee/src/discussion/models/discussion_user.coffee
+8
-0
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+22
-14
lms/templates/discussion/_underscore_templates.html
+1
-1
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
10887ab1
...
...
@@ -447,6 +447,14 @@ if Backbone?
@
set
(
'subscribed'
,
false
)
@
trigger
"thread:unfollow"
vote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
+
1
@
trigger
"change"
unvote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
trigger
"change"
display_body
:
->
if
@
has
(
"highlighted_body"
)
String
(
@
get
(
"highlighted_body"
)).
replace
(
/<highlight>/g
,
'<mark>'
).
replace
(
/<\/highlight>/g
,
'</mark>'
)
...
...
lms/static/coffee/src/discussion/models/discussion_user.coffee
View file @
10887ab1
...
...
@@ -4,3 +4,11 @@ class @DiscussionUser extends Backbone.Model
voted
:
(
thread
)
->
_
.
include
(
@
get
(
'upvoted_ids'
),
thread
.
id
)
vote
:
(
thread
)
->
@
get
(
'upvoted_ids'
).
push
(
thread
.
id
)
thread
.
vote
()
unvote
:
(
thread
)
->
@
set
(
'upvoted_ids'
,
_
.
without
(
@
get
(
'upvoted_ids'
),
thread
.
id
))
thread
.
unvote
()
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
10887ab1
...
...
@@ -22,22 +22,32 @@ class @DiscussionThreadView extends DiscussionContentView
template
:
_
.
template
(
$
(
"#thread-template"
).
html
())
initialize
:
->
@
model
.
on
"change"
,
@
updateModelDetails
render
:
->
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
@
model
.
bind
"change"
,
@
updateModelDetails
if
window
.
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
if
window
.
user
.
voted
(
@
model
)
@
$
(
".vote-btn"
).
addClass
(
"is-cast"
)
@
renderDogear
()
@
renderVoted
()
@
$
(
"span.timeago"
).
timeago
()
Markdown
.
makeWmdEditor
@
$
(
".reply-body"
),
""
,
DiscussionUtil
.
urlFor
(
"upload"
),
(
text
)
->
DiscussionUtil
.
postMathJaxProcessor
(
text
)
@
convertMath
()
@
renderResponses
()
@
renderDogear
:
->
if
window
.
user
.
following
(
@
model
)
@
$
(
".dogear"
).
addClass
(
"is-followed"
)
renderVoted
:
=>
if
window
.
user
.
voted
(
@
model
)
@
$
(
"[data-role=discussion-vote]"
).
addClass
(
"is-cast"
)
else
@
$
(
"[data-role=discussion-vote]"
).
removeClass
(
"is-cast"
)
updateModelDetails
:
=>
@
$
(
".discussion-vote .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
@
renderVoted
()
@
$
(
"[data-role=discussion-vote] .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
convertMath
:
->
element
=
@
$
(
".post-body"
)
...
...
@@ -64,10 +74,10 @@ class @DiscussionThreadView extends DiscussionContentView
toggleVote
:
(
event
)
->
event
.
preventDefault
()
if
not
@
model
.
get
(
'voted'
)
#@$(".discussion-vote").hasClass("is-cast")
@
vote
()
else
if
window
.
user
.
voted
(
@
model
)
@
unvote
()
else
@
vote
()
toggleFollowing
:
(
event
)
->
$elem
=
$
(
event
.
target
)
...
...
@@ -84,9 +94,8 @@ class @DiscussionThreadView extends DiscussionContentView
type
:
"POST"
vote
:
->
window
.
user
.
vote
(
@
model
)
url
=
@
model
.
urlFor
(
"upvote"
)
@
model
.
set
(
'votes_point'
,
parseInt
(
@
model
.
get
(
'votes_point'
))
+
1
)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) + 1)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
...
...
@@ -96,9 +105,8 @@ class @DiscussionThreadView extends DiscussionContentView
@
model
.
set
(
response
)
unvote
:
->
window
.
user
.
unvote
(
@
model
)
url
=
@
model
.
urlFor
(
"unvote"
)
@
model
.
set
(
'votes_point'
,
parseInt
(
@
model
.
get
(
'votes_point'
))
-
1
)
#@$(".discussion-vote .votes-count-number").html(parseInt(@$(".discussion-vote .votes-count-number").html()) - 1)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-vote"
)
url
:
url
...
...
lms/templates/discussion/_underscore_templates.html
View file @
10887ab1
...
...
@@ -3,7 +3,7 @@
<
a
href
=
"javascript:void(0)"
class
=
"dogear action-follow"
><
/a
>
<
div
class
=
"discussion-post"
>
<
header
>
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
><
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
data
-
role
=
"discussion-vote"
><
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
<
h1
>
$
{
'<%- title %>'
}
<
/h1
>
<
p
class
=
"posted-details"
>
<
span
class
=
"timeago"
title
=
"${'<%- created_at %>'}"
>
$
{
'<%- created_at %>'
}
<
/span> b
y
...
...
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