MediaWiki:Common.js
De Spinoza et Nous.
(Différences entre les versions)
| (2 révisions intermédiaires par un utilisateur sont masquées) | |||
| Ligne 157 : | Ligne 157 : | ||
//============================================================ | //============================================================ | ||
| + | // Bouton Comment dans wikieditor | ||
| + | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
| + | 'section': 'advanced', | ||
| + | 'group': 'format', | ||
| + | 'tools': { | ||
| + | 'comment': { | ||
| + | label: 'Comment', | ||
| + | type: 'button', | ||
| + | icon: 'http://upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png', | ||
| + | action: { | ||
| + | type: 'encapsulate', | ||
| + | options: { | ||
| + | pre: "<!-- ", | ||
| + | post: " -->" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } ); | ||
//============================================================ | //============================================================ | ||
| Ligne 286 : | Ligne 305 : | ||
| − | / | + | //============================================================ |
| − | == | + | // |
| − | + | // Boites deroulantes | |
| − | + | // | |
| − | + | //============================================================ | |
| − | + | ||
| − | |||
| − | + | var autoCollapse = 2; | |
| − | + | var collapseCaption = '[ Enrouler ]'; | |
| − | // | + | var expandCaption = '[ Dérouler ]'; |
| − | function toggleNavigationBar(indexNavigationBar) | + | |
| − | { | + | function collapseTable( tableIndex ) { |
| − | + | var Button = document.getElementById( "collapseButton" + tableIndex ); | |
| − | + | var Table = document.getElementById( "collapsibleTable" + tableIndex ); | |
| − | + | if ( !Table || !Button ) return false; | |
| − | + | ||
| − | + | var Rows = Table.getElementsByTagName( "tr" ); | |
| − | + | ||
| − | + | if ( Button.firstChild.data == collapseCaption ) { | |
| − | + | for ( var i = 1; i < Rows.length; i++ ) { | |
| − | + | Rows[i].style.display = "none"; | |
| − | + | } | |
| − | + | Button.firstChild.data = expandCaption; | |
| − | + | } else { | |
| − | ShowText = | + | for ( var i = 1; i < Rows.length; i++ ) { |
| − | + | Rows[i].style.display = Rows[0].style.display; | |
| + | } | ||
| + | Button.firstChild.data = collapseCaption; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function createCollapseButtons() { | ||
| + | var tableIndex = 0; | ||
| + | var NavigationBoxes = new Object(); | ||
| + | var Tables = document.getElementsByTagName( "table" ); | ||
| + | |||
| + | for ( var i = 0; i < Tables.length; i++ ) { | ||
| + | if ( hasClass( Tables[i], "collapsible" ) ) { | ||
| + | NavigationBoxes[ tableIndex ] = Tables[i]; | ||
| + | Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); | ||
| + | |||
| + | var Button = document.createElement( "span" ); | ||
| + | var ButtonLink = document.createElement( "a" ); | ||
| + | var ButtonText = document.createTextNode( collapseCaption ); | ||
| + | |||
| + | Button.style.styleFloat = "right"; | ||
| + | Button.style.cssFloat = "right"; | ||
| + | Button.style.fontWeight = "normal"; | ||
| + | Button.style.textAlign = "right"; | ||
| + | Button.style.width = "6em"; | ||
| + | |||
| + | ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); | ||
| + | ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); | ||
| + | ButtonLink.appendChild( ButtonText ); | ||
| + | |||
| + | Button.appendChild( ButtonLink ); | ||
| + | |||
| + | var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0]; | ||
| + | /* only add button and increment count if there is a header row to work with */ | ||
| + | if (Header) { | ||
| + | Header.insertBefore( Button, Header.childNodes[0] ); | ||
| + | tableIndex++; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | for (var i = 0; i < tableIndex; i++) { | ||
| + | if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) collapseTable( i ); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | addOnloadHook( createCollapseButtons ); | ||
| + | |||
| + | /* Pour {{Boîte déroulante}} */ | ||
| + | var NavigationBarShowDefault = 0; | ||
| + | |||
| + | function toggleNavigationBar(indexNavigationBar) { | ||
| + | var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); | ||
| + | var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); | ||
| + | |||
| + | if (!NavFrame || !NavToggle) return; | ||
| + | |||
| + | // ajout par Dake - permet de créer un titre en lieu et place du "Dérouler" grâce | ||
| + | // à l'attribut "title" du tag. | ||
| + | var ShowText; | ||
| + | |||
| + | if (NavFrame.title == undefined || NavFrame.title.length == 0 ) { | ||
| + | ShowText = expandCaption; | ||
| + | } else { | ||
ShowText = NavFrame.title; | ShowText = NavFrame.title; | ||
| − | + | } | |
| − | + | ||
| − | + | // if shown now | |
| − | + | if (NavToggle.firstChild.data == collapseCaption) { | |
| − | + | for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { | |
| − | + | if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'none'; | |
| − | + | if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'none'; | |
| − | + | if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = ShowText; | |
| − | + | } | |
| − | + | ||
| − | + | // if hidden now | |
| − | + | } else if (NavToggle.firstChild.data == ShowText) { | |
| − | + | for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { | |
| − | + | if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'block'; | |
| − | + | if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'block'; | |
| − | + | if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = collapseCaption; | |
| − | + | } | |
| − | + | } | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
} | } | ||
| − | + | ||
// adds show/hide-button to navigation bars | // adds show/hide-button to navigation bars | ||
| − | function createNavigationBarToggleButton() | + | function createNavigationBarToggleButton() { |
| − | { | + | var indexNavigationBar = 0; |
| − | + | var NavFrame; | |
| − | + | // iterate over all < div >-elements | |
| − | + | for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) { | |
| − | + | // if found a navigation bar | |
| − | + | if (hasClass(NavFrame, "NavFrame")) { | |
| − | + | indexNavigationBar++; | |
| − | + | var NavToggle = document.createElement("a"); | |
| − | + | NavToggle.className = 'NavToggle'; | |
| − | + | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); | |
| − | + | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); | |
| − | + | ||
| − | + | var NavToggleText = document.createTextNode(collapseCaption); | |
| − | + | NavToggle.appendChild(NavToggleText); | |
| − | + | ||
| − | + | // add NavToggle-Button as first div-element | |
| − | + | // in <div class="NavFrame"> | |
| − | + | NavFrame.insertBefore( NavToggle, NavFrame.firstChild ); | |
| − | + | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); | |
| − | + | } | |
| − | + | } | |
| − | + | // if more Navigation Bars found than Default: hide all | |
| − | + | if (NavigationBarShowDefault < indexNavigationBar) { | |
| − | + | for( var i=1; i<=indexNavigationBar; i++ ) { | |
| − | + | toggleNavigationBar(i); | |
| − | + | } | |
| − | + | } | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
} | } | ||
| − | + | ||
addOnloadHook(createNavigationBarToggleButton); | addOnloadHook(createNavigationBarToggleButton); | ||
| + | |||
| + | /* Test if an element has a certain class ************************************** | ||
| + | * | ||
| + | * Description: Uses regular expressions and caching for better performance. | ||
| + | * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]] | ||
| + | */ | ||
| + | |||
| + | var hasClass = (function () { | ||
| + | var reCache = {}; | ||
| + | return function (element, className) { | ||
| + | return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); | ||
| + | }; | ||
| + | })(); | ||
Version actuelle en date du 3 février 2012 à 01:14
/* N’importe quel JavaScript ici sera chargé pour n’importe quel utilisateur et pour chaque page accédée. */
/* <pre> <nowiki> */
/*
== Fonctions générales ==
<source lang="javascript">/*
* Fonctions générales de lancement de fonctions ou de script
*/
/**
* Installation d'une nouvelle fonction de cette façon :
* addOnloadHook(nom_de_la_fonction); (sans parenthèses)
* La procédure suivante ne doit plus être utilisée
*/
if (!window.aOnloadFunctions) {
var aOnloadFunctions = new Array();
}
window.onload = function() {
if (window.aOnloadFunctions) {
for (var _i=0; _i<aOnloadFunctions.length; _i++) {
aOnloadFunctions[_i]();
}
}
}
function addLoadEvent(func) {
addOnloadHook(func);
}
/**
* insertAfter : insérer un élément dans une page
*/
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
/**
* getElementsByClass : rechercher les éléments de la page dont le paramètre "class" est celui recherché
*/
function getElementsByClass(searchClass, node, tag) {
if (node == null) node = document;
if (tag == null) tag = '*';
return getElementsByClassName(node, tag, searchClass);
}
/**
* Teste si un élément contient la classe CSS spécifiée
* Utilise des expressions régulières et un cache pour de meilleures perfs
* Fonction importée depuis [[:en:MediaWiki:Common.js]]
* Auteurs : [[:en:User:Mike Dillon]], [[:en:User:R. Koot]], [[:en:User:SG]]
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
/**
* Insérer un JavaScript d'une page particulière, idée de Mickachu
*/
function loadJs(page) {
document.write('<script type="text/javascript" src="' +
'http://fr.wikipedia.org/w/index.php?title=' + page +
'&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
/**
* Projet JavaScript
*/
function obtenir(name) {
loadJs('MediaWiki:JSScripts/' + name);
}
/**
* Récupère la valeur du cookie
*/
function getCookieVal(name) {
var cookiePos = document.cookie.indexOf(name + "=");
var cookieValue = false;
if (cookiePos > -1) {
cookiePos += name.length + 1;
var endPos = document.cookie.indexOf(";", cookiePos);
if (endPos > -1)
cookieValue = document.cookie.substring(cookiePos, endPos);
else
cookieValue = document.cookie.substring(cookiePos);
}
return cookieValue;
}
/* Fin des fonctions générales</source> */
//============================================================
//
// Caractères spéciaux
//
//============================================================
/**
* Ajoutez le menu pour choisir des sous-ensembles de caractères spéciaux
* @note L'ordre de cette liste doit correspondre a celui de MediaWiki:Edittools !
*/
function addCharSubsetMenu() {
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
menu += "<option>Wiki</option>";
menu += "<option>Mathématiques</option>";
menu += "<option>Latin/Romain</option>";
menu += "<option>Grec</option>";
menu += "<option>Cyrillique</option>";
menu += "<option>Allemand</option>";
menu += "<option>Arabe</option>";
menu += "<option>Espagnol</option>";
menu += "<option>Espéranto</option>";
menu += "<option>Hébreu</option>";
menu += "<option>Hiéroglyphe</option>";
menu += "<option>Hollandais</option>";
menu += "<option>Italien</option>";
menu += "<option>Portugais</option>";
menu += "<option>Yiddish</option>";
menu += "<option>API</option>";
menu += "</select>";
specialchars.innerHTML = menu + specialchars.innerHTML;
/* default subset - try to use a cookie some day */
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
addLoadEvent(addCharSubsetMenu);
//============================================================
//
// Barre d'outil
//
//============================================================
// Bouton Comment dans wikieditor
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'comment': {
label: 'Comment',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png',
action: {
type: 'encapsulate',
options: {
pre: "<!-- ",
post: " -->"
}
}
}
}
} );
//============================================================
// Insertion de nouveaux boutons dans la barre d'outil
//============================================================
//Remplit la variable mwCustomEditButtons (voir /skins-1.5/commons/wikibits.js) pour ajouter des boutons à la barre d'outils
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText)
{
mwCustomEditButtons[mwCustomEditButtons.length] =
{"imageFile": imageFile,
"speedTip": speedTip,
"tagOpen": tagOpen,
"tagClose": tagClose,
"sampleText": sampleText};
}
addCustomButton('http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png','Sous-titre de niveau 3',"\n===","===\n",'Sous-titre');
addCustomButton('http://upload.wikimedia.org/wikipedia/en/5/5f/Button_center.png','Centrer',"<div style=\"text-align:center;\">","</div>",'Texte centré');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png','Texte justifié à droite',"<div style=\"text-align:right;\">","</div>",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png','Retrait',":","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/5/58/Button_small.png','Texte plus petit',"<small>","</small>",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png','Exposant',"<sup>","</sup>",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png','Insérer un bloc de citation',"<blockquote style=\"border: 1px solid #97D5DC; padding: 2em;\">\n","\n</blockquote>",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png','Rayer',"<s>","</s>",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/8/88/Btn_toolbar_enum.png','Énumération',"\n# élément 1\n# élément 2\n# élément 3","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_liste.png','Liste',"\n* élément A\n* élément B\n* élément C","",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png','Commentaire',"<!--","-->",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/9/93/Button_sub_link.png','Lien ancré',"[[#|","]]",'');
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png','à la ligne',"<br />","",'');
//Ressemble à la fonction de /skins-1.5/commons/wikibits.js pour insérer un autre lien que insertTags
function marque_tab()
{
var toolbar = document.getElementById('toolbar');
if (!toolbar) return false;
var textbox = document.getElementById('wpTextbox1');
if (!textbox) return false;
if (!document.selection && textbox.selectionStart == null)
return false;
var image = document.createElement("img");
image.width = 23;
image.height = 22;
image.src = 'http://upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png';
image.border = 0;
image.alt = 'Tableau';
image.title = 'Tableau';
image.style.cursor = "pointer";
image.onclick = function() {
popupTableau();
return false;
}
toolbar.appendChild(image);
}
addOnloadHook(marque_tab);
//============================================================
//
// Divers
//
//============================================================
/**
* Utilisation du modèle Modèle:Images
*/
function toggleImage(group, remindex, shwindex){
document.getElementById("ImageGroupsGr"+group+"Im"+remindex).style.display="none";
document.getElementById("ImageGroupsGr"+group+"Im"+shwindex).style.display="inline";
}
function ImageGroup(){
if (document.URL.match(/printable/g)) return;
var bc=document.getElementById("bodyContent");
var divs=bc.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length ; i++) {
if (divs[i].className != "ImageGroup") continue;
UnitNode=undefined;
search=divs[i].getElementsByTagName("div");
for (j = 0; j < search.length ; j++) {
if (search[j].className != "ImageGroupUnits") continue;
UnitNode=search[j];
break;
}
if (UnitNode==undefined) continue;
units=Array();
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (temp.className=="center") units.push(temp);
}
for (j = 0 ; j < units.length ; j++) {
currentimage=units[j];
currentimage.id="ImageGroupsGr"+i+"Im"+j;
var imghead = document.createElement("div");
var leftlink = document.createElement("a");
var rightlink = document.createElement("a");
if (j != 0) {
leftlink.href = "javascript:toggleImage("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="◀";
}
if (j != units.length - 1) {
rightlink.href = "javascript:toggleImage("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="▶";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
with(imghead) {
style.fontSize="110%";
style.fontweight="bold";
appendChild(leftlink);
appendChild(comment);
appendChild(rightlink);
}
currentimage.insertBefore(imghead,currentimage.childNodes[0]);
if (j != 0) {
currentimage.style.display="none";
}
}
}
}
addOnloadHook(ImageGroup);
//============================================================
//
// Boites deroulantes
//
//============================================================
var autoCollapse = 2;
var collapseCaption = '[ Enrouler ]';
var expandCaption = '[ Dérouler ]';
function collapseTable( tableIndex ) {
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) return false;
var Rows = Table.getElementsByTagName( "tr" );
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
Button.style.styleFloat = "right";
Button.style.cssFloat = "right";
Button.style.fontWeight = "normal";
Button.style.textAlign = "right";
Button.style.width = "6em";
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( ButtonLink );
var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
/* only add button and increment count if there is a header row to work with */
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
for (var i = 0; i < tableIndex; i++) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) collapseTable( i );
}
}
addOnloadHook( createCollapseButtons );
/* Pour {{Boîte déroulante}} */
var NavigationBarShowDefault = 0;
function toggleNavigationBar(indexNavigationBar) {
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) return;
// ajout par Dake - permet de créer un titre en lieu et place du "Dérouler" grâce
// à l'attribut "title" du tag.
var ShowText;
if (NavFrame.title == undefined || NavFrame.title.length == 0 ) {
ShowText = expandCaption;
} else {
ShowText = NavFrame.title;
}
// if shown now
if (NavToggle.firstChild.data == collapseCaption) {
for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'none';
if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'none';
if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = ShowText;
}
// if hidden now
} else if (NavToggle.firstChild.data == ShowText) {
for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'block';
if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'block';
if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = collapseCaption;
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
// iterate over all < div >-elements
for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) {
// if found a navigation bar
if (hasClass(NavFrame, "NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(collapseCaption);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in <div class="NavFrame">
NavFrame.insertBefore( NavToggle, NavFrame.firstChild );
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for( var i=1; i<=indexNavigationBar; i++ ) {
toggleNavigationBar(i);
}
}
}
addOnloadHook(createNavigationBarToggleButton);
/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
/*
* VraiTitre : Ajout du titre réel d'un article pour lequel MediaWiki n'affiche pas correctement
*/
function VraiTitre()
{
var balise = document.getElementById("vrai_titre");
if (!balise) return;
vrai_titre = balise.childNodes[0].nodeValue;
var titre = document.getElementsByTagName("H1")[0];
rectificatif = titre.appendChild(document.createElement("span"));
rectificatif.setAttribute ("style","color:#AAAAAA; font-size:0.7em; font-style:italic; display:inline;");
rectificatif.appendChild(document.createTextNode(" ("+ vrai_titre +")"));
}
addLoadEvent(VraiTitre);
/* </nowiki> </pre> */