mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-12-18 08:40:39 +00:00
22 lines
629 B
JavaScript
22 lines
629 B
JavaScript
|
/*!
|
||
|
* Add file description links to ImageMap images.
|
||
|
*/
|
||
|
( function () {
|
||
|
mw.hook( 'wikipage.content' ).add( function ( $content ) {
|
||
|
$content.find(
|
||
|
'figure[class*="mw-ext-imagemap-desc-"] > :not(figcaption) .mw-file-element'
|
||
|
).each( function () {
|
||
|
var resource = this.getAttribute( 'resource' );
|
||
|
if ( !resource ) {
|
||
|
return;
|
||
|
}
|
||
|
var inner = this.parentNode;
|
||
|
inner.classList.add( 'mw-ext-imagemap-inner' );
|
||
|
var desc = this.ownerDocument.createElement( 'a' );
|
||
|
desc.setAttribute( 'href', resource );
|
||
|
desc.classList.add( 'mw-ext-imagemap-desc-link' );
|
||
|
inner.appendChild( desc );
|
||
|
} );
|
||
|
} );
|
||
|
}() );
|