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
a8e3bca8
Commit
a8e3bca8
authored
Jan 14, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internationalize forums CoffeeScript code
parent
a1dc49cc
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
66 additions
and
50 deletions
+66
-50
common/static/coffee/spec/discussion/view/discussion_view_spec_helper.coffee
+2
-4
common/static/coffee/src/discussion/discussion_module_view.coffee
+7
-7
common/static/coffee/src/discussion/utils.coffee
+5
-6
common/static/coffee/src/discussion/views/discussion_content_view.coffee
+22
-5
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+7
-7
common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
+5
-5
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
+1
-1
common/static/coffee/src/discussion/views/new_post_view.coffee
+3
-3
common/static/coffee/src/discussion/views/response_comment_show_view.coffee
+6
-6
common/static/coffee/src/discussion/views/thread_response_show_view.coffee
+4
-4
common/static/coffee/src/discussion/views/thread_response_view.coffee
+1
-1
common/static/js/test/i18n.js
+2
-1
common/static/js_test.yml
+1
-0
No files found.
common/static/coffee/spec/discussion/view/discussion_view_spec_helper.coffee
View file @
a8e3bca8
...
...
@@ -5,14 +5,12 @@ class @DiscussionViewSpecHelper
expect
(
button
.
hasClass
(
"is-cast"
)).
toBe
(
true
)
expect
(
button
.
attr
(
"aria-pressed"
)).
toEqual
(
"true"
)
expect
(
button
.
attr
(
"data-tooltip"
)).
toEqual
(
"remove vote"
)
expect
(
button
.
find
(
".votes-count-number"
).
html
()).
toEqual
(
"43"
)
expect
(
button
.
find
(
".sr"
).
html
()).
toEqual
(
"votes (click to remove your vote)"
)
expect
(
button
.
text
()).
toEqual
(
"43 votes (click to remove your vote)"
)
else
expect
(
button
.
hasClass
(
"is-cast"
)).
toBe
(
false
)
expect
(
button
.
attr
(
"aria-pressed"
)).
toEqual
(
"false"
)
expect
(
button
.
attr
(
"data-tooltip"
)).
toEqual
(
"vote"
)
expect
(
button
.
find
(
".votes-count-number"
).
html
()).
toEqual
(
"42"
)
expect
(
button
.
find
(
".sr"
).
html
()).
toEqual
(
"votes (click to vote)"
)
expect
(
button
.
text
()).
toEqual
(
"42 votes (click to vote)"
)
@
checkRenderVote
=
(
view
,
model
)
->
view
.
renderVote
()
...
...
common/static/coffee/src/discussion/discussion_module_view.coffee
View file @
a8e3bca8
...
...
@@ -30,7 +30,7 @@ if Backbone?
else
@
newPostForm
.
show
()
@
toggleDiscussionBtn
.
addClass
(
'shown'
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
"Hide Discussion"
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
gettext
(
"Hide Discussion"
)
)
@
$
(
"section.discussion"
).
slideDown
()
@
showed
=
true
...
...
@@ -41,7 +41,7 @@ if Backbone?
hideDiscussion
:
->
@
$
(
"section.discussion"
).
slideUp
()
@
toggleDiscussionBtn
.
removeClass
(
'shown'
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
"Show Discussion"
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
gettext
(
"Show Discussion"
)
)
@
showed
=
false
toggleDiscussion
:
(
event
)
->
...
...
@@ -49,7 +49,7 @@ if Backbone?
@
hideDiscussion
()
else
@
toggleDiscussionBtn
.
addClass
(
'shown'
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
"Hide Discussion"
)
@
toggleDiscussionBtn
.
find
(
'.button-text'
).
html
(
gettext
(
"Hide Discussion"
)
)
if
@
retrieved
@
$
(
"section.discussion"
).
slideDown
()
...
...
@@ -61,8 +61,8 @@ if Backbone?
=>
@
hideDiscussion
()
DiscussionUtil
.
discussionAlert
(
"Sorry"
,
"We had some trouble loading the discussion. Please try again."
gettext
(
"Sorry"
)
,
gettext
(
"We had some trouble loading the discussion. Please try again."
)
)
)
...
...
@@ -154,7 +154,7 @@ if Backbone?
=>
@
page
=
currPage
DiscussionUtil
.
discussionAlert
(
"Sorry"
,
"We had some trouble loading the threads you requested. Please try again."
gettext
(
"Sorry"
)
,
gettext
(
"We had some trouble loading the threads you requested. Please try again."
)
)
)
common/static/coffee/src/discussion/utils.coffee
View file @
a8e3bca8
...
...
@@ -3,7 +3,7 @@ $ ->
window
.
$
$contents
=
{}
$
.
fn
.
extend
loading
:
(
takeFocus
)
->
@
$_loading
=
$
(
"<div class='loading-animation' tabindex='0'><span class='sr'>
Loading content
</span></div>"
)
@
$_loading
=
$
(
"<div class='loading-animation' tabindex='0'><span class='sr'>
"
+
gettext
(
"Loading content"
)
+
"
</span></div>"
)
$
(
this
).
after
(
@
$_loading
)
if
takeFocus
DiscussionUtil
.
makeFocusTrap
(
@
$_loading
)
...
...
@@ -109,7 +109,7 @@ class @DiscussionUtil
" <header><h2/><hr/></header>"
+
" <p id='discussion-alert-message'/>"
+
" <hr/>"
+
" <button class='dismiss'>
OK
</button>"
+
" <button class='dismiss'>
"
+
gettext
(
"OK"
)
+
"
</button>"
+
"</div>"
)
@
makeFocusTrap
(
alertDiv
.
find
(
"button"
))
...
...
@@ -137,9 +137,8 @@ class @DiscussionUtil
if
!
params
[
"error"
]
params
[
"error"
]
=
=>
@
discussionAlert
(
"Sorry"
,
"We had some trouble processing your request. Please ensure you"
+
" have copied any unsaved work and then reload the page."
gettext
(
"Sorry"
),
gettext
(
"We had some trouble processing your request. Please ensure you have copied any unsaved work and then reload the page."
)
)
request
=
$
.
ajax
(
params
).
always
->
if
$elem
...
...
@@ -290,5 +289,5 @@ class @DiscussionUtil
else
while
minLength
<
text
.
length
&&
text
[
minLength
]
!=
' '
minLength
++
return
text
.
substr
(
0
,
minLength
)
+
'...'
return
text
.
substr
(
0
,
minLength
)
+
gettext
(
'…'
)
common/static/coffee/src/discussion/views/discussion_content_view.coffee
View file @
a8e3bca8
...
...
@@ -23,11 +23,11 @@ if Backbone?
return
if
not
@
$
(
".post-status-closed"
).
length
if
closed
@
$
(
".post-status-closed"
).
show
()
@
$
(
".action-openclose"
).
html
(
@
$
(
".action-openclose"
).
html
().
replace
(
"Close"
,
"Open"
))
@
$
(
".action-openclose"
).
html
(
@
$
(
".action-openclose"
).
html
().
replace
(
gettext
(
"Close"
),
gettext
(
"Open"
)
))
@
$
(
".discussion-reply-new"
).
hide
()
else
@
$
(
".post-status-closed"
).
hide
()
@
$
(
".action-openclose"
).
html
(
@
$
(
".action-openclose"
).
html
().
replace
(
"Open"
,
"Close"
))
@
$
(
".action-openclose"
).
html
(
@
$
(
".action-openclose"
).
html
().
replace
(
gettext
(
"Open"
),
gettext
(
"Close"
)
))
@
$
(
".discussion-reply-new"
).
show
()
voted
:
(
voted
)
->
...
...
@@ -166,9 +166,26 @@ if Backbone?
voteNum
=
@
model
.
get
(
"votes"
)[
"up_count"
]
button
.
toggleClass
(
"is-cast"
,
voted
)
button
.
attr
(
"aria-pressed"
,
voted
)
button
.
attr
(
"data-tooltip"
,
if
voted
then
"remove vote"
else
"vote"
)
button
.
find
(
".votes-count-number"
).
html
(
voteNum
)
button
.
find
(
".sr"
).
html
(
if
voted
then
"votes (click to remove your vote)"
else
"votes (click to vote)"
)
button
.
attr
(
"data-tooltip"
,
if
voted
then
gettext
(
"remove vote"
)
else
gettext
(
"vote"
))
buttonTextFmt
=
if
voted
ngettext
(
"%(voteNum)s%(startSrSpan)s vote (click to remove your vote)%(endSrSpan)s"
,
"%(voteNum)s%(startSrSpan)s votes (click to remove your vote)%(endSrSpan)s"
,
voteNum
)
else
ngettext
(
"%(voteNum)s%(startSrSpan)s vote (click to vote)%(endSrSpan)s"
,
"%(voteNum)s%(startSrSpan)s votes (click to vote)%(endSrSpan)s"
,
voteNum
)
buttonText
=
interpolate
(
buttonTextFmt
,
{
voteNum
:
voteNum
,
startSrSpan
:
"<span class='sr'>"
,
endSrSpan
:
"</span>"
},
true
)
button
.
html
(
"<span class='plus-icon'/>"
+
buttonText
)
toggleVote
:
(
event
)
=>
event
.
preventDefault
()
...
...
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
a8e3bca8
...
...
@@ -119,12 +119,12 @@ if Backbone?
renderMorePages
:
->
if
@
displayedCollection
.
hasMorePages
()
@
$
(
".post-list"
).
append
(
"<li class='more-pages'><a href='#'>
Load more
</a></li>"
)
@
$
(
".post-list"
).
append
(
"<li class='more-pages'><a href='#'>
"
+
gettext
(
"Load more"
)
+
"
</a></li>"
)
loadMorePages
:
(
event
)
->
if
event
event
.
preventDefault
()
@
$
(
".more-pages"
).
html
(
'<div class="loading-animation" tabindex=0><span class="sr" role="alert">
Loading more threads
</span></div>'
)
@
$
(
".more-pages"
).
html
(
'<div class="loading-animation" tabindex=0><span class="sr" role="alert">
'
+
gettext
(
'Loading more threads'
)
+
'
</span></div>'
)
@
$
(
".more-pages"
).
addClass
(
"loading"
)
loadingDiv
=
@
$
(
".more-pages .loading-animation"
)
DiscussionUtil
.
makeFocusTrap
(
loadingDiv
)
...
...
@@ -161,7 +161,7 @@ if Backbone?
error
=
=>
@
renderThreads
()
DiscussionUtil
.
discussionAlert
(
"Sorry"
,
"We had some trouble loading more threads. Please try again."
)
DiscussionUtil
.
discussionAlert
(
gettext
(
"Sorry"
),
gettext
(
"We had some trouble loading more threads. Please try again."
)
)
@
collection
.
retrieveAnotherPage
(
@
mode
,
options
,
{
sort_key
:
@
sortBy
},
error
)
...
...
@@ -292,14 +292,14 @@ if Backbone?
path
=
(
x
.
replace
/^\s+|\s+$/g
,
""
for
x
in
name
.
split
(
"/"
))
while
path
.
length
>
1
path
.
shift
()
partialName
=
"…
/"
+
path
.
join
(
"/"
)
partialName
=
gettext
(
"…"
)
+
"
/"
+
path
.
join
(
"/"
)
if
@
getNameWidth
(
partialName
)
<
@
maxNameWidth
return
partialName
rawName
=
path
[
0
]
name
=
"…
/"
+
rawName
name
=
gettext
(
"…"
)
+
"
/"
+
rawName
while
@
getNameWidth
(
name
)
>
@
maxNameWidth
rawName
=
rawName
[
0
...
rawName
.
length
-
1
]
name
=
"…/"
+
rawName
+
"…"
name
=
gettext
(
"…"
)
+
"/"
+
rawName
+
gettext
(
"…"
)
return
name
filterTopic
:
(
event
)
->
...
...
@@ -407,7 +407,7 @@ if Backbone?
type
:
"GET"
$loading
:
$
loadingCallback
:
=>
@
$
(
".post-list"
).
html
(
'<li class="loading"><div class="loading-animation"><span class="sr">
Loading thread list
</span></div></li>'
)
@
$
(
".post-list"
).
html
(
'<li class="loading"><div class="loading-animation"><span class="sr">
'
+
gettext
(
'Loading thread list'
)
+
'
</span></div></li>'
)
loadedCallback
:
=>
if
callback
callback
.
apply
@
,
[
value
]
...
...
common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
View file @
a8e3bca8
...
...
@@ -46,22 +46,22 @@ if Backbone?
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"true"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Misuse Reported"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Misuse Reported"
)
)
else
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"false"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Report Misuse"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Report Misuse"
)
)
renderPinned
:
=>
if
@
model
.
get
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
addClass
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
removeClass
(
"notpinned"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
"Pinned"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
gettext
(
"Pinned"
)
)
else
@
$
(
"[data-role=thread-pin]"
).
removeClass
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
addClass
(
"notpinned"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
"Pin Thread"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
gettext
(
"Pin Thread"
)
)
updateModelDetails
:
=>
...
...
@@ -97,7 +97,7 @@ if Backbone?
if
textStatus
==
'success'
@
model
.
set
(
'pinned'
,
true
)
error
:
=>
$
(
'.admin-pin'
).
text
(
"Pinning not currently available"
)
$
(
'.admin-pin'
).
text
(
gettext
(
"Pinning is not currently available"
)
)
unPin
:
->
url
=
@
model
.
urlFor
(
"unPinThread"
)
...
...
common/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
a8e3bca8
...
...
@@ -165,7 +165,7 @@ if Backbone?
url
=
@
model
.
urlFor
(
'_delete'
)
if
not
@
model
.
can
(
'can_delete'
)
return
if
not
confirm
"Are you sure to delete thread
\"
#{
@
model
.
get
(
'title'
)
}
\"
?"
if
not
confirm
gettext
(
"Are you sure you want to delete this post?"
)
return
@
model
.
remove
()
@
showView
.
undelegateEvents
()
...
...
common/static/coffee/src/discussion/views/new_post_view.coffee
View file @
a8e3bca8
...
...
@@ -105,17 +105,17 @@ if Backbone?
path
=
(
x
.
replace
/^\s+|\s+$/g
,
""
for
x
in
name
.
split
(
"/"
))
while
path
.
length
>
1
path
.
shift
()
partialName
=
"...
/ "
+
path
.
join
(
" / "
)
partialName
=
gettext
(
"…"
)
+
"
/ "
+
path
.
join
(
" / "
)
if
@
getNameWidth
(
partialName
)
<
@
maxNameWidth
return
partialName
rawName
=
path
[
0
]
name
=
"...
/ "
+
rawName
name
=
gettext
(
"…"
)
+
"
/ "
+
rawName
while
@
getNameWidth
(
name
)
>
@
maxNameWidth
rawName
=
rawName
[
0
...
rawName
.
length
-
1
]
name
=
"... / "
+
rawName
+
" ..."
name
=
gettext
(
"…"
)
+
" / "
+
rawName
+
" "
+
gettext
(
"…"
)
return
name
...
...
common/static/coffee/src/discussion/views/response_comment_show_view.coffee
View file @
a8e3bca8
...
...
@@ -24,7 +24,7 @@ if Backbone?
addReplyLink
:
()
->
if
@
model
.
hasOwnProperty
(
'parent'
)
name
=
@
model
.
parent
.
get
(
'username'
)
?
"anonymous"
name
=
@
model
.
parent
.
get
(
'username'
)
?
gettext
(
"anonymous"
)
html
=
"<a href='#comment_
#{
@
model
.
parent
.
id
}
'>@
#{
name
}
</a>: "
p
=
@
$
(
'.response-body p:first'
)
p
.
prepend
(
html
)
...
...
@@ -36,9 +36,9 @@ if Backbone?
markAsStaff
:
->
if
DiscussionUtil
.
isStaff
(
@
model
.
get
(
"user_id"
))
@
$el
.
find
(
"a.profile-link"
).
after
(
'<span class="staff-label">
staff
</span>'
)
@
$el
.
find
(
"a.profile-link"
).
after
(
'<span class="staff-label">
'
+
gettext
(
'staff'
)
+
'
</span>'
)
else
if
DiscussionUtil
.
isTA
(
@
model
.
get
(
"user_id"
))
@
$el
.
find
(
"a.profile-link"
).
after
(
'<span class="community-ta-label">
Community TA
</span>'
)
@
$el
.
find
(
"a.profile-link"
).
after
(
'<span class="community-ta-label">
'
+
gettext
(
'Community TA'
)
+
'
</span>'
)
renderFlagged
:
=>
...
...
@@ -46,14 +46,14 @@ if Backbone?
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"true"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"data-tooltip"
,
"Misuse Reported"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"data-tooltip"
,
gettext
(
"Misuse Reported"
)
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Misuse Reported"
)
else
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"false"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"data-tooltip"
,
"Report Misuse"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Report Misuse"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"data-tooltip"
,
gettext
(
"Report Misuse"
)
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Report Misuse"
)
)
updateModelDetails
:
=>
@
renderFlagged
()
...
...
common/static/coffee/src/discussion/views/thread_response_show_view.coffee
View file @
a8e3bca8
...
...
@@ -42,10 +42,10 @@ if Backbone?
markAsStaff
:
->
if
DiscussionUtil
.
isStaff
(
@
model
.
get
(
"user_id"
))
@
$el
.
addClass
(
"staff"
)
@
$el
.
prepend
(
'<div class="staff-banner">
staff
</div>'
)
@
$el
.
prepend
(
'<div class="staff-banner">
'
+
gettext
(
'staff'
)
+
'
</div>'
)
else
if
DiscussionUtil
.
isTA
(
@
model
.
get
(
"user_id"
))
@
$el
.
addClass
(
"community-ta"
)
@
$el
.
prepend
(
'<div class="community-ta-banner">
Community TA
</div>'
)
@
$el
.
prepend
(
'<div class="community-ta-banner">
'
+
gettext
(
'Community TA'
)
+
'
</div>'
)
edit
:
(
event
)
->
@
trigger
"response:edit"
,
event
...
...
@@ -75,12 +75,12 @@ if Backbone?
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"true"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Misuse Reported"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Misuse Reported"
)
)
else
@
$
(
"[data-role=thread-flag]"
).
removeClass
(
"flagged"
)
@
$
(
"[data-role=thread-flag]"
).
addClass
(
"notflagged"
)
@
$
(
".discussion-flag-abuse"
).
attr
(
"aria-pressed"
,
"false"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
"Report Misuse"
)
@
$
(
".discussion-flag-abuse .flag-label"
).
html
(
gettext
(
"Report Misuse"
))
updateModelDetails
:
=>
@
renderVote
()
...
...
common/static/coffee/src/discussion/views/thread_response_view.coffee
View file @
a8e3bca8
...
...
@@ -97,7 +97,7 @@ if Backbone?
event
.
preventDefault
()
if
not
@
model
.
can
(
'can_delete'
)
return
if
not
confirm
"Are you sure to delete this response? "
if
not
confirm
gettext
(
"Are you sure you want to delete this response?"
)
return
url
=
@
model
.
urlFor
(
'_delete'
)
@
model
.
remove
()
...
...
common/static/js/test/i18n.js
View file @
a8e3bca8
window
.
gettext
=
window
.
ngettext
=
function
(
s
){
return
s
;};
window
.
gettext
=
function
(
s
){
return
s
;};
window
.
ngettext
=
function
(
singular
,
plural
,
num
){
return
num
==
1
?
singular
:
plural
}
function
interpolate
(
fmt
,
obj
,
named
)
{
if
(
named
)
{
...
...
common/static/js_test.yml
View file @
a8e3bca8
...
...
@@ -37,6 +37,7 @@ lib_paths:
-
js/vendor/URI.min.js
-
coffee/src/ajax_prefix.js
-
js/test/add_ajax_prefix.js
-
js/test/i18n.js
-
coffee/src/jquery.immediateDescendents.js
# Paths to source JavaScript files
...
...
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