2016-11-03 15:56:35 +00:00
|
|
|
(function (window) {
|
2016-11-03 13:44:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var ImageLink = {
|
|
|
|
init: function ($content) {
|
2016-11-03 15:11:23 +00:00
|
|
|
$content.find('.portable-infobox .pi-image > a.image').on('click', function () {
|
2016-11-03 13:44:29 +00:00
|
|
|
var $anchor = $(this),
|
2016-11-04 12:14:34 +00:00
|
|
|
fileName = $anchor.find('img[data-image-key]').data('image-key');
|
2016-11-03 13:44:29 +00:00
|
|
|
|
2016-11-04 12:14:34 +00:00
|
|
|
// If users create markup manually and there is no data-image-key then cancel the change
|
|
|
|
if (fileName) {
|
|
|
|
$anchor.attr('href', window.wgArticlePath.replace(/\$1/, 'File:' + fileName));
|
|
|
|
}
|
2016-11-03 13:44:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
mw.hook('wikipage.content').add(function ($content) {
|
|
|
|
ImageLink.init($content);
|
|
|
|
});
|
2016-11-03 15:56:35 +00:00
|
|
|
})(window);
|