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
fd1e91ae
Commit
fd1e91ae
authored
Aug 02, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display show comments button
parent
1e7e2f25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
28 deletions
+34
-28
lms/static/coffee/src/discussion.coffee
+33
-27
lms/templates/discussion/_thread.html
+1
-1
No files found.
lms/static/coffee/src/discussion.coffee
View file @
fd1e91ae
...
...
@@ -16,7 +16,6 @@ $ ->
Discussion
.
initializeDiscussion
(
discussion
)
Discussion
.
bindDiscussionEvents
(
discussion
)
generateLocal
=
(
elem
)
->
(
selector
)
->
$
(
elem
).
find
(
selector
)
...
...
@@ -104,6 +103,14 @@ Discussion =
retrieve_single_thread
:
"/courses/
#{
$$course_id
}
/discussion/forum/
#{
param
}
/threads/
#{
param1
}
"
}[
name
]
safeAjax
:
(
params
)
->
$elem
=
params
.
$elem
if
$elem
.
attr
(
"disabled"
)
return
$elem
.
attr
(
"disabled"
,
"disabled"
)
$
.
ajax
(
params
).
always
->
$elem
.
removeAttr
(
"disabled"
)
handleAnchorAndReload
:
(
response
)
->
#window.location = window.location.pathname + "#" + response['id']
window
.
location
.
reload
()
...
...
@@ -113,13 +120,10 @@ Discussion =
$local
=
generateLocal
(
$discussionModule
)
handleShowDiscussion
=
(
elem
)
->
$elem
=
$
(
elem
)
if
$elem
.
attr
(
"disabled"
)
return
if
not
$local
(
"section.discussion"
).
length
$elem
.
attr
(
"disabled"
,
"disabled"
)
discussion_id
=
$elem
.
attr
(
"discussion_id"
)
url
=
Discussion
.
urlFor
'retrieve_discussion'
,
discussion_id
$
.
ajax
(
Discussion
.
safeAjax
url
:
url
method
:
"GET"
success
:
(
data
,
textStatus
,
xhr
)
->
...
...
@@ -131,14 +135,12 @@ Discussion =
$elem
.
unbind
(
'click'
).
click
->
handleHideDiscussion
(
this
)
dataType
:
'html'
).
always
->
$elem
.
removeAttr
(
"disabled"
)
else
$local
(
"section.discussion"
).
show
()
$elem
.
html
(
"Hide Discussion"
)
$elem
.
unbind
(
'click'
).
click
->
handleHideDiscussion
(
this
)
handleHideDiscussion
=
(
elem
)
->
$local
(
"section.discussion"
).
hide
()
$elem
=
$
(
elem
)
...
...
@@ -381,25 +383,32 @@ Discussion =
,
'json'
handleHideSingleThread
=
(
elem
)
->
$elem
=
$
(
elem
)
$threadTitle
=
$local
(
".thread-title"
)
$showComments
=
$local
(
".discussion-show-comments"
)
$content
.
children
(
".comments"
).
hide
()
$elem
.
unbind
(
'click'
).
click
->
handleShowSingleThread
(
this
)
$threadTitle
.
unbind
(
'click'
).
click
handleShowSingleThread
$showComments
.
unbind
(
'click'
).
click
handleShowSingleThread
prevHtml
=
$showComments
.
html
()
$showComments
.
html
prevHtml
.
replace
"Hide"
,
"Show"
handleShowSingleThread
=
->
$threadTitle
=
$local
(
".thread-title"
)
$showComments
=
$local
(
".discussion-show-comments"
)
rebindHideEvents
=
->
$threadTitle
.
unbind
(
'click'
).
click
handleHideSingleThread
$showComments
.
unbind
(
'click'
).
click
handleHideSingleThread
prevHtml
=
$showComments
.
html
()
$showComments
.
html
prevHtml
.
replace
"Show"
,
"Hide"
handleShowSingleThread
=
(
elem
)
->
$elem
=
$
(
elem
)
if
$elem
.
attr
(
"disabled"
)
return
if
$content
.
children
(
".comments"
).
length
$content
.
children
(
".comments"
).
show
()
$elem
.
unbind
(
'click'
).
click
->
handleHideSingleThread
(
this
)
rebindHideEvents
()
else
$elem
.
attr
(
"disabled"
,
"disabled"
)
discussion_id
=
$elem
.
parents
(
".discussion"
).
attr
(
"_id"
)
discussion_id
=
$threadTitle
.
parents
(
".discussion"
).
attr
(
"_id"
)
url
=
Discussion
.
urlFor
(
'retrieve_single_thread'
,
discussion_id
,
id
)
console
.
log
url
$
.
ajax
(
Discussion
.
safeAjax
$elem
:
$
.
merge
(
$threadTitle
,
$showComments
)
url
:
url
method
:
"GET"
success
:
(
response
,
textStatus
)
->
...
...
@@ -412,15 +421,12 @@ Discussion =
$content
.
find
(
".comment"
).
each
(
index
,
comment
)
->
Discussion
.
initializeContent
(
comment
)
Discussion
.
bindContentEvents
(
comment
)
$elem
.
unbind
(
'click'
).
click
->
handleHideSingleThread
(
this
)
rebindHideEvents
()
dataType
:
'json'
).
always
->
$elem
.
removeAttr
(
"disabled"
)
$local
(
".thread-title"
).
click
->
handleShowSingleThread
(
this
)
$local
(
".thread-title"
).
click
handleShowSingleThread
$local
(
".discussion-show-comments"
).
click
handleShowSingleThread
$local
(
".discussion-reply"
).
click
->
handleShowSingleThread
(
$local
(
".thread-title"
))
...
...
lms/templates/discussion/_thread.html
View file @
fd1e91ae
...
...
@@ -93,7 +93,7 @@
user No.${content['user_id']}
% endif
% if content.get('comments_count', -1) >= 0:
, ${content['comments_count']} comment(s)
,
<a
href=
"javascript:void(0)"
class=
"discussion-show-comments"
>
Show ${content['comments_count']} comment(s)
</a>
% endif
</
%
def>
...
...
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