Merge "[a11y] Add title attributes to logout, talk and history and DRY up code."

This commit is contained in:
jenkins-bot 2021-10-19 16:36:58 +00:00 committed by Gerrit Code Review
commit b1dd172a5f
3 changed files with 18 additions and 9 deletions

View file

@ -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 )
] );
}

View file

@ -1,4 +1,4 @@
{{!-- The #pt-logout ID is required for the AJAX enabled logout in mediawiki.page.ready to work.}}
<div id="pt-logout" class="vector-user-menu-logout">
<div id="pt-logout" class="vector-user-menu-logout" title="{{msg-tooltip-pt-logout}}">
{{{htmlLogout}}}
</div>

View file

@ -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 );
}