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
d6b77077
Commit
d6b77077
authored
Jul 30, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored reply rendering by using mustache
parent
e705bbb7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
33 deletions
+25
-33
common/static/js/vendor/mustache.js
+0
-0
lms/static/coffee/src/discussion.coffee
+22
-31
lms/static/sass/_discussion.scss
+2
-2
lms/templates/discussion/_js_dependencies.html
+1
-0
No files found.
common/static/js/vendor/mustache.js
0 → 100644
View file @
d6b77077
This diff is collapsed.
Click to expand it.
lms/static/coffee/src/discussion.coffee
View file @
d6b77077
...
...
@@ -25,6 +25,19 @@ generateDiscussionLink = (cls, txt, handler) ->
Discussion
=
replyTemplate
:
"""
<div class="discussion-reply-new">
<ul class="discussion-errors"></ul>
<div class="reply-body"></div>
<input type="checkbox" class="discussion-post-anonymously" id="discussion-post-anonymously-{{id}}" />
<label for="discussion-post-anonymously-{{id}}">post anonymously</label>
{{#showWatchCheckbox}}
<input type="checkbox" class="discussion-auto-watch" id="discussion-autowatch-{{id}}" checked />
<label for="discussion-auto-watch-{{id}}">watch this thread</label>
{{/showWatchCheckbox}}
</div>
"""
urlFor
:
(
name
,
param
)
->
{
watch_commentable
:
"/courses/
#{
$$course_id
}
/discussion/
#{
param
}
/watch"
...
...
@@ -162,38 +175,16 @@ Discussion =
$discussionContent
.
hover
(
discussionContentHoverIn
,
discussionContentHoverOut
)
handleReply
=
(
elem
)
->
editView
=
$local
(
".discussion-
content-edit
"
)
editView
=
$local
(
".discussion-
reply-new
"
)
if
editView
.
length
editView
.
show
()
else
editView
=
$
(
"<div>"
).
addClass
(
"discussion-content-edit"
)
errorsField
=
$
(
"<ul>"
).
addClass
(
"discussion-errors"
)
editView
.
append
(
errorsField
)
textarea
=
$
(
"<div>"
).
addClass
(
"comment-edit"
)
editView
.
append
(
textarea
)
anonymousCheckbox
=
$
(
"<input>"
).
attr
(
"type"
,
"checkbox"
)
.
addClass
(
"discussion-post-anonymously"
)
.
attr
(
"id"
,
"discussion-post-anonymously-
#{
id
}
"
)
anonymousLabel
=
$
(
"<label>"
).
attr
(
"for"
,
"discussion-post-anonymously-
#{
id
}
"
)
.
html
(
"post anonymously"
)
editView
.
append
(
anonymousCheckbox
).
append
(
anonymousLabel
)
if
$discussionContent
.
parent
(
".thread"
).
attr
(
"_id"
)
not
in
$$user_info
.
subscribed_thread_ids
watchCheckbox
=
$
(
"<input>"
).
attr
(
"type"
,
"checkbox"
)
.
addClass
(
"discussion-auto-watch"
)
.
attr
(
"id"
,
"discussion-auto-watch-
#{
id
}
"
)
.
attr
(
"checked"
,
""
)
watchLabel
=
$
(
"<label>"
).
attr
(
"for"
,
"discussion-auto-watch-
#{
id
}
"
)
.
html
(
"watch this thread"
)
editView
.
append
(
watchCheckbox
).
append
(
watchLabel
)
$discussionContent
.
append
(
editView
)
Markdown
.
makeWmdEditor
$local
(
".comment-edit"
),
"-comment-edit-
#{
id
}
"
,
Discussion
.
urlFor
(
'upload'
)
view
=
{
id
:
id
showWatchCheckbox
:
$discussionContent
.
parent
(
".thread"
).
attr
(
"_id"
)
not
in
$$user_info
.
subscribed_thread_ids
}
$discussionContent
.
append
Mustache
.
render
Discussion
.
replyTemplate
,
view
Markdown
.
makeWmdEditor
$local
(
".reply-body"
),
"-reply-body-
#{
id
}
"
,
Discussion
.
urlFor
(
'upload'
)
cancelReply
=
generateDiscussionLink
(
"discussion-cancel-reply"
,
"Cancel"
,
handleCancelReply
)
submitReply
=
generateDiscussionLink
(
"discussion-submit-reply"
,
"Submit"
,
handleSubmitReply
)
$local
(
".discussion-link"
).
hide
()
...
...
@@ -201,7 +192,7 @@ Discussion =
$discussionContent
.
attr
(
"status"
,
"reply"
)
handleCancelReply
=
(
elem
)
->
editView
=
$local
(
".discussion-
content-edit
"
)
editView
=
$local
(
".discussion-
reply-new
"
)
if
editView
.
length
editView
.
hide
()
$local
(
".discussion-submit-reply"
).
remove
()
...
...
@@ -218,7 +209,7 @@ Discussion =
else
return
body
=
$local
(
"#wmd-input-
comment-edit
-
#{
id
}
"
).
val
()
body
=
$local
(
"#wmd-input-
reply-body
-
#{
id
}
"
).
val
()
anonymous
=
false
||
$local
(
".discussion-post-anonymously"
).
is
(
":checked"
)
autowatch
=
false
||
$local
(
".discussion-auto-watch"
).
is
(
":checked"
)
...
...
lms/static/sass/_discussion.scss
View file @
d6b77077
...
...
@@ -193,9 +193,9 @@ $discussion_input_width: 85%;
.discussion-content
{
margin-top
:
10px
;
overflow
:
hidden
;
.discussion-
content-edit
{
.discussion-
reply-new
{
margin-left
:
$comment_margin_left
;
.
comment-edit
{
.
reply-body
{
@include
discussion-font
;
width
:
$discussion_input_width
!
important
;
font-size
:
$comment_body_size
;
...
...
lms/templates/discussion/_js_dependencies.html
View file @
d6b77077
...
...
@@ -26,5 +26,6 @@
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/Markdown.Editor.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.autocomplete.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.tagsinput.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/mustache.js')}"
></script>
<link
href=
"${static.url('css/vendor/jquery.tagsinput.css')}"
rel=
"stylesheet"
type=
"text/css"
>
<link
href=
"${static.url('css/vendor/jquery.autocomplete.css')}"
rel=
"stylesheet"
type=
"text/css"
>
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