MediaWiki:Common.js : Différence entre versions

De Canard Wiki
Sauter à la navigation Sauter à la recherche
 
(31 révisions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
 
var customizeToolbar = function () {
 
var customizeToolbar = function () {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
+
section: 'advanced',
group: 'format',
+
group: 'format',
tools: {
+
tools: {
"youtube": {
+
"youtube": {
label: 'youtube',
+
label: 'youtube',
type: 'button',
+
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
+
icon: 'https://canards-fantasy.fr/mediawiki/resources/assets/youtube.png',
action: {
+
action: {
type: 'encapsulate',
+
type: 'encapsulate',
options: {
+
options: {
pre: "<youtube> ",
+
pre: "<html5Media height=\"720\" width=\"1024\">",
post: " </youtube>"
+
                                                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>"
 +
}
 
}
 
}
 
}
 
}
 
}
 
}
}
+
} );
} );
 
 
};
 
};
  
Ligne 27 : Ligne 101 :
 
$.when(
 
$.when(
 
mw.loader.using( 'ext.wikiEditor' ), $.ready
 
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
+
).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=["#333","#005fd6","#007f5b","#03478e","#06037f","#07f687","#0a6afb","#0a8a92","#0d73ee","#0e03ab","#0e78bf","#119b87","#158547","#1e732a","#1ff078","#20eac2","#22ff9b","#245303","#24e002","#24f93e","#2ca04f","#2f75b2","#2fbd33","#301df2","#3171a6","#31b64e","#326a89","#33aab5","#36532f","#3780c0","#37f7ec","#3a0264","#3af86f","#434f9e","#488479","#48ad7c","#49e10c","#4a933b","#4b4cd8","#4bc2f3","#4e7e1d","#4feb8e","#572094","#58f5f2","#59335a","#5ac518","#5e0821","#5e5922","#5f74ca","#601225","#6066e5","#6210db","#63ed4f","#67baf8","#693b7d","#72c0b2","#742722","#74381f","#78741a","#7d1dba","#7f5268","#848344","#85ee08","#89f42e","#8b87f4","#8d2bed","#8ff2b7","#904e1e","#926f4b","#931f64","#932b0c","#944f9d","#9684fc","#9afd59","#9b5764","#9d5d72","#a248a4","#a3ebc5","#a5f846","#a78fb4","#aa3754","#acb153","#b14428","#b2252e","#b70eb5","#b8f19b","#bbade4","#bbb8d9","#c182a9","#c2837a","#c43f61","#c46d44","#c98c74","#cc3d1b","#ce87c0","#cec129","#d1433b","#dd4006","#e88088","#e99f62","#ebd948","#ecc92a","#ecdc5c","#f063f9","#f2918b","#f30dce","#f55097","#fa6a60","#faa2c5"];
 +
window.setInterval(function(){
 +
$(".blinkotron").each(function(){
 +
shuffleArray(blinkcolor);
 +
var pos = $(this).data("pos");
 +
if(pos != null){
 +
if(pos >= blinkcolor.length){
 +
shuffleArray(blinkcolor);
 +
$(this).data("pos", 0);
 +
$(this).css("color",blinkcolor[0]);
 +
}else{
 +
$(this).data("pos",pos+1);
 +
$(this).css("color",blinkcolor[pos]);
 +
}
 +
}else{
 +
$(this).data("pos",0);
 +
$(this).css("color",blinkcolor[0]);
 +
}
 +
});
 +
},200);
 +
}
 +
});
 +
 +
function shuffleArray(array) {
 +
    for (var i = array.length - 1; i > 0; i--) {
 +
        var j = Math.floor(Math.random() * (i + 1));
 +
        var temp = array[i];
 +
        array[i] = array[j];
 +
        array[j] = temp;
 +
    }
 
}
 
}

Version actuelle datée du 3 mai 2018 à 13:58

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=["#333","#005fd6","#007f5b","#03478e","#06037f","#07f687","#0a6afb","#0a8a92","#0d73ee","#0e03ab","#0e78bf","#119b87","#158547","#1e732a","#1ff078","#20eac2","#22ff9b","#245303","#24e002","#24f93e","#2ca04f","#2f75b2","#2fbd33","#301df2","#3171a6","#31b64e","#326a89","#33aab5","#36532f","#3780c0","#37f7ec","#3a0264","#3af86f","#434f9e","#488479","#48ad7c","#49e10c","#4a933b","#4b4cd8","#4bc2f3","#4e7e1d","#4feb8e","#572094","#58f5f2","#59335a","#5ac518","#5e0821","#5e5922","#5f74ca","#601225","#6066e5","#6210db","#63ed4f","#67baf8","#693b7d","#72c0b2","#742722","#74381f","#78741a","#7d1dba","#7f5268","#848344","#85ee08","#89f42e","#8b87f4","#8d2bed","#8ff2b7","#904e1e","#926f4b","#931f64","#932b0c","#944f9d","#9684fc","#9afd59","#9b5764","#9d5d72","#a248a4","#a3ebc5","#a5f846","#a78fb4","#aa3754","#acb153","#b14428","#b2252e","#b70eb5","#b8f19b","#bbade4","#bbb8d9","#c182a9","#c2837a","#c43f61","#c46d44","#c98c74","#cc3d1b","#ce87c0","#cec129","#d1433b","#dd4006","#e88088","#e99f62","#ebd948","#ecc92a","#ecdc5c","#f063f9","#f2918b","#f30dce","#f55097","#fa6a60","#faa2c5"];
		window.setInterval(function(){
			$(".blinkotron").each(function(){
				shuffleArray(blinkcolor);
				var pos = $(this).data("pos");
				if(pos != null){
					if(pos >= blinkcolor.length){
						shuffleArray(blinkcolor);
						$(this).data("pos", 0);
						$(this).css("color",blinkcolor[0]);
					}else{
						$(this).data("pos",pos+1);
						$(this).css("color",blinkcolor[pos]);
					}
				}else{
					$(this).data("pos",0);
					$(this).css("color",blinkcolor[0]);
				}
			});
		},200);
	}
});

function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}