Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -41,15 +41,15 @@ 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) ->
if @showed
@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()
Expand All @@ -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.")
)
)

Expand Down Expand Up @@ -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.")
)
)
3 changes: 0 additions & 3 deletions common/static/coffee/src/discussion/discussion_router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ if Backbone?
@main.render()
@main.on "thread:responses:rendered", =>
@nav.updateSidebar()
@main.on "tag:selected", (tag) =>
search = "[#{tag}]"
@nav.setAndSearchFor(search)

navigateToThread: (thread_id) =>
thread = @discussion.get(thread_id)
Expand Down
26 changes: 5 additions & 21 deletions common/static/coffee/src/discussion/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -75,7 +75,6 @@ class @DiscussionUtil
undo_vote_for_comment : "/courses/#{$$course_id}/discussion/comments/#{param}/unvote"
upload : "/courses/#{$$course_id}/discussion/upload"
search : "/courses/#{$$course_id}/discussion/forum/search"
tags_autocomplete : "/courses/#{$$course_id}/discussion/threads/tags/autocomplete"
retrieve_discussion : "/courses/#{$$course_id}/discussion/forum/#{param}/inline"
retrieve_single_thread : "/courses/#{$$course_id}/discussion/forum/#{param}/threads/#{param1}"
openclose_thread : "/courses/#{$$course_id}/discussion/threads/#{param}/close"
Expand Down Expand Up @@ -110,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"))
Expand Down Expand Up @@ -138,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
Expand All @@ -157,20 +155,6 @@ class @DiscussionUtil
[event, selector] = eventSelector.split(' ')
$local(selector).unbind(event)[event] handler

@processTag: (text) ->
text.toLowerCase()

@tagsInputOptions: ->
autocomplete_url: @urlFor('tags_autocomplete')
autocomplete:
remoteDataType: 'json'
interactive: true
height: '30px'
width: '100%'
defaultText: "Tag your post: press enter after each tag"
removeWithBackspace: true
preprocessTag: @processTag

@formErrorHandler: (errorsField) ->
(xhr, textStatus, error) ->
response = JSON.parse(xhr.responseText)
Expand Down Expand Up @@ -305,5 +289,5 @@ class @DiscussionUtil
else
while minLength < text.length && text[minLength] != ' '
minLength++
return text.substr(0, minLength) + '...'
return text.substr(0, minLength) + gettext('…')

Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ if Backbone?
@$el.html(@template(@model.toJSON()))
@delegateEvents()
DiscussionUtil.makeWmdEditor @$el, $.proxy(@$, @), "edit-post-body"
@$(".edit-post-tags").tagsInput DiscussionUtil.tagsInputOptions()
@

update: (event) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -393,11 +393,6 @@ if Backbone?
text = @$(".post-search-field").val()
@searchFor(text)

setAndSearchFor: (text) ->
@showSearch()
@$(".post-search-field").val(text)
@searchFor(text)

searchFor: (text, callback, value) ->
@mode = 'search'
@current_search = text
Expand All @@ -412,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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: =>
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ if Backbone?
events:
"click .discussion-submit-post": "submitComment"

# TODO tags
# Until we decide what to do w/ tags, removing them.
#"click .thread-tag": "tagSelected"

$: (selector) ->
@$el.find(selector)

Expand All @@ -27,10 +23,6 @@ if Backbone?
@renderShowView()
@renderAttrs()

# TODO tags
# Until we decide what to do w/ tags, removing them.
#@renderTags()

@$("span.timeago").timeago()
@makeWmdEditor "reply-body"
@renderResponses()
Expand All @@ -40,21 +32,6 @@ if Backbone?
if @responsesRequest?
@responsesRequest.abort()

# TODO tags
# Until we decide what to do w/ tags, removing them.
#renderTags: ->
# # tags
# for tag in @model.get("tags")
# if !tags
# tags = $('<div class="thread-tags">')
# tags.append("<a href='#' class='thread-tag'>#{tag}</a>")
# @$(".post-body").after(tags)

# TODO tags
# Until we decide what to do w tags, removing them.
#tagSelected: (e) ->
# @trigger "tag:selected", $(e.target).html()

renderResponses: ->
setTimeout(=>
@$el.find(".loading").show()
Expand Down Expand Up @@ -116,10 +93,6 @@ if Backbone?
newTitle = @editView.$(".edit-post-title").val()
newBody = @editView.$(".edit-post-body textarea").val()

# TODO tags
# Until we decide what to do w/ tags, removing them.
#newTags = @editView.$(".edit-post-tags").val()

url = DiscussionUtil.urlFor('update_thread', @model.id)

DiscussionUtil.safeAjax
Expand All @@ -133,31 +106,20 @@ if Backbone?
title: newTitle
body: newBody

# TODO tags
# Until we decide what to do w/ tags, removing them.
#tags: newTags

error: DiscussionUtil.formErrorHandler(@$(".edit-post-form-errors"))
success: (response, textStatus) =>
# TODO: Move this out of the callback, this makes it feel sluggish
@editView.$(".edit-post-title").val("").attr("prev-text", "")
@editView.$(".edit-post-body textarea").val("").attr("prev-text", "")
@editView.$(".edit-post-tags").val("")
@editView.$(".edit-post-tags").importTags("")
@editView.$(".wmd-preview p").html("")

@model.set
title: newTitle
body: newBody
tags: response.content.tags

@createShowView()
@renderShowView()

# TODO tags
# Until we decide what to do w/ tags, removing them.
#@renderTags()

createEditView: () ->

if @showView?
Expand Down Expand Up @@ -203,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ if Backbone?
@renderShowView()
@renderAttrs()

# TODO tags commenting out til we decide what to do with tags
#@renderTags()

@$("span.timeago").timeago()
@$el.find('.post-extended-content').hide()
if @expanded
Expand Down
Loading