« MediaWiki:Common.js » : différence entre les versions
(Chargement du module mediawiki.api) |
Aucun résumé des modifications |
||
Ligne 32 : | Ligne 32 : | ||
/* Add heading image (see Gestion:Tâches/Liste/564) */ | /* Add heading image (see Gestion:Tâches/Liste/564) */ | ||
var namespace = mw.config.get("wgNamespaceNumber"); | var namespace = mw.config.get("wgNamespaceNumber"); | ||
if(namespace == 0) // if on the main namespace. | if(namespace == 0) // if on the main namespace. | ||
{ | { | ||
// Retrieve the image in the HTML. | // Retrieve the image in the HTML. | ||
img = $(".mw-capiunto-infobox-spanning").find("img").first().attr("src"); | img = $(".mw-capiunto-infobox-spanning").find("img").first().attr("src"); | ||
// If an image was feteched. | |||
if(img) { $("#firstHeading-wrapper").css("background-image", "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")"); } | |||
} | } | ||
else if(namespace == 1) // If on the talk namespace. | else if(namespace == 1) // If on the talk namespace. | ||
Ligne 58 : | Ligne 61 : | ||
}); | }); | ||
} | } | ||
Version du 8 avril 2022 à 00:58
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
mw.loader.load( '/index.php?title=MediaWiki:Welcome-modal-dialog.js&action=raw&ctype=text/javascript' );
// Mermaid does not seem to load in talk namespaces. This script forces it.
if(mw.config.get('wgNamespaceNumber') % 2 && $('.ext-mermaid').length)
{
setTimeout(function() {
var config = mw.config.get( 'mermaid' );
mw.loader.using( [ 'mediawiki.api', 'ext.mermaid', 'ext.mermaid.theme.' + config.theme ] );
}, 3000);
}
/* Menu de gauche collapsible et en tête (Gestion:Tâches/Liste/221/13) */
$('#p-tb-label').addClass("not-collapsed");
$('#p-tb-label').siblings('.body').toggleClass( "collapsed" );
$('#p-tb-label').click(function(event) {
console.log(event);
$(event.target).siblings('.body').toggleClass( "collapsed" );
$(event.target).toggleClass( "not-collapsed" );
/* Prise en compte des iframe (e.g. fil de discussion) */
/*
if ($(event.target).parent().parent().nextUntil('h2').find("iframe").css( "height") == '0px'){
$(event.target).parent().parent().nextUntil('h2').find("iframe").css( "height", "");
}¸
*/
});
$('.collapse').click(); // Collaspe all by default.
/* Add heading image (see Gestion:Tâches/Liste/564) */
var namespace = mw.config.get("wgNamespaceNumber");
if(namespace == 0) // if on the main namespace.
{
// Retrieve the image in the HTML.
img = $(".mw-capiunto-infobox-spanning").find("img").first().attr("src");
// If an image was feteched.
if(img) { $("#firstHeading-wrapper").css("background-image", "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")"); }
}
else if(namespace == 1) // If on the talk namespace.
{
mw.loader.using('mediawiki.api', function () {
// Retrieve the image using the API.
var api = new mw.Api();
api.get( {
action: 'query',
prop: 'pagesimages',
titles: mw.config.get("wgTitle"),
pithumbsize: 300
} ).done( function ( data ) {
pages = data.query.pages;
if(thumb = pages[Object.keys(pages)[0]].thumbnail) // If there is thumbnail for that page.
{
img = thumb.source;
$("#firstHeading-wrapper").css("background-image", "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")");
}
} );
});
}