« MediaWiki:Common.js » : différence entre les versions

De Wikimedica
Aucun résumé des modifications
(Animation pour les ...)
 
(9 versions intermédiaires par le même utilisateur non affichées)
Ligne 14 : Ligne 14 :
/* Menu de gauche collapsible et en tête (Gestion:Tâches/Liste/221/13) */
/* Menu de gauche collapsible et en tête (Gestion:Tâches/Liste/221/13) */
$('#p-tb-label').addClass("not-collapsed");
$('#p-tb-label').addClass("not-collapsed");
$('#p-tb-label').siblings('.body').toggleClass( "collapsed" );
$('#p-tb-label').siblings().toggleClass( "collapsed" );


$('#p-tb-label').click(function(event) {
$('#p-tb-label').click(function(event) {
     console.log(event);
     console.log(event);
     $(event.target).siblings('.body').toggleClass( "collapsed" );
     $(event.target).siblings().toggleClass( "collapsed" );
     $(event.target).toggleClass( "not-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.
$('.collapse').click(); // Collaspe all by default.
Ligne 32 : Ligne 25 :
/* 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");
var bg;


if(namespace == 0) // if on the main namespace.
if(namespace == 0) // if on the main namespace.
Ligne 38 : Ligne 32 :
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 an image was feteched.
if(img) { $("#firstHeading-wrapper").css("background-image", "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")"); }
if(img) { bg = "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 53 : Ligne 47 :
} ).done( function ( data ) {
} ).done( function ( data ) {
    pages = data.query.pages;
    pages = data.query.pages;
    debugger;
    if(thumb = pages[Object.keys(pages)[0]].thumbnail) // If there is thumbnail for that page.
    if(thumb = pages[Object.keys(pages)[0]].thumbnail) // If there is thumbnail for that page.
    {
    {
    img = thumb.source;
    img = thumb.source;
    $("#firstHeading-wrapper").css("background-image", "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")");
    bg = "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")";
    }
    }
} );
} );
});
});
}
}
if(bg) { $('<style>#firstHeading-wrapper { background-image: '+ bg +' }</style>').appendTo('body'); }
// This code goes with Module:Collapsible list.
$(".collapsible-list-toggle").click(function() {
if($(this).html() == '[+]')
{ $(this).html('[-]').prev().fadeIn().prev().toggle(); }
else { $(this).html('[+]').prev().fadeOut().prev().toggle(); }
});

Dernière version du 13 mars 2024 à 17:30

/* 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().toggleClass( "collapsed" );

$('#p-tb-label').click(function(event) {
    console.log(event);
    $(event.target).siblings().toggleClass( "collapsed" );
    $(event.target).toggleClass( "not-collapsed" );
});
$('.collapse').click(); // Collaspe all by default.

/* Add heading image (see Gestion:Tâches/Liste/564) */
var namespace = mw.config.get("wgNamespaceNumber");
var bg;

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) { bg = "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: 'pageimages',
		    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;
		    	bg = "linear-gradient(0deg, black 0%, #00000032 30%), url(" + img + ")";
		    }
		} );
	});
}
if(bg) { $('<style>#firstHeading-wrapper { background-image: '+ bg +' }</style>').appendTo('body'); }

// This code goes with Module:Collapsible list. 
$(".collapsible-list-toggle").click(function() { 
	if($(this).html() == '[+]') 
	{ $(this).html('[-]').prev().fadeIn().prev().toggle(); } 
	else { $(this).html('[+]').prev().fadeOut().prev().toggle(); }
});