mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-11-27 15:40:03 +00:00
b2113e0154
The approach taken here is the same as in core for magnify links on thumbs in Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37 The gist is that resource attributes are added on the mw-file-element so that the necessary url is present in the html. A class is also added to the wrapper element that designates where the link should be positioned. Finally, a script adds the link which styles in appropriately. Bug: T329364 Depends-On: Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37 Change-Id: I20130fd39135dfd5074590ee9c2b6e01693384e4
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 );
|
|
} );
|
|
} );
|
|
}() );
|