From 358d81ddce7bf1dab8bc921b76354476e2f27659 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Tue, 19 Oct 2021 08:27:18 -0700 Subject: [PATCH] [a11y] Add title attributes to logout, talk and history and DRY up code. * Addresses feedback in: ** T289816#7440605 ** T283505#7440585 Change-Id: I98abdab8c3eb20567af527e6a8bf75faa5670d6b --- includes/SkinVector.php | 1 + includes/templates/UserLinks__logout.mustache | 2 +- resources/skins.vector.js/stickyHeader.js | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 07213b9..9f2b979 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -257,6 +257,7 @@ class SkinVector extends SkinMustache { ]; return $templateParser->processTemplate( 'UserLinks__logout', [ + 'msg-tooltip-pt-logout' => $this->msg( 'tooltip-pt-logout' ), 'htmlLogout' => $this->makeLink( 'logout', $logoutLinkData ) ] ); } diff --git a/includes/templates/UserLinks__logout.mustache b/includes/templates/UserLinks__logout.mustache index aace293..1010a89 100644 --- a/includes/templates/UserLinks__logout.mustache +++ b/includes/templates/UserLinks__logout.mustache @@ -1,4 +1,4 @@ {{!-- The #pt-logout ID is required for the AJAX enabled logout in mediawiki.page.ready to work.}} -
+
{{{htmlLogout}}}
diff --git a/resources/skins.vector.js/stickyHeader.js b/resources/skins.vector.js/stickyHeader.js index f365696..24679e0 100644 --- a/resources/skins.vector.js/stickyHeader.js +++ b/resources/skins.vector.js/stickyHeader.js @@ -23,6 +23,17 @@ function copyAttribute( from, to, attribute ) { } } +/** + * Copies attribute from an element to another. + * + * @param {Element} from + * @param {Element} to + */ +function copyButtonAttributes( from, to ) { + copyAttribute( from, to, 'href' ); + copyAttribute( from, to, 'title' ); +} + /** * Suffixes an attribute with a value that indicates it * relates to the sticky header to support click tracking instrumentation. @@ -80,13 +91,13 @@ function prepareIcons( header, history, talk ) { } if ( history ) { - copyAttribute( history, historySticky, 'href' ); + copyButtonAttributes( history, historySticky ); } else { // @ts-ignore historySticky.parentNode.removeChild( historySticky ); } if ( talk ) { - copyAttribute( talk, talkSticky, 'href' ); + copyButtonAttributes( talk, talkSticky ); } else { // @ts-ignore talkSticky.parentNode.removeChild( talkSticky ); @@ -132,15 +143,12 @@ function prepareEditIcons( } else if ( isProtected ) { removeNode( wikitextSticky ); removeNode( primaryEditSticky ); - copyAttribute( primaryEdit, protectedSticky, 'href' ); - copyAttribute( primaryEdit, protectedSticky, 'title' ); + copyButtonAttributes( primaryEdit, protectedSticky ); } else { removeNode( protectedSticky ); - copyAttribute( primaryEdit, primaryEditSticky, 'href' ); - copyAttribute( primaryEdit, primaryEditSticky, 'title' ); + copyButtonAttributes( primaryEdit, primaryEditSticky ); if ( secondaryEdit ) { - copyAttribute( secondaryEdit, wikitextSticky, 'href' ); - copyAttribute( secondaryEdit, wikitextSticky, 'title' ); + copyButtonAttributes( secondaryEdit, wikitextSticky ); } else { removeNode( wikitextSticky ); }