MediaWiki:Gadget-DeferredDisplay.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* Deferred display of {{tl|nsfw}}-tagged images.
* jshint validation
* @author Dschwen, 2013
*/
(function ($, mw) {
// nothing should be tagged outside these pages yet
var fpc = "Featured picture candidate";
var ti = mw.config.get("wgTitle");
if ($.inArray(mw.config.get('wgNamespaceNumber'), [4, 5, 10, 11, 14, 15]) === -1 || (ti.indexOf(fpc) === -1 && ti !== "Nsfw/sandbox"))
return;
// wrap non thumb images first
$('img[alt*=NSFWTAG]').each(function (i, e) {
$(e).wrap($('<div>').css({
display: 'inline-block',
width: $(e).width() + 'px',
height: $(e).height() + 'px',
backgroundColor: '#eee'
}));
}).parent().add($('.thumbinner,.gallerybox').has('.nsfwelement').find('.image').parent())
.one('click', function (e) {
$(this).css('background', 'none').find('img').css({
visibility: ''
});
e.preventDefault();
})
.css({
backgroundImage: 'url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Dialog-warning-orange.svg/40px-Dialog-warning-orange.svg.png")',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center'
})
.find('img').css({
visibility: 'hidden'
});
}(jQuery, mediaWiki));