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
3c681a20
Commit
3c681a20
authored
Aug 03, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed vote bug
parent
6f798fd1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
64 deletions
+59
-64
lms/static/coffee/src/discussion/content.coffee
+19
-0
lms/static/coffee/src/discussion/discussion.coffee
+8
-64
lms/static/coffee/src/discussion/utils.coffee
+32
-0
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
3c681a20
...
...
@@ -3,6 +3,22 @@ if not @Discussion?
Discussion
=
@
Discussion
initializeVote
=
(
content
)
->
$content
=
$
(
content
)
$local
=
Discussion
.
generateLocal
(
$content
.
children
(
".discussion-content"
))
id
=
$content
.
attr
(
"_id"
)
if
Discussion
.
isUpvoted
id
$local
(
".discussion-vote-up"
).
addClass
(
"voted"
)
else
if
Discussion
.
isDownvoted
id
$local
(
".discussion-vote-down"
).
addClass
(
"voted"
)
initializeFollowThread
=
(
thread
)
->
$thread
=
$
(
thread
)
id
=
$thread
.
attr
(
"_id"
)
$thread
.
children
(
".discussion-content"
)
.
find
(
".follow-wrapper"
)
.
append
(
Discussion
.
subscriptionLink
(
'thread'
,
id
))
@
Discussion
=
$
.
extend
@
Discussion
,
bindContentEvents
:
(
content
)
->
...
...
@@ -265,6 +281,9 @@ Discussion = @Discussion
initializeContent
:
(
content
)
->
$content
=
$
(
content
)
initializeVote
$content
if
$content
.
hasClass
(
"thread"
)
initializeFollowThread
$content
$local
=
Discussion
.
generateLocal
(
$content
.
children
(
".discussion-content"
))
$contentBody
=
$local
(
".content-body"
)
raw_text
=
$contentBody
.
html
()
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
3c681a20
...
...
@@ -3,75 +3,27 @@ if not @Discussion?
Discussion
=
@
Discussion
initializeVote
=
(
index
,
content
)
->
$content
=
$
(
content
)
$local
=
Discussion
.
generateLocal
(
$content
.
children
(
".discussion-content"
))
id
=
$content
.
attr
(
"_id"
)
if
Discussion
.
isUpvoted
id
$local
(
".discussion-vote-up"
).
addClass
(
"voted"
)
else
if
Discussion
.
isDownvoted
id
$local
(
".discussion-vote-down"
).
addClass
(
"voted"
)
subscriptionLink
=
(
type
,
id
)
->
followLink
=
->
Discussion
.
generateDiscussionLink
(
"discussion-follow-
#{
type
}
"
,
"Follow"
,
handleFollow
)
unfollowLink
=
->
Discussion
.
generateDiscussionLink
(
"discussion-unfollow-
#{
type
}
"
,
"Unfollow"
,
handleUnfollow
)
handleFollow
=
(
elem
)
->
Discussion
.
safeAjax
$elem
:
$
(
elem
)
url
:
Discussion
.
urlFor
(
"follow_
#{
type
}
"
,
id
)
type
:
"POST"
success
:
(
response
,
textStatus
)
->
if
textStatus
==
"success"
$
(
elem
).
replaceWith
unfollowLink
()
dataType
:
'json'
handleUnfollow
=
(
elem
)
->
Discussion
.
safeAjax
$elem
:
$
(
elem
)
url
:
Discussion
.
urlFor
(
"unfollow_
#{
type
}
"
,
id
)
type
:
"POST"
success
:
(
response
,
textStatus
)
->
if
textStatus
==
"success"
$
(
elem
).
replaceWith
followLink
()
dataType
:
'json'
if
Discussion
.
isSubscribed
(
id
,
type
)
unfollowLink
()
else
followLink
()
initializeFollowDiscussion
=
(
discussion
)
->
$discussion
=
$
(
discussion
)
id
=
$following
.
attr
(
"_id"
)
$local
=
Discussion
.
generateLocal
()
$discussion
.
children
(
".discussion-non-content"
)
.
find
(
".discussion-title-wrapper"
)
.
append
(
subscriptionLink
(
'discussion'
,
id
))
initializeFollowThread
=
(
index
,
thread
)
->
$thread
=
$
(
thread
)
id
=
$thread
.
attr
(
"_id"
)
$thread
.
children
(
".discussion-content"
)
.
find
(
".follow-wrapper"
)
.
append
(
subscriptionLink
(
'thread'
,
id
))
.
append
(
Discussion
.
subscriptionLink
(
'discussion'
,
id
))
@
Discussion
=
$
.
extend
@
Discussion
,
initializeDiscussion
:
(
discussion
)
->
$discussion
=
$
(
discussion
)
$discussion
.
find
(
".thread"
).
each
(
index
,
thread
)
->
Discussion
.
initializeContent
(
thread
)
Discussion
.
bindContentEvents
(
thread
)
$discussion
.
find
(
".comment"
).
each
(
index
,
comment
)
->
Discussion
.
initializeContent
(
comment
)
Discussion
.
bindContentEvents
(
comment
)
$local
=
Discussion
.
generateLocal
(
discussion
)
$local
(
".comment"
).
each
(
initializeVote
)
$local
(
".thread"
).
each
(
initializeVote
).
each
(
initializeFollowThread
)
#initializeFollowDiscussion(discussion) TODO move this somewhere else
$local
(
".new-post-tags"
).
tagsInput
Discussion
.
tagsInputOptions
()
bindDiscussionEvents
:
(
discussion
)
->
$discussion
=
$
(
discussion
)
...
...
@@ -189,11 +141,3 @@ initializeFollowThread = (index, thread) ->
"click .discussion-inline-sort-link"
:
->
handleAjaxSort
(
this
)
$discussion
.
find
(
".thread"
).
each
(
index
,
thread
)
->
Discussion
.
initializeContent
(
thread
)
Discussion
.
bindContentEvents
(
thread
)
$discussion
.
find
(
".comment"
).
each
(
index
,
comment
)
->
Discussion
.
initializeContent
(
comment
)
Discussion
.
bindContentEvents
(
comment
)
lms/static/coffee/src/discussion/utils.coffee
View file @
3c681a20
...
...
@@ -132,3 +132,35 @@ wmdEditors = {}
if
not
window
.
$
$annotated_content_info
?
window
.
$
$annotated_content_info
=
{}
window
.
$
$annotated_content_info
=
$
.
extend
window
.
$
$annotated_content_info
,
newInfos
subscriptionLink
:
(
type
,
id
)
->
followLink
=
->
Discussion
.
generateDiscussionLink
(
"discussion-follow-
#{
type
}
"
,
"Follow"
,
handleFollow
)
unfollowLink
=
->
Discussion
.
generateDiscussionLink
(
"discussion-unfollow-
#{
type
}
"
,
"Unfollow"
,
handleUnfollow
)
handleFollow
=
(
elem
)
->
Discussion
.
safeAjax
$elem
:
$
(
elem
)
url
:
Discussion
.
urlFor
(
"follow_
#{
type
}
"
,
id
)
type
:
"POST"
success
:
(
response
,
textStatus
)
->
if
textStatus
==
"success"
$
(
elem
).
replaceWith
unfollowLink
()
dataType
:
'json'
handleUnfollow
=
(
elem
)
->
Discussion
.
safeAjax
$elem
:
$
(
elem
)
url
:
Discussion
.
urlFor
(
"unfollow_
#{
type
}
"
,
id
)
type
:
"POST"
success
:
(
response
,
textStatus
)
->
if
textStatus
==
"success"
$
(
elem
).
replaceWith
followLink
()
dataType
:
'json'
if
Discussion
.
isSubscribed
(
id
,
type
)
unfollowLink
()
else
followLink
()
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