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
e827ee33
Commit
e827ee33
authored
Aug 21, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make edit working
parent
6183146e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
33 deletions
+45
-33
lms/static/coffee/src/backbone_discussion/content.coffee
+45
-33
No files found.
lms/static/coffee/src/backbone_discussion/content.coffee
View file @
e827ee33
...
@@ -214,42 +214,52 @@ class @ContentView extends Backbone.View
...
@@ -214,42 +214,52 @@ class @ContentView extends Backbone.View
DiscussionUtil
.
post
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
DiscussionUtil
.
post
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
@
model
.
set
(
'closed'
,
not
closed
)
@
model
.
set
(
'closed'
,
not
closed
)
edit
:
->
edit
:
(
event
)
->
$local
(
".discussion-content-wrapper"
).
hide
()
@
$
(
".discussion-content-wrapper"
).
hide
()
$editView
=
$local
(
".discussion-content-edit"
)
$editView
=
@
$
(
".discussion-content-edit"
)
if
$editView
.
length
if
$editView
.
length
$editView
.
show
()
$editView
.
show
()
else
else
view
=
{
view
=
{}
id
:
id
view
.
id
=
@
model
.
id
title
:
$local
(
".thread-raw-title"
).
html
()
if
@
model
.
get
(
'type'
)
==
'thread'
body
:
$local
(
".thread-raw-body"
).
html
()
view
.
title
=
@
$
(
".thread-raw-title"
).
html
()
tags
:
$local
(
".thread-raw-tags"
).
html
()
view
.
body
=
@
$
(
".thread-raw-body"
).
html
()
}
view
.
tags
=
@
$
(
".thread-raw-tags"
).
html
()
@
$discussionContent
().
append
Mustache
.
render
Discussion
.
editThreadTemplate
,
view
else
Discussion
.
makeWmdEditor
$content
,
$local
,
"thread-body-edit"
view
.
body
=
@
$
(
".comment-raw-body"
).
html
()
$local
(
".thread-tags-edit"
).
tagsInput
Discussion
.
tagsInputOptions
()
@
$discussionContent
().
append
Mustache
.
render
DiscussionUtil
.
getTemplate
(
"_edit_
#{
@
model
.
get
(
'type'
)
}
"
),
view
$local
(
".discussion-submit-update"
).
unbind
(
"click"
).
click
->
handleSubmitEditThread
(
this
)
Discussion
.
makeWmdEditor
@
$el
,
$
.
proxy
(
@
$
,
@
),
"
#{
@
model
.
get
(
'type'
)
}
-body-edit"
$local
(
".discussion-cancel-update"
).
unbind
(
"click"
).
click
->
handleCancelEdit
(
this
)
@
$
(
".thread-tags-edit"
).
tagsInput
DiscussionUtil
.
tagsInputOptions
()
@
$
(
".discussion-submit-update"
).
unbind
(
"click"
).
click
$
.
proxy
(
@
submitEdit
,
@
)
handleSubmitEditThread
=
(
elem
)
->
@
$
(
".discussion-cancel-update"
).
unbind
(
"click"
).
click
$
.
proxy
(
@
cancelEdit
,
@
)
url
=
Discussion
.
urlFor
(
'update_thread'
,
id
)
title
=
$local
(
".thread-title-edit"
).
val
()
submitEdit
:
(
event
)
->
body
=
Discussion
.
getWmdContent
$content
,
$local
,
"thread-body-edit"
tags
=
$local
(
".thread-tags-edit"
).
val
()
url
=
@
model
.
urlFor
(
'update'
)
Discussion
.
safeAjax
data
=
{}
$elem
:
$
(
elem
)
if
@
model
.
get
(
'type'
)
==
'thread'
url
:
url
data
.
title
=
@
$
(
".thread-title-edit"
).
val
()
type
:
"POST"
data
.
body
=
DiscussionUtil
.
getWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"thread-body-edit"
dataType
:
'json'
data
.
tags
=
@
$
(
".thread-tags-edit"
).
val
()
data
:
{
title
:
title
,
body
:
body
,
tags
:
tags
},
else
error
:
Discussion
.
formErrorHandler
(
$local
(
".discussion-update-errors"
))
data
.
body
=
DiscussionUtil
.
getWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"comment-body-edit"
success
:
(
response
,
textStatus
)
->
DiscussionUtil
.
safeAjax
Discussion
.
clearFormErrors
(
$local
(
".discussion-update-errors"
))
$elem
:
$
(
event
.
target
)
@
$discussionContent
().
replaceWith
(
response
.
html
)
url
:
url
Discussion
.
extendContentInfo
response
.
content
[
'id'
],
response
[
'annotated_content_info'
]
type
:
"POST"
Discussion
.
initializeContent
(
$content
)
dataType
:
'json'
Discussion
.
bindContentEvents
(
$content
)
data
:
data
error
:
DiscussionUtil
.
formErrorHandler
@
$
(
".discussion-update-errors"
)
success
:
(
response
,
textStatus
)
=>
DiscussionUtil
.
clearFormErrors
@
$
(
".discussion-update-errors"
)
@
$discussionContent
().
replaceWith
(
response
.
html
)
@
model
.
set
response
.
content
@
model
.
updateInfo
response
.
annotated_content_info
cancelEdit
:
(
event
)
->
@
$
(
".discussion-content-edit"
).
hide
()
@
$
(
".discussion-content-wrapper"
).
show
()
delete
:
->
delete
:
->
if
$content
.
hasClass
(
"thread"
)
if
$content
.
hasClass
(
"thread"
)
...
@@ -325,6 +335,7 @@ class @Thread extends @Content
...
@@ -325,6 +335,7 @@ class @Thread extends @Content
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'close'
:
->
DiscussionUtil
.
urlFor
(
'openclose_thread'
,
@
id
)
'close'
:
->
DiscussionUtil
.
urlFor
(
'openclose_thread'
,
@
id
)
'update'
:
->
DiscussionUtil
.
urlFor
(
'update_thread'
,
@
id
)
initialize
:
->
initialize
:
->
@
set
(
'thread'
,
@
)
@
set
(
'thread'
,
@
)
...
@@ -343,6 +354,7 @@ class @Comment extends @Content
...
@@ -343,6 +354,7 @@ class @Comment extends @Content
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'upvote'
:
->
DiscussionUtil
.
urlFor
(
"upvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'downvote'
:
->
DiscussionUtil
.
urlFor
(
"downvote_
#{
@
get
(
'type'
)
}
"
,
@
id
)
'endorse'
:
->
DiscussionUtil
.
urlFor
(
'endorse_comment'
,
@
id
)
'endorse'
:
->
DiscussionUtil
.
urlFor
(
'endorse_comment'
,
@
id
)
'update'
:
->
DiscussionUtil
.
urlFor
(
'update_comment'
,
@
id
)
permalink
:
->
permalink
:
->
thread_id
=
@
get
(
'thread'
).
id
thread_id
=
@
get
(
'thread'
).
id
...
...
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