mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-11 16:49:26 +00:00
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:
parent
8cac9f4aee
commit
ee8da566e3
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
3
modules/ext.cite.highlighting.css
Normal file
3
modules/ext.cite.highlighting.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
:target .mw-cite-targeted-backlink {
|
||||
font-weight: bold;
|
||||
}
|
18
modules/ext.cite.highlighting.js
Normal file
18
modules/ext.cite.highlighting.js
Normal 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 );
|
||||
} );
|
||||
} );
|
||||
}() );
|
Loading…
Reference in a new issue