MediaWiki:Gadget-DeferredDisplay.js: Difference between revisions
From Little Tail Wiki
Jump to navigationJump to search
Tag: Rollback |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
/** | /** | ||
* Deferred display of {{tl|nsfw}}-tagged images. | * Deferred display of {{tl|nsfw}}-tagged images. | ||
* @author | * 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, .mw-file-description').parent()) | |||
.one('click', function (e) { | |||
$(this).css('background', 'none').find('img').css({ | |||
visibility: '' | |||
}); | |||
e.preventDefault(); | |||
}) | |||
.css({ | |||
backgroundImage: 'url("https://static.jojowiki.com/images/customizations/Dialog-warning-yellow.png")', | |||
backgroundRepeat: 'no-repeat', | |||
backgroundPosition: 'center' | |||
}) | |||
.find('img').css({ | |||
visibility: 'hidden' | |||
}); | |||
}(jQuery, mediaWiki)); | |||
Revision as of 17:46, 11 March 2025
/** * 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, .mw-file-description').parent()) .one('click', function (e) { $(this).css('background', 'none').find('img').css({ visibility: '' }); e.preventDefault(); }) .css({ backgroundImage: 'url("https://static.jojowiki.com/images/customizations/Dialog-warning-yellow.png")', backgroundRepeat: 'no-repeat', backgroundPosition: 'center' }) .find('img').css({ visibility: 'hidden' }); }(jQuery, mediaWiki));