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
7030d1f1
Commit
7030d1f1
authored
Aug 11, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed endorse&edit&delete
parent
2f469f0f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
62 deletions
+45
-62
lms/static/coffee/src/discussion/content.coffee
+9
-4
lms/static/coffee/src/discussion/discussion.coffee
+15
-13
lms/static/coffee/src/discussion/utils.coffee
+10
-4
lms/templates/discussion/_inline.html
+6
-38
lms/templates/discussion/_thread.html
+5
-3
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
7030d1f1
...
@@ -183,6 +183,8 @@ initializeFollowThread = (thread) ->
...
@@ -183,6 +183,8 @@ initializeFollowThread = (thread) ->
handleEndorse
=
(
elem
,
endorsed
)
->
handleEndorse
=
(
elem
,
endorsed
)
->
url
=
Discussion
.
urlFor
(
'endorse_comment'
,
id
)
url
=
Discussion
.
urlFor
(
'endorse_comment'
,
id
)
console
.
log
endorsed
console
.
log
url
Discussion
.
safeAjax
Discussion
.
safeAjax
$elem
:
$
(
elem
)
$elem
:
$
(
elem
)
url
:
url
url
:
url
...
@@ -196,6 +198,9 @@ initializeFollowThread = (thread) ->
...
@@ -196,6 +198,9 @@ initializeFollowThread = (thread) ->
else
else
$
(
content
).
removeClass
(
"endorsed"
)
$
(
content
).
removeClass
(
"endorsed"
)
$
(
elem
).
unbind
(
'click'
).
click
->
handleEndorse
(
elem
,
!
endorsed
)
handleOpenClose
=
(
elem
,
text
)
->
handleOpenClose
=
(
elem
,
text
)
->
url
=
Discussion
.
urlFor
(
'openclose_thread'
,
id
)
url
=
Discussion
.
urlFor
(
'openclose_thread'
,
id
)
closed
=
undefined
closed
=
undefined
...
@@ -314,19 +319,19 @@ initializeFollowThread = (thread) ->
...
@@ -314,19 +319,19 @@ initializeFollowThread = (thread) ->
else
else
handleVote
(
$elem
,
"down"
)
handleVote
(
$elem
,
"down"
)
"click .
discussio
n-endorse"
:
->
"click .
admi
n-endorse"
:
->
handleEndorse
(
this
,
$
(
this
).
is
(
":checked"
))
handleEndorse
(
this
,
true
)
#,
$(this).is(":checked"))
"click .discussion-openclose"
:
->
"click .discussion-openclose"
:
->
handleOpenClose
(
this
,
$
(
this
).
text
())
handleOpenClose
(
this
,
$
(
this
).
text
())
"click .
discussio
n-edit"
:
->
"click .
admi
n-edit"
:
->
if
$content
.
hasClass
(
"thread"
)
if
$content
.
hasClass
(
"thread"
)
handleEditThread
(
this
)
handleEditThread
(
this
)
else
else
handleEditComment
(
this
)
handleEditComment
(
this
)
"click .
discussio
n-delete"
:
->
"click .
admi
n-delete"
:
->
handleDelete
(
this
)
handleDelete
(
this
)
initializeContent
:
(
content
)
->
initializeContent
:
(
content
)
->
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
7030d1f1
...
@@ -36,7 +36,7 @@ initializeFollowDiscussion = (discussion) ->
...
@@ -36,7 +36,7 @@ initializeFollowDiscussion = (discussion) ->
title
=
$local
(
".new-post-title"
).
val
()
title
=
$local
(
".new-post-title"
).
val
()
body
=
Discussion
.
getWmdContent
$discussion
,
$local
,
"new-post-body"
body
=
Discussion
.
getWmdContent
$discussion
,
$local
,
"new-post-body"
tags
=
$local
(
".new-post-tags"
).
val
()
tags
=
$local
(
".new-post-tags"
).
val
()
url
=
Discussion
.
urlFor
(
'create_thread'
,
$local
(
".new-post-form"
).
attr
(
"_id"
)
)
url
=
Discussion
.
urlFor
(
'create_thread'
,
id
)
Discussion
.
safeAjax
Discussion
.
safeAjax
$elem
:
$
(
elem
)
$elem
:
$
(
elem
)
url
:
url
url
:
url
...
@@ -95,19 +95,19 @@ initializeFollowDiscussion = (discussion) ->
...
@@ -95,19 +95,19 @@ initializeFollowDiscussion = (discussion) ->
$wrapper
.
hide
()
$wrapper
.
hide
()
$title
.
attr
(
"prev-text"
,
text
)
$title
.
attr
(
"prev-text"
,
text
)
handleNewPost
=
(
elem
)
->
initializeNewPost
=
(
elem
)
->
newPostForm
=
$local
(
".new-post-form"
)
#newPostForm = $local(".new-post-form")
if
newPostForm
.
length
#view = { discussion_id: id }
newPostForm
.
show
()
#$newPostButton = $local(".discussion-new-post")
$
(
elem
).
hide
()
#$newPostButton.after Mustache.render Discussion.newPostTemplate, view
else
view
=
{
discussion_id
:
id
}
$newPostButton
=
$local
(
".discussion-new-post"
)
$newPostButton
.
after
Mustache
.
render
Discussion
.
newPostTemplate
,
view
newPostBody
=
$discussion
.
find
(
".new-post-body"
)
newPostBody
=
$discussion
.
find
(
".new-post-body"
)
if
newPostBody
.
length
if
newPostBody
.
length
Discussion
.
makeWmdEditor
$discussion
,
$local
,
"new-post-body"
Discussion
.
makeWmdEditor
$discussion
,
$local
,
"new-post-body"
$input
=
Discussion
.
getWmdInput
(
$discussion
,
$local
,
"new-post-body"
)
$input
.
attr
(
"placeholder"
,
"post a new topic..."
).
bind
'focus'
,
(
e
)
->
$local
(
".new-post-form"
).
removeClass
(
'collapsed'
)
$local
(
".new-post-tags"
).
tagsInput
Discussion
.
tagsInputOptions
()
$local
(
".new-post-tags"
).
tagsInput
Discussion
.
tagsInputOptions
()
$local
(
".new-post-title"
).
blur
->
$local
(
".new-post-title"
).
blur
->
...
@@ -121,7 +121,7 @@ initializeFollowDiscussion = (discussion) ->
...
@@ -121,7 +121,7 @@ initializeFollowDiscussion = (discussion) ->
$local
(
".discussion-cancel-post"
).
click
->
$local
(
".discussion-cancel-post"
).
click
->
handleCancelNewPost
(
this
)
handleCancelNewPost
(
this
)
$
(
elem
).
hide
()
#
$(elem).hide()
handleAjaxReloadDiscussion
=
(
elem
,
url
)
->
handleAjaxReloadDiscussion
=
(
elem
,
url
)
->
$elem
=
$
(
elem
)
$elem
=
$
(
elem
)
...
@@ -152,14 +152,16 @@ initializeFollowDiscussion = (discussion) ->
...
@@ -152,14 +152,16 @@ initializeFollowDiscussion = (discussion) ->
url
=
$elem
.
attr
(
"page-url"
)
url
=
$elem
.
attr
(
"page-url"
)
handleAjaxReloadDiscussion
(
$elem
,
url
)
handleAjaxReloadDiscussion
(
$elem
,
url
)
initializeNewPost
()
Discussion
.
bindLocalEvents
$local
,
Discussion
.
bindLocalEvents
$local
,
"submit .search-wrapper>.discussion-search-form"
:
(
event
)
->
"submit .search-wrapper>.discussion-search-form"
:
(
event
)
->
event
.
preventDefault
()
event
.
preventDefault
()
handleAjaxSearch
(
this
)
handleAjaxSearch
(
this
)
"click .discussion-new-post"
:
->
#
"click .discussion-new-post": ->
handleNewPost
(
this
)
#
handleNewPost(this)
"click .discussion-search-link"
:
->
"click .discussion-search-link"
:
->
handleAjaxSearch
(
$local
(
".search-wrapper>.discussion-search-form"
))
handleAjaxSearch
(
$local
(
".search-wrapper>.discussion-search-form"
))
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
7030d1f1
...
@@ -116,20 +116,26 @@ wmdEditors = {}
...
@@ -116,20 +116,26 @@ wmdEditors = {}
appended_id
=
"-
#{
cls_identifier
}
-
#{
id
}
"
appended_id
=
"-
#{
cls_identifier
}
-
#{
id
}
"
imageUploadUrl
=
Discussion
.
urlFor
(
'upload'
)
imageUploadUrl
=
Discussion
.
urlFor
(
'upload'
)
editor
=
Markdown
.
makeWmdEditor
elem
,
appended_id
,
imageUploadUrl
,
Discussion
.
postMathJaxProcessor
editor
=
Markdown
.
makeWmdEditor
elem
,
appended_id
,
imageUploadUrl
,
Discussion
.
postMathJaxProcessor
console
.
log
editor
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
=
editor
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
=
editor
$input
=
$
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
)
$input
.
attr
(
"placeholder"
,
"post a new topic..."
).
bind
'focus'
,
(
e
)
->
$
(
'.new-post-form'
).
removeClass
(
'collapsed'
)
editor
editor
getWmdEditor
:
(
$content
,
$local
,
cls_identifier
)
->
getWmdEditor
:
(
$content
,
$local
,
cls_identifier
)
->
id
=
$content
.
attr
(
"_id"
)
id
=
$content
.
attr
(
"_id"
)
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
]
getWmd
Conten
t
:
(
$content
,
$local
,
cls_identifier
)
->
getWmd
Inpu
t
:
(
$content
,
$local
,
cls_identifier
)
->
id
=
$content
.
attr
(
"_id"
)
id
=
$content
.
attr
(
"_id"
)
$local
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
).
val
()
$local
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
)
getWmdContent
:
(
$content
,
$local
,
cls_identifier
)
->
Discussion
.
getWmdInput
(
$content
,
$local
,
cls_identifier
).
val
()
setWmdContent
:
(
$content
,
$local
,
cls_identifier
,
text
)
->
setWmdContent
:
(
$content
,
$local
,
cls_identifier
,
text
)
->
id
=
$content
.
attr
(
"_id"
)
Discussion
.
getWmdInput
(
$content
,
$local
,
cls_identifier
).
val
(
text
)
$local
(
"#wmd-input-
#{
cls_identifier
}
-
#{
id
}
"
).
val
(
text
)
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
].
refreshPreview
()
wmdEditors
[
"
#{
cls_identifier
}
-
#{
id
}
"
].
refreshPreview
()
getContentInfo
:
(
id
,
attr
)
->
getContentInfo
:
(
id
,
attr
)
->
...
...
lms/templates/discussion/_inline.html
View file @
7030d1f1
<
%
namespace
name=
"renderer"
file=
"_thread.html"
/>
<
%
namespace
name=
"renderer"
file=
"_thread.html"
/>
<script
type=
"text/javascript"
>
$
(
'#wmd-input-reply-body'
).
bind
(
'focus'
,
function
(
e
)
{
$
(
'.new-post-form'
).
removeClass
(
'collapsed'
);
});
</script>
<section
class=
"discussion inline-discussion"
_id=
"${discussion_id}"
>
<section
class=
"discussion inline-discussion"
_id=
"${discussion_id}"
>
<div
class=
"discussion-non-content"
>
<div
class=
"discussion-non-content
discussion-local
"
>
<form
class=
"new-post-form collapsed"
id=
"new-post-form"
style=
"display: block; "
>
<form
class=
"new-post-form collapsed"
id=
"new-post-form"
style=
"display: block; "
>
<ul
class=
"discussion-errors"
></ul>
<ul
class=
"discussion-errors"
></ul>
<div
class=
"reply-body"
>
<div
class=
"new-post-body reply-body"
></div>
<div
class=
"wmd-panel"
>
<div
id=
"wmd-button-bar-reply-body-502021ba30e78e7d4d00031d"
>
<ul
id=
"wmd-button-row-reply-body-502021ba30e78e7d4d00031d"
class=
"wmd-button-row"
>
<li
class=
"wmd-button"
style=
"left: 0px; "
id=
"wmd-bold-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Strong <strong> Ctrl+B"
><span
style=
"background-position: 0px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 25px; "
id=
"wmd-italic-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Emphasis <em> Ctrl+I"
><span
style=
"background-position: -20px 0px; "
></span></li>
<li
class=
"wmd-spacer wmd-spacer1"
id=
"wmd-spacer1-reply-body-502021ba30e78e7d4d00031d"
></li>
<li
class=
"wmd-button"
style=
"left: 75px; "
id=
"wmd-link-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Hyperlink <a> Ctrl+L"
><span
style=
"background-position: -40px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 100px; "
id=
"wmd-quote-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Blockquote <blockquote> Ctrl+Q"
><span
style=
"background-position: -60px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 125px; "
id=
"wmd-code-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Code Sample <pre><code> Ctrl+K"
><span
style=
"background-position: -80px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 150px; "
id=
"wmd-image-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Image <img> Ctrl+G"
><span
style=
"background-position: -100px 0px; "
></span></li>
<li
class=
"wmd-spacer wmd-spacer2"
id=
"wmd-spacer2-reply-body-502021ba30e78e7d4d00031d"
></li>
<li
class=
"wmd-button"
style=
"left: 200px; "
id=
"wmd-olist-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Numbered List <ol> Ctrl+O"
><span
style=
"background-position: -120px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 225px; "
id=
"wmd-ulist-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Bulleted List <ul> Ctrl+U"
><span
style=
"background-position: -140px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 250px; "
id=
"wmd-heading-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Heading <h1>/<h2> Ctrl+H"
><span
style=
"background-position: -160px 0px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 275px; "
id=
"wmd-hr-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Horizontal Rule <hr> Ctrl+R"
><span
style=
"background-position: -180px 0px; "
></span></li>
<li
class=
"wmd-spacer wmd-spacer3"
id=
"wmd-spacer3-reply-body-502021ba30e78e7d4d00031d"
></li>
<li
class=
"wmd-button"
style=
"left: 325px; "
id=
"wmd-undo-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Undo - Ctrl+Z"
><span
style=
"background-position: -200px -20px; "
></span></li>
<li
class=
"wmd-button"
style=
"left: 350px; "
id=
"wmd-redo-button-reply-body-502021ba30e78e7d4d00031d"
title=
"Redo - Ctrl+Shift+Z"
><span
style=
"background-position: -220px -20px; "
></span></li>
</ul>
</div>
<textarea
class=
"wmd-input"
id=
"wmd-input-reply-body"
placeholder=
"Post a question or comment…"
></textarea>
<div
id=
"wmd-preview-reply-body-502021ba30e78e7d4d00031d"
class=
"wmd-panel wmd-preview"
></div>
</div>
</div>
<div
class=
"post-options"
>
<div
class=
"post-options"
>
<input
type=
"checkbox"
class=
"discussion-post-anonymously"
id=
"discussion-post-anonymously-
502021ba30e78e7d4d00031d
"
>
<input
type=
"checkbox"
class=
"discussion-post-anonymously"
id=
"discussion-post-anonymously-
${discussion_id}
"
>
<label
for=
"discussion-post-anonymously-
502021ba30e78e7d4d00031d
"
>
post anonymously
</label>
<label
for=
"discussion-post-anonymously-
${discussion_id}
"
>
post anonymously
</label>
<input
type=
"checkbox"
class=
"discussion-auto-watch"
id=
"discussion-autowatch-
502021ba30e78e7d4d00031d
"
checked=
""
>
<input
type=
"checkbox"
class=
"discussion-auto-watch"
id=
"discussion-autowatch-
${discussion_id}
"
checked=
""
>
<label
for=
"discussion-auto-watch-
502021ba30e78e7d4d00031d
"
>
follow this thread
</label>
<label
for=
"discussion-auto-watch-
${discussion_id}
"
>
follow this thread
</label>
</div>
</div>
<div
class=
"reply-post-control"
>
<div
class=
"reply-post-control"
>
<a
class=
"discussion-submit-post control-button"
href=
"javascript:void(0)"
>
Submit
</a>
<a
class=
"discussion-submit-post control-button"
href=
"javascript:void(0)"
>
Submit
</a>
...
...
lms/templates/discussion/_thread.html
View file @
7030d1f1
...
@@ -40,9 +40,11 @@
...
@@ -40,9 +40,11 @@
${render_vote(content)}
${render_vote(content)}
<div
class=
"discussion-right-wrapper clearfix"
>
<div
class=
"discussion-right-wrapper clearfix"
>
<ul
class=
"admin-actions"
>
<ul
class=
"admin-actions"
>
<li><a
href=
"#"
class=
"admin-endorse"
>
Endorse
</a></li>
% if type == 'comment':
<li><a
href=
"#"
class=
"admin-edit"
>
Edit
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-endorse"
>
Endorse
</a></li>
<li><a
href=
"#"
class=
"admin-delete"
>
Delete
</a></li>
% endif
<li><a
href=
"javascript:void(0)"
class=
"admin-edit"
>
Edit
</a></li>
<li><a
href=
"javascript:void(0)"
class=
"admin-delete"
>
Delete
</a></li>
</ul>
</ul>
${render_title(content, type, **kwargs)}
${render_title(content, type, **kwargs)}
...
...
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