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
a8b84a27
Commit
a8b84a27
authored
Aug 23, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display loading status
parent
8ccaca3a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
32 deletions
+92
-32
lms/static/coffee/src/discussion/content.coffee
+55
-23
lms/static/coffee/src/discussion/discussion.coffee
+14
-8
lms/static/coffee/src/discussion/utils.coffee
+15
-1
lms/static/images/discussion/loading.gif
+0
-0
lms/static/sass/_discussion.scss
+8
-0
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
a8b84a27
...
...
@@ -120,14 +120,19 @@ if Backbone?
else
$elem
=
$
.
merge
@
$
(
".thread-title"
),
@
$showComments
()
url
=
@
model
.
urlFor
(
'retrieve'
)
DiscussionUtil
.
get
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
showed
=
true
@
updateShowComments
()
@
$showComments
().
addClass
(
"retrieved"
)
@
$el
.
children
(
".comments"
).
replaceWith
response
.
html
@
model
.
resetComments
response
.
content
.
children
@
initCommentViews
()
DiscussionUtil
.
bulkUpdateContentInfo
response
.
annotated_content_info
DiscussionUtil
.
safeAjax
$elem
:
$elem
$loading
:
$
(
event
.
target
)
if
event
type
:
"GET"
url
:
url
success
:
(
response
,
textStatus
)
=>
@
showed
=
true
@
updateShowComments
()
@
$showComments
().
addClass
(
"retrieved"
)
@
$el
.
children
(
".comments"
).
replaceWith
response
.
html
@
model
.
resetComments
response
.
content
.
children
@
initCommentViews
()
DiscussionUtil
.
bulkUpdateContentInfo
response
.
annotated_content_info
toggleSingleThread
:
(
event
)
->
if
@
showed
...
...
@@ -169,6 +174,7 @@ if Backbone?
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
$loading
:
$
(
event
.
target
)
if
event
url
:
url
type
:
"POST"
dataType
:
'json'
...
...
@@ -197,16 +203,24 @@ if Backbone?
unvote
:
(
event
)
->
url
=
@
model
.
urlFor
(
'unvote'
)
$elem
=
@
$
(
".discussion-vote"
)
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
model
.
set
(
'voted'
,
''
)
@
model
.
set
(
'votes_point'
,
response
.
votes
.
point
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
@
model
.
set
(
'voted'
,
''
)
@
model
.
set
(
'votes_point'
,
response
.
votes
.
point
)
vote
:
(
event
,
value
)
->
url
=
@
model
.
urlFor
(
"
#{
value
}
vote"
)
$elem
=
@
$
(
".discussion-vote"
)
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
model
.
set
(
'voted'
,
value
)
@
model
.
set
(
'votes_point'
,
response
.
votes
.
point
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
@
model
.
set
(
'voted'
,
value
)
@
model
.
set
(
'votes_point'
,
response
.
votes
.
point
)
toggleVote
:
(
event
)
->
$elem
=
$
(
event
.
target
)
...
...
@@ -221,8 +235,13 @@ if Backbone?
url
=
@
model
.
urlFor
(
'endorse'
)
endorsed
=
@
model
.
get
(
'endorsed'
)
data
=
{
endorsed
:
not
endorsed
}
DiscussionUtil
.
post
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
@
model
.
set
(
'endorsed'
,
not
endorsed
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
data
:
data
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
@
model
.
set
(
'endorsed'
,
not
endorsed
)
toggleFollow
:
(
event
)
->
$elem
=
$
(
event
.
target
)
...
...
@@ -231,16 +250,25 @@ if Backbone?
url
=
@
model
.
urlFor
(
'unfollow'
)
else
url
=
@
model
.
urlFor
(
'follow'
)
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
model
.
set
(
'subscribed'
,
not
subscribed
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
@
model
.
set
(
'subscribed'
,
not
subscribed
)
toggleClosed
:
(
event
)
->
$elem
=
$
(
event
.
target
)
url
=
@
model
.
urlFor
(
'close'
)
closed
=
@
model
.
get
(
'closed'
)
data
=
{
closed
:
not
closed
}
DiscussionUtil
.
post
$elem
,
url
,
data
,
(
response
,
textStatus
)
=>
@
model
.
set
(
'closed'
,
not
closed
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
type
:
"POST"
data
:
data
success
:
(
response
,
textStatus
)
=>
@
model
.
set
(
'closed'
,
not
closed
)
edit
:
(
event
)
->
@
$
(
".discussion-content-wrapper"
).
hide
()
...
...
@@ -274,6 +302,7 @@ if Backbone?
data
.
body
=
DiscussionUtil
.
getWmdContent
@
$el
,
$
.
proxy
(
@
$
,
@
),
"comment-body-edit"
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
$loading
:
$
(
event
.
target
)
if
event
url
:
url
type
:
"POST"
dataType
:
'json'
...
...
@@ -298,9 +327,12 @@ if Backbone?
if
not
c
return
$elem
=
$
(
event
.
target
)
DiscussionUtil
.
post
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
@
$el
.
remove
()
@
model
.
get
(
'thread'
).
removeComment
(
@
model
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
url
:
url
success
:
(
response
,
textStatus
)
=>
@
$el
.
remove
()
@
model
.
get
(
'thread'
).
removeComment
(
@
model
)
events
:
"click .discussion-follow-thread"
:
"toggleFollow"
...
...
lms/static/coffee/src/discussion/discussion.coffee
View file @
a8b84a27
...
...
@@ -39,14 +39,19 @@ if Backbone?
reload
:
(
$elem
,
url
)
->
if
not
url
then
return
DiscussionUtil
.
get
$elem
,
url
,
{},
(
response
,
textStatus
)
=>
$parent
=
@
$el
.
parent
()
@
$el
.
replaceWith
(
response
.
html
)
$discussion
=
$parent
.
find
(
"section.discussion"
)
@
model
.
reset
(
response
.
discussionData
,
{
silent
:
false
})
view
=
new
DiscussionView
el
:
$discussion
[
0
],
model
:
@
model
DiscussionUtil
.
bulkUpdateContentInfo
(
window
.
$
$annotated_content_info
)
$
(
"html, body"
).
animate
({
scrollTop
:
0
},
0
)
DiscussionUtil
.
safeAjax
$elem
:
$elem
$loading
:
$elem
url
:
url
type
:
"GET"
success
:
(
response
,
textStatus
)
=>
$parent
=
@
$el
.
parent
()
@
$el
.
replaceWith
(
response
.
html
)
$discussion
=
$parent
.
find
(
"section.discussion"
)
@
model
.
reset
(
response
.
discussionData
,
{
silent
:
false
})
view
=
new
DiscussionView
el
:
$discussion
[
0
],
model
:
@
model
DiscussionUtil
.
bulkUpdateContentInfo
(
window
.
$
$annotated_content_info
)
$
(
"html, body"
).
animate
({
scrollTop
:
0
},
0
)
loadSimilarPost
:
(
event
)
->
$title
=
@
$
(
".new-post-title"
)
...
...
@@ -114,6 +119,7 @@ if Backbone?
url
=
DiscussionUtil
.
urlFor
(
'create_thread'
,
@
model
.
id
)
DiscussionUtil
.
safeAjax
$elem
:
$
(
event
.
target
)
$loading
:
$
(
event
.
target
)
if
event
url
:
url
type
:
"POST"
dataType
:
'json'
...
...
lms/static/coffee/src/discussion/utils.coffee
View file @
a8b84a27
$
->
$
.
fn
.
extend
loading
:
->
$
(
this
).
after
(
"<span class='loading'></span>"
)
loaded
:
->
$
(
this
).
parent
().
children
(
".loading"
).
remove
()
class
@
DiscussionUtil
@
wmdEditors
:
{}
...
...
@@ -62,9 +69,16 @@ class @DiscussionUtil
$elem
=
params
.
$elem
if
$elem
.
attr
(
"disabled"
)
return
$elem
.
attr
(
"disabled"
,
"disabled"
)
params
[
"beforeSend"
]
=
->
$elem
.
attr
(
"disabled"
,
"disabled"
)
if
params
[
"$loading"
]
console
.
log
"loading"
params
[
"$loading"
].
loading
()
$
.
ajax
(
params
).
always
->
$elem
.
removeAttr
(
"disabled"
)
if
params
[
"$loading"
]
console
.
log
"loaded"
params
[
"$loading"
].
loaded
()
@
get
:
(
$elem
,
url
,
data
,
success
)
->
@
safeAjax
...
...
lms/static/images/discussion/loading.gif
0 → 100644
View file @
a8b84a27
809 Bytes
lms/static/sass/_discussion.scss
View file @
a8b84a27
...
...
@@ -49,6 +49,14 @@ $tag-text-color: #5b614f;
margin-top
:
0
;
}
.loading
{
background-image
:
url(../images/discussion/loading.gif)
;
width
:
15px
;
height
:
15px
;
margin-left
:
2px
;
display
:
inline-block
;
}
/*** Sidebar ***/
...
...
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