Commit 21169cbb by Greg Price

Merge pull request #1707 from edx/gprice/forum-thread-list-focus-trap

Add error recovery and focus trap to thread loading in forum sidebar
parents 82092bdd 95932610
...@@ -5,6 +5,11 @@ These are notable changes in edx-platform. This is a rolling list of changes, ...@@ -5,6 +5,11 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected. the top. Include a label indicating the component affected.
LMS: Trap focus on the loading element when a user loads more threads
in the forum sidebar to improve accessibility.
LMS: Add error recovery when a user loads more threads in the forum sidebar.
LMS: Add a user-visible alert modal when a forums AJAX request fails. LMS: Add a user-visible alert modal when a forums AJAX request fails.
Blades: Add template for checkboxes response to studio. BLD-193. Blades: Add template for checkboxes response to studio. BLD-193.
......
...@@ -25,9 +25,8 @@ if Backbone? ...@@ -25,9 +25,8 @@ if Backbone?
@add model @add model
model model
retrieveAnotherPage: (mode, options={}, sort_options={})-> retrieveAnotherPage: (mode, options={}, sort_options={}, error=null)->
@current_page += 1 data = { page: @current_page + 1 }
data = { page: @current_page }
switch mode switch mode
when 'search' when 'search'
url = DiscussionUtil.urlFor 'search' url = DiscussionUtil.urlFor 'search'
...@@ -59,6 +58,7 @@ if Backbone? ...@@ -59,6 +58,7 @@ if Backbone?
@reset new_collection @reset new_collection
@pages = response.num_pages @pages = response.num_pages
@current_page = response.page @current_page = response.page
error: error
sortByDate: (thread) -> sortByDate: (thread) ->
# #
......
...@@ -87,6 +87,13 @@ class @DiscussionUtil ...@@ -87,6 +87,13 @@ class @DiscussionUtil
"notifications_status" : "/notification_prefs/status" "notifications_status" : "/notification_prefs/status"
}[name] }[name]
@makeFocusTrap: (elem) ->
elem.keydown(
(event) ->
if event.which == 9 # Tab
event.preventDefault()
)
@discussionAlert: (header, body) -> @discussionAlert: (header, body) ->
if $("#discussion-alert").length == 0 if $("#discussion-alert").length == 0
alertDiv = $("<div class='modal' role='alertdialog' id='discussion-alert' aria-describedby='discussion-alert-message'/>").css("display", "none") alertDiv = $("<div class='modal' role='alertdialog' id='discussion-alert' aria-describedby='discussion-alert-message'/>").css("display", "none")
...@@ -99,12 +106,7 @@ class @DiscussionUtil ...@@ -99,12 +106,7 @@ class @DiscussionUtil
" <button class='dismiss'>OK</button>" + " <button class='dismiss'>OK</button>" +
"</div>" "</div>"
) )
# Capture focus @makeFocusTrap(alertDiv.find("button"))
alertDiv.find("button").keydown(
(event) ->
if event.which == 9 # Tab
event.preventDefault()
)
alertTrigger = $("<a href='#discussion-alert' id='discussion-alert-trigger'/>").css("display", "none") alertTrigger = $("<a href='#discussion-alert' id='discussion-alert-trigger'/>").css("display", "none")
alertTrigger.leanModal({closeButton: "#discussion-alert .dismiss", overlay: 1, top: 200}) alertTrigger.leanModal({closeButton: "#discussion-alert .dismiss", overlay: 1, top: 200})
$("body").append(alertDiv).append(alertTrigger) $("body").append(alertDiv).append(alertTrigger)
......
...@@ -124,8 +124,11 @@ if Backbone? ...@@ -124,8 +124,11 @@ if Backbone?
loadMorePages: (event) -> loadMorePages: (event) ->
if event if event
event.preventDefault() event.preventDefault()
@$(".more-pages").html('<div class="loading-animation"><span class="sr">Loading more threads</span></div>') @$(".more-pages").html('<div class="loading-animation" tabindex=0><span class="sr" role="alert">Loading more threads</span></div>')
@$(".more-pages").addClass("loading") @$(".more-pages").addClass("loading")
loadingDiv = @$(".more-pages .loading-animation")
DiscussionUtil.makeFocusTrap(loadingDiv)
loadingDiv.focus()
options = {} options = {}
switch @mode switch @mode
when 'search' when 'search'
...@@ -156,7 +159,11 @@ if Backbone? ...@@ -156,7 +159,11 @@ if Backbone?
$(".post-list a").first()?.focus() $(".post-list a").first()?.focus()
) )
@collection.retrieveAnotherPage(@mode, options, {sort_key: @sortBy}) error = =>
@renderThreads()
DiscussionUtil.discussionAlert("Sorry", "We had some trouble loading more threads. Please try again.")
@collection.retrieveAnotherPage(@mode, options, {sort_key: @sortBy}, error)
renderThread: (thread) => renderThread: (thread) =>
content = $(_.template($("#thread-list-item-template").html())(thread.toJSON())) content = $(_.template($("#thread-list-item-template").html())(thread.toJSON()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment