Commit b6f53481 by Greg Price

Improve accessibility of forum follow buttons

They now include screen reader-friendly text, have the ARIA checkbox
role, activate on keypress (for space or enter), and occur in the DOM
after the header information (title, etc.)
parent 7aa80f63
...@@ -11,6 +11,8 @@ it pauses on the end time. ...@@ -11,6 +11,8 @@ it pauses on the end time.
Blades: Disallow users to enter video url's in http. Blades: Disallow users to enter video url's in http.
LMS: Improve the acessibility of the forum follow post buttons.
Blades: Fix bug when the speed can only be changed when the video is playing. Blades: Fix bug when the speed can only be changed when the video is playing.
LMS: Change bulk email implementation to use less memory, and to better handle LMS: Change bulk email implementation to use less memory, and to better handle
......
...@@ -37,9 +37,9 @@ if Backbone? ...@@ -37,9 +37,9 @@ if Backbone?
subscribed: (subscribed) -> subscribed: (subscribed) ->
if subscribed if subscribed
@$(".dogear").addClass("is-followed") @$(".dogear").addClass("is-followed").attr("aria-checked", "true")
else else
@$(".dogear").removeClass("is-followed") @$(".dogear").removeClass("is-followed").attr("aria-checked", "false")
ability: (ability) -> ability: (ability) ->
for action, selector of @abilityRenderer for action, selector of @abilityRenderer
...@@ -106,6 +106,26 @@ if Backbone? ...@@ -106,6 +106,26 @@ if Backbone?
@model.bind('change', @renderPartialAttrs, @) @model.bind('change', @renderPartialAttrs, @)
toggleFollowingKeypress: (event) ->
# Activate on spacebar or enter
if event.which == 32 or event.which == 13
@toggleFollowing(event)
toggleFollowing: (event) ->
event.preventDefault()
$elem = $(event.target)
url = null
if not @model.get('subscribed')
@model.follow()
url = @model.urlFor("follow")
else
@model.unfollow()
url = @model.urlFor("unfollow")
DiscussionUtil.safeAjax
$elem: $elem
url: url
type: "POST"
toggleFlagAbuseKeypress: (event) -> toggleFlagAbuseKeypress: (event) ->
# Activate on spacebar or enter # Activate on spacebar or enter
if event.which == 32 or event.which == 13 if event.which == 32 or event.which == 13
......
...@@ -4,6 +4,7 @@ if Backbone? ...@@ -4,6 +4,7 @@ if Backbone?
events: events:
"click .discussion-vote": "toggleVote" "click .discussion-vote": "toggleVote"
"click .action-follow": "toggleFollowing" "click .action-follow": "toggleFollowing"
"keypress .action-follow": "toggleFollowingKeypress"
"click .expand-post": "expandPost" "click .expand-post": "expandPost"
"click .collapse-post": "collapsePost" "click .collapse-post": "collapsePost"
...@@ -25,7 +26,6 @@ if Backbone? ...@@ -25,7 +26,6 @@ if Backbone?
@$el.html(Mustache.render(@template, params)) @$el.html(Mustache.render(@template, params))
@initLocal() @initLocal()
@delegateEvents() @delegateEvents()
@renderDogear()
@renderVoted() @renderVoted()
@renderAttrs() @renderAttrs()
@$("span.timeago").timeago() @$("span.timeago").timeago()
...@@ -34,10 +34,6 @@ if Backbone? ...@@ -34,10 +34,6 @@ if Backbone?
@renderResponses() @renderResponses()
@ @
renderDogear: ->
if window.user.following(@model)
@$(".dogear").addClass("is-followed")
renderVoted: => renderVoted: =>
if window.user.voted(@model) if window.user.voted(@model)
@$("[data-role=discussion-vote]").addClass("is-cast") @$("[data-role=discussion-vote]").addClass("is-cast")
...@@ -81,20 +77,6 @@ if Backbone? ...@@ -81,20 +77,6 @@ if Backbone?
else else
@vote() @vote()
toggleFollowing: (event) ->
$elem = $(event.target)
url = null
if not @model.get('subscribed')
@model.follow()
url = @model.urlFor("follow")
else
@model.unfollow()
url = @model.urlFor("unfollow")
DiscussionUtil.safeAjax
$elem: $elem
url: url
type: "POST"
vote: -> vote: ->
window.user.vote(@model) window.user.vote(@model)
url = @model.urlFor("upvote") url = @model.urlFor("upvote")
......
...@@ -7,6 +7,7 @@ if Backbone? ...@@ -7,6 +7,7 @@ if Backbone?
"keypress .discussion-flag-abuse": "toggleFlagAbuseKeypress" "keypress .discussion-flag-abuse": "toggleFlagAbuseKeypress"
"click .admin-pin": "togglePin" "click .admin-pin": "togglePin"
"click .action-follow": "toggleFollowing" "click .action-follow": "toggleFollowing"
"keypress .action-follow": "toggleFollowingKeypress"
"click .action-edit": "edit" "click .action-edit": "edit"
"click .action-delete": "_delete" "click .action-delete": "_delete"
"click .action-openclose": "toggleClosed" "click .action-openclose": "toggleClosed"
...@@ -25,7 +26,6 @@ if Backbone? ...@@ -25,7 +26,6 @@ if Backbone?
render: -> render: ->
@$el.html(@renderTemplate()) @$el.html(@renderTemplate())
@delegateEvents() @delegateEvents()
@renderDogear()
@renderVoted() @renderVoted()
@renderFlagged() @renderFlagged()
@renderPinned() @renderPinned()
...@@ -36,10 +36,6 @@ if Backbone? ...@@ -36,10 +36,6 @@ if Backbone?
@highlight @$("h1,h3") @highlight @$("h1,h3")
@ @
renderDogear: ->
if window.user.following(@model)
@$(".dogear").addClass("is-followed")
renderVoted: => renderVoted: =>
if window.user.voted(@model) if window.user.voted(@model)
@$("[data-role=discussion-vote]").addClass("is-cast") @$("[data-role=discussion-vote]").addClass("is-cast")
...@@ -94,20 +90,6 @@ if Backbone? ...@@ -94,20 +90,6 @@ if Backbone?
else else
@vote() @vote()
toggleFollowing: (event) ->
$elem = $(event.target)
url = null
if not @model.get('subscribed')
@model.follow()
url = @model.urlFor("follow")
else
@model.unfollow()
url = @model.urlFor("unfollow")
DiscussionUtil.safeAjax
$elem: $elem
url: url
type: "POST"
vote: -> vote: ->
window.user.vote(@model) window.user.vote(@model)
url = @model.urlFor("upvote") url = @model.urlFor("upvote")
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
<script type="text/template" id="thread-show-template"> <script type="text/template" id="thread-show-template">
<div class="discussion-post"> <div class="discussion-post">
<div><a href="javascript:void(0)" class="dogear action-follow" data-tooltip="follow"></a></div>
<header> <header>
${"<% if (obj.group_id) { %>"} ${"<% if (obj.group_id) { %>"}
<div class="group-visibility-label">${"<%- obj.group_string%>"}</div> <div class="group-visibility-label">${"<%- obj.group_string%>"}</div>
...@@ -45,6 +44,9 @@ ...@@ -45,6 +44,9 @@
${_("&bull; This thread is closed.")} ${_("&bull; This thread is closed.")}
</span> </span>
</p> </p>
<a href="javascript:void(0)" class="dogear action-follow" data-tooltip="follow" role="checkbox" aria-checked="false">
<span class="sr">${_("Follow this post")}</span>
</a>
</header> </header>
<div class="post-body">${'<%- body %>'}</div> <div class="post-body">${'<%- body %>'}</div>
......
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