Highlight backreference jump marks by making them bold

The separate "ext.cite.a11y" module is kept for (temporary)
compatibility with cached HTML, and should be removed in about
a month.

Browser tests will be added in a separate patch.

Bug: T205270
Change-Id: I26fe41c328157233cc5b06d38d2ba0f7b036a853
This commit is contained in:
Thiemo Kreuz 2018-11-15 18:32:38 +01:00 committed by Thiemo Kreuz (WMDE)
parent 8cac9f4aee
commit ee8da566e3
4 changed files with 36 additions and 1 deletions

View file

@ -77,6 +77,20 @@
"cite_references_link_many_accessibility_label"
]
},
"ext.cite.ux-enhancements": {
"scripts": [
"ext.cite.a11y.js",
"ext.cite.highlighting.js"
],
"styles": [
"ext.cite.a11y.css",
"ext.cite.highlighting.css"
],
"messages": [
"cite_references_link_accessibility_label",
"cite_references_link_many_accessibility_label"
]
},
"ext.cite.style": {
"class": "CiteCSSFileModule",
"styles": "ext.cite.style.css",

View file

@ -218,7 +218,7 @@ class Cite {
$this->mInCite = false;
$parserOutput = $parser->getOutput();
$parserOutput->addModules( 'ext.cite.a11y' );
$parserOutput->addModules( 'ext.cite.ux-enhancements' );
$parserOutput->addModuleStyles( 'ext.cite.styles' );
$frame->setVolatile();

View file

@ -0,0 +1,3 @@
:target .mw-cite-targeted-backlink {
font-weight: bold;
}

View file

@ -0,0 +1,18 @@
/**
* @author Thiemo Kreuz
*/
( function () {
'use strict';
mw.hook( 'wikipage.content' ).add( function ( $content ) {
// We are going to use the ID in the code below, so better be sure one is there.
$content.find( '.reference[id] > a' ).click( function () {
var id = $( this ).parent().attr( 'id' ),
className = 'mw-cite-targeted-backlink';
$content.find( '.' + className ).removeClass( className );
// The additional "*" avoids the "↑" (when there is only one backlink) becoming bold.
$content.find( '.mw-cite-backlink * a[href="#' + id + '"]' ).addClass( className );
} );
} );
}() );