MediaWiki:Common.js : Différence entre versions

De Canard Wiki
Sauter à la navigation Sauter à la recherche
Ligne 112 : Ligne 112 :
  
 
$(document).ready(function(){
 
$(document).ready(function(){
if($(".blinkotron").length() > 0){
+
if($(".blinkotron").length > 0){
 
var blinkcolor=["#c0392b","#884ea0","#2980b9","#1abc9c","#d4ac0d","#fff000","#333333"];
 
var blinkcolor=["#c0392b","#884ea0","#2980b9","#1abc9c","#d4ac0d","#fff000","#333333"];
 
window.setInterval(
 
window.setInterval(
Ligne 118 : Ligne 118 :
 
var pos = $(this).data("pos");
 
var pos = $(this).data("pos");
 
if(Number.isInteger(pos)){
 
if(Number.isInteger(pos)){
if(pos >= blinkcolor.length()){
+
if(pos >= blinkcolor.length){
 
$(this).data("pos") = 0;
 
$(this).data("pos") = 0;
 
$(this).css("color",blinkcolor[pos]);
 
$(this).css("color",blinkcolor[pos]);

Version du 3 mai 2018 à 13:29

var customizeToolbar = function () {
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
		section: 'advanced',
		group: 'format',
		tools: {
			"youtube": {
				label: 'youtube',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/youtube.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<html5Media height=\"720\" width=\"1024\">",
                                                periMsg: "https://www.youtube.com/watch?v=BpS_wkBq9BI",
						post: "</html5media>"
					}
				}
			},
			"pageLink": {
				label: 'Lien vers une page',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/pageLink.jpg',
				action: {
					type: 'encapsulate',
					options: {
						pre: "[[Titre de la page|Texte du lien]]",
						post: ""
					}
				}
			},
			"alertBlock": {
				label: 'Bloc d\'alert',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/alertblock.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<div class='alertBlock'>",
						post: "</div>"
					}
				}
			},
			"infoBlock": {
				label: 'Bloc d\'info',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/info.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<div class='alertInfo'>",
						post: "</div>"
					}
				}
			},
			"successBlock": {
				label: 'Bloc de succès (vert)',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/success.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<div class='alertSuccess'>",
						post: "</div>"
					}
				}
			},
			"spoiler": {
				label: 'Spoiler',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/spoiler.jpg',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<div class='spoiler'><span class='toggler'>Afficher</span><div class='spoiler-content'> ",
						post: " </div></div>"
					}
				}
			},
			"Audio": {
				label: 'lecteur audio',
				type: 'button',
				icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/note.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: "<html5media>",
                                                periMsg:"File:test.mp3|http://site/fichier_audio.mp3",
						post: "</html5media>"
					}
				}
			}
		}
	} );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
				).then( customizeToolbar );
		}
	} );
}

$(document).on("click",".toggler",function(e){
	$(e.target).parents(".spoiler").children(".spoiler-content").toggle();
	$(e.target).text() === "Afficher" ? $(e.target).text("Cacher") : $(e.target).text("Afficher");
});

$(document).ready(function(){
	if($(".blinkotron").length > 0){
		var blinkcolor=["#c0392b","#884ea0","#2980b9","#1abc9c","#d4ac0d","#fff000","#333333"];
		window.setInterval(
			$(".blinkotron").each(function(){
				var pos = $(this).data("pos");
				if(Number.isInteger(pos)){
					if(pos >= blinkcolor.length){
						$(this).data("pos") = 0;
						$(this).css("color",blinkcolor[pos]);
					}else{
						$(this).data("pos") = pos++;
						$(this).css("color",blinkcolor[pos]);
					}
				}else{
					$(this).data("pos") = 0;
					$(this).css("color",blinkcolor[pos]);
				}
			}),1000);
	}
});