From 6c1bcb1044ea5812964b8012b649cd04de15f669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rie=20Michaud?= Date: Tue, 11 Aug 2020 14:20:35 -0400 Subject: [PATCH 1/3] Initial commit Accessibility --- css/jquery-comments.css | 96 ++++++++++++++++++++++++----------- js/jquery-comments.js | 110 ++++++++++++++++++++++++++-------------- 2 files changed, 138 insertions(+), 68 deletions(-) diff --git a/css/jquery-comments.css b/css/jquery-comments.css index fed5aba..7143702 100644 --- a/css/jquery-comments.css +++ b/css/jquery-comments.css @@ -10,6 +10,14 @@ http://viima.github.io/jquery-comments/*/ text-shadow: none; } +.jquery-comments input, +.jquery-comments select, +.jquery-comments button, +.jquery-comments textarea { + font-family: 'Arial'; + font-size: 1em; +} + .jquery-comments a[href]:not(.tag) { color: #2793e6; text-decoration: none; @@ -232,6 +240,8 @@ http://viima.github.io/jquery-comments/*/ } .jquery-comments .textarea-wrapper .close { + position: absolute; + top: 0; width: 1em; height: 1em; } @@ -259,7 +269,8 @@ http://viima.github.io/jquery-comments/*/ padding-top: .3em; } -.jquery-comments .textarea-wrapper .control-row > span { +.jquery-comments .textarea-wrapper .control-row > span, +.jquery-comments .textarea-wrapper .control-row > button { float: right; line-height: 1.6em; margin-top: .4em; @@ -270,30 +281,31 @@ http://viima.github.io/jquery-comments/*/ opacity: .5; } -.jquery-comments .textarea-wrapper .control-row > span:not(:first-child) { +.jquery-comments .textarea-wrapper .control-row > *:not(:first-child) { margin-right: .5em; } -.jquery-comments .textarea-wrapper .control-row > span.enabled { +.jquery-comments .textarea-wrapper .control-row > .enabled { opacity: 1; cursor: pointer; } -.jquery-comments .textarea-wrapper .control-row > span:not(.enabled) { +.jquery-comments .textarea-wrapper .control-row > span:not(.enabled), +.jquery-comments .textarea-wrapper .control-row > button:not(.enabled) { pointer-events: none; } -.jquery-comments .textarea-wrapper .control-row > span.enabled:hover { +.jquery-comments .textarea-wrapper .control-row > .enabled:hover { opacity: .9; } -.jquery-comments .textarea-wrapper .control-row > span.upload { +.jquery-comments .textarea-wrapper .control-row > .upload { position: relative; overflow: hidden; background-color: #999; } -.jquery-comments ul.navigation { +.jquery-comments .navigation { clear: both; color: #999; @@ -303,14 +315,15 @@ http://viima.github.io/jquery-comments/*/ margin-bottom: 0.5em; } -.jquery-comments ul.navigation .navigation-wrapper { +.jquery-comments .navigation .navigation-wrapper { position: relative; } -.jquery-comments ul.navigation li { +.jquery-comments .navigation button { display: inline-block; position: relative; padding: 0 1em; + line-height: 2em; cursor: pointer; text-align: center; @@ -320,12 +333,12 @@ http://viima.github.io/jquery-comments/*/ user-select: none; } -.jquery-comments ul.navigation li.active, -.jquery-comments ul.navigation li:hover { +.jquery-comments .navigation button.active, +.jquery-comments .navigation button:hover { color: #000; } -.jquery-comments ul.navigation li.active:after { +.jquery-comments .navigation button.active:after { content: " "; display: block; right: 0; @@ -336,39 +349,39 @@ http://viima.github.io/jquery-comments/*/ left: 0; } -.jquery-comments ul.navigation li[data-sort-key="attachments"] { +.jquery-comments .navigation button[data-sort-key="attachments"] { float: right; } -.jquery-comments ul.navigation li[data-sort-key="attachments"] i { +.jquery-comments .navigation button[data-sort-key="attachments"] i { margin-right: 0.25em; } -.jquery-comments ul.navigation .navigation-wrapper.responsive { +.jquery-comments .navigation .navigation-wrapper.responsive { display: none; } @media screen and (max-width: 600px) { - .jquery-comments ul.navigation .navigation-wrapper { + .jquery-comments .navigation .navigation-wrapper { display: none; } - .jquery-comments ul.navigation .navigation-wrapper.responsive { + .jquery-comments .navigation .navigation-wrapper.responsive { display: inline; } } -.jquery-comments.responsive ul.navigation .navigation-wrapper { +.jquery-comments.responsive .navigation .navigation-wrapper { display: none; } -.jquery-comments.responsive ul.navigation .navigation-wrapper.responsive { +.jquery-comments.responsive .navigation .navigation-wrapper.responsive { display: inline; } -.jquery-comments ul.navigation .navigation-wrapper.responsive li.title { +.jquery-comments .navigation .navigation-wrapper.responsive li.title { padding: 0 1.5em; } -.jquery-comments ul.navigation .navigation-wrapper.responsive li.title header:after { +.jquery-comments .navigation .navigation-wrapper.responsive li.title header:after { display: inline-block; content: ""; border-left: 0.3em solid rgba(0, 0, 0, 0) !important; @@ -379,8 +392,8 @@ http://viima.github.io/jquery-comments/*/ top: -0.1em; } -.jquery-comments ul.navigation .navigation-wrapper.responsive li.title.active header:after, -.jquery-comments ul.navigation .navigation-wrapper.responsive li.title:hover header:after { +.jquery-comments .navigation .navigation-wrapper.responsive li.title.active header:after, +.jquery-comments .navigation .navigation-wrapper.responsive li.title:hover header:after { border-top-color: #000; } @@ -524,6 +537,9 @@ http://viima.github.io/jquery-comments/*/ } .jquery-comments ul.main li.comment .comment-header .name { + margin: 0 0.5rem 0 0; + font-size: 1em; + display: inline-block; font-weight: bold; } @@ -684,20 +700,21 @@ http://viima.github.io/jquery-comments/*/ font-size: 2.4em; } -.jquery-comments ul.main li.comment .child-comments li.toggle-all { - padding-top: 0; +.jquery-comments ul.main li.comment .toggle-all { + margin-left: calc(3.6em + .5em); + padding: .5em; } -.jquery-comments ul.main li.comment .child-comments li.toggle-all span:first-child { +.jquery-comments ul.main li.comment .toggle-all span:first-child { vertical-align: middle; } -.jquery-comments ul.main li.comment .child-comments li.toggle-all span:first-child:hover { +.jquery-comments ul.main li.comment .toggle-all span:first-child:hover { cursor: pointer; text-decoration: underline; } -.jquery-comments ul.main li.comment .child-comments li.toggle-all .caret { +.jquery-comments ul.main li.comment .toggle-all .caret { display: inline-block; vertical-align: middle; width: 0; @@ -712,7 +729,7 @@ http://viima.github.io/jquery-comments/*/ border-right-color: rgba(0, 0, 0, 0); } -.jquery-comments ul.main li.comment .child-comments li.toggle-all .caret.up { +.jquery-comments ul.main li.comment .toggle-all .caret.up { border-top-color: rgba(0, 0, 0, 0); border-bottom-color: inherit; margin-top: -.2em; @@ -784,3 +801,24 @@ http://viima.github.io/jquery-comments/*/ .jquery-comments.read-only .actions { display: none; } + +/* Accessibility */ +input:focus, input:active, +textarea:focus, textarea:active +select:focus, select:active, +button:focus, button:active, +a:focus, a:active { + outline: 2px dotted #2793e6; +} + +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} \ No newline at end of file diff --git a/js/jquery-comments.js b/js/jquery-comments.js index 1814098..d4e1f9a 100644 --- a/js/jquery-comments.js +++ b/js/jquery-comments.js @@ -62,11 +62,11 @@ 'blur [contenteditable]' : 'checkEditableContentForChange', // Navigation - 'click .navigation li[data-sort-key]' : 'navigationElementClicked', + 'click .navigation button[data-sort-key]' : 'navigationElementClicked', 'click .navigation li.title' : 'toggleNavigationDropdown', // Main comenting field - 'click .commenting-field.main .textarea': 'showMainCommentingField', + 'focus .commenting-field.main .textarea': 'showMainCommentingField', 'click .commenting-field.main .close' : 'hideMainCommentingField', // All commenting fields @@ -88,7 +88,7 @@ 'click li.comment .ping' : 'pingClicked', // Other - 'click li.comment ul.child-comments .toggle-all': 'toggleReplies', + 'click li.comment .toggle-all': 'toggleReplies', 'click li.comment button.reply': 'replyButtonClicked', 'click li.comment button.edit': 'editButtonClicked', @@ -138,7 +138,7 @@ attachmentsText: 'Attachments', sendText: 'Send', replyText: 'Reply', - editText: 'Edit', + editText: 'Edit this comment', editedText: 'Edited', youText: 'You', saveText: 'Save', @@ -205,7 +205,15 @@ hashtagClicked: function(hashtag) {}, pingClicked: function(userId) {}, refresh: function() {}, - timeFormatter: function(time) {return new Date(time).toLocaleDateString()} + timeFormatter: function(time) {return new Date(time).toLocaleDateString()}, + + // Accessibility + replyToText: 'Replied to ', + upvoteText: 'Upvote this comment', + downvoteText: 'Downvote this comment', + likedText: ' people upvoted this comment', + deleteAttachmentText: 'Delete this attachment', + closeButtonText: 'Clear this comment' } }, @@ -593,7 +601,7 @@ var childCommentsEl = parentEl.find('.child-comments'); var childComments = childCommentsEl.find('.comment').not('.hidden'); - var toggleAllButton = childCommentsEl.find('li.toggle-all'); + var toggleAllButton = parentEl.find('.toggle-all'); childComments.removeClass('togglable-reply'); // Select replies to be hidden @@ -617,8 +625,10 @@ // Append button to toggle all replies if necessary if(!toggleAllButton.length) { - toggleAllButton = $('
  • ', { - 'class': 'toggle-all highlight-font-bold' + toggleAllButton = $('