Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4037377
ext.cite.a11y.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ext.cite.a11y.js
View Options
'use strict'
;
/**
* Adds accessibility attributes to citation links.
*
* @see https://phabricator.wikimedia.org/T40141
* @author Marius Hoch <hoo@online.de>
*/
mw
.
hook
(
'wikipage.content'
).
add
(
(
$content
)
=>
{
const
accessibilityLabelOne
=
mw
.
msg
(
'cite_references_link_accessibility_label'
);
const
accessibilityLabelMany
=
mw
.
msg
(
'cite_references_link_many_accessibility_label'
);
$content
.
find
(
'.mw-cite-backlink'
).
each
(
(
_
,
el
)
=>
{
const
$links
=
$
(
el
).
find
(
'a'
);
if
(
$links
.
length
>
1
)
{
// This citation is used multiple times. Let's only set the accessibility
// label on the first link, the following ones should then be
// self-explaining. This is needed to make sure this isn't getting too
// wordy.
$links
.
eq
(
0
).
prepend
(
$
(
'<span>'
)
.
addClass
(
'cite-accessibility-label'
)
// Also make sure we have at least one space between the accessibility
// label and the visual one
.
text
(
accessibilityLabelMany
+
' '
)
);
}
else
{
$links
.
attr
(
'aria-label'
,
accessibilityLabelOne
)
.
attr
(
'title'
,
accessibilityLabelOne
);
}
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/x-asm
Expires
Aug 15 2026, 03:37 (12 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
95/48/384b5500e3193e05b6892180d696
Default Alt Text
ext.cite.a11y.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment