MediaWiki:Common.js : Différence entre versions
De geoLwiki - Guide géologique du Luxembourg
(38 révisions intermédiaires par 2 utilisateurs non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ | /* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ | ||
− | |||
+ | /*############################################################################################*/ | ||
+ | /* Boutons spplémentaires dans l'éditeur */ | ||
− | + | ||
+ | if (mwCustomEditButtons) { | ||
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_enter.png", |
"speedTip": "Nouveau paragraphe", | "speedTip": "Nouveau paragraphe", | ||
"tagOpen": "<br />", | "tagOpen": "<br />", | ||
Ligne 14 : | Ligne 16 : | ||
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_liste.png", |
"speedTip": "Liste", | "speedTip": "Liste", | ||
− | "tagOpen": "* | + | "tagOpen": "* " , |
"tagClose": "", | "tagClose": "", | ||
− | "sampleText": ""}; | + | "sampleText": "élément 1 \n* élément 2"}; |
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_enum.png", |
"speedTip": "Énumération", | "speedTip": "Énumération", | ||
− | "tagOpen": "# | + | "tagOpen": "# ", |
"tagClose": "", | "tagClose": "", | ||
− | "sampleText": ""}; | + | "sampleText": "élément 1 \n# élément 2"}; |
− | + | /* | |
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_tableau.png", |
"speedTip": "Tableau", | "speedTip": "Tableau", | ||
− | "tagOpen": "", | + | "tagOpen": "{| border="1" cellpadding="10" cellspacing="0"\n", |
− | "tagClose": "", | + | "tagClose": "\n|}", |
− | "sampleText": ""}; | + | "sampleText": "|Orange\n|Apple\n|-\n|Bread\n|Pie\n|-\n|Butter\n|Ice cream"}; |
− | + | */ | |
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_gallery.png", |
"speedTip": "Galerie d'images", | "speedTip": "Galerie d'images", | ||
"tagOpen": "<gallery>", | "tagOpen": "<gallery>", | ||
− | "tagClose": "</gallery>", | + | "tagClose": "\n</gallery>", |
− | "sampleText": " | + | "sampleText": "\nImage:Exemple1.jpg|texte descriptif 1 \nImage:Exemple2.jpg|texte descriptif 2 \nImage:Exemple3.jpg|texte descriptif 3"}; |
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_modele.png", |
"speedTip": "Modèle", | "speedTip": "Modèle", | ||
"tagOpen": "{{", | "tagOpen": "{{", | ||
Ligne 51 : | Ligne 53 : | ||
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_category.png", |
"speedTip": "Catégorie", | "speedTip": "Catégorie", | ||
"tagOpen": "[[Catégorie:", | "tagOpen": "[[Catégorie:", | ||
Ligne 60 : | Ligne 62 : | ||
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_redirect.png", |
"speedTip": "Redirection", | "speedTip": "Redirection", | ||
"tagOpen": "#REDIRECT [[", | "tagOpen": "#REDIRECT [[", | ||
Ligne 66 : | Ligne 68 : | ||
"sampleText": "Insert text"}; | "sampleText": "Insert text"}; | ||
− | + | ||
mwCustomEditButtons[mwCustomEditButtons.length] = { | mwCustomEditButtons[mwCustomEditButtons.length] = { | ||
− | "imageFile": "http://geologie | + | "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_comment.png", |
− | + | "speedTip": "Commentaire visible uniquement aux éditeurs", | |
− | "tagOpen": "<!-- ", | + | "tagOpen": "<"+"!--", |
− | "tagClose": " -->", | + | "tagClose": "--"+">", |
− | "sampleText": " | + | "sampleText": "Insérer commentaire ici"}; |
− | + | ||
} | } | ||
Ligne 80 : | Ligne 82 : | ||
− | + | /*############################################################################################*/ | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
/* Commandes SOUS la fenêtre de l'éditeur installé le 29/10/08 ========================== */ | /* Commandes SOUS la fenêtre de l'éditeur installé le 29/10/08 ========================== */ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function includePage( name ) | function includePage( name ) | ||
{ | { | ||
− | + | document.write('<script type="text/javascript" src="' + wgScript + '?title=' | |
+ name | + name | ||
+ '&action=raw&ctype=text/javascript"><\/script>' | + '&action=raw&ctype=text/javascript"><\/script>' | ||
− | + | ); | |
} | } | ||
/* End of includePage */ | /* End of includePage */ | ||
− | + | ||
− | + | ||
/* Including extra .js pages */ | /* Including extra .js pages */ | ||
− | + | ||
// switches for scripts | // switches for scripts | ||
// TODO: migrate to JSConfig | // TODO: migrate to JSConfig | ||
// var load_extratabs = true; | // var load_extratabs = true; | ||
var load_edittools = true; | var load_edittools = true; | ||
− | + | ||
// extra drop down menu on editing for adding special characters | // extra drop down menu on editing for adding special characters | ||
includePage( 'MediaWiki:Edittools.js' ); | includePage( 'MediaWiki:Edittools.js' ); | ||
− | |||
− | |||
− | |||
− | |||
− | /* | + | /*############################################################################################*/ |
− | + | /* wikEd installation le 05/11/08 RC , http://en.wikipedia.org/wiki/User:Cacycle/wikEd_installation============== */ | |
− | + | ||
− | + | // install [[User:Cacycle/wikEd]] in-browser text editor | |
− | + | document.write('<script type="text/javascript" src="' | |
− | + | + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' | |
− | + | + '&action=raw&ctype=text/javascript"></' + 'script>'); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | /*############################################################################################*/ | ||
+ | /* ################################## copié de http://meta.wikimedia.org/w/index.php?title=MediaWiki:Common.js RC 07/11/08 */ | ||
/** Collapsible tables ********************************************************* | /** Collapsible tables ********************************************************* | ||
− | + | * | |
− | + | * Description: Allows tables to be collapsed, showing only the header. See | |
− | + | * [[Wikipedia:NavFrame]]. | |
− | + | * Maintainer on Wikipedia: [[User:R. Koot]] | |
− | + | */ | |
− | + | ||
− | + | ||
var autoCollapse = 2; | var autoCollapse = 2; | ||
− | var collapseCaption = " | + | var collapseCaption = "cacher ▲"; |
− | var expandCaption = " | + | var expandCaption = "afficher ▼" ; |
+ | function hasClass( element, className ) { | ||
+ | var Classes = element.className.split( " " ); | ||
+ | for ( var i = 0; i < Classes.length; i++ ) { | ||
+ | if ( Classes[i] == className ) { | ||
+ | return ( true ); | ||
+ | } | ||
+ | } | ||
+ | return ( false ); | ||
+ | } | ||
+ | |||
function collapseTable( tableIndex ) | 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() | 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( document.createTextNode( "[" ) ); | |
− | + | Button.appendChild( ButtonLink ); | |
− | + | Button.appendChild( document.createTextNode( "]" ) ); | |
− | + | ||
− | + | ||
− | + | 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 ); | addOnloadHook( createCollapseButtons ); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Version actuelle en date du 31 mai 2011 à 12:16
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ /*############################################################################################*/ /* Boutons spplémentaires dans l'éditeur */ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_enter.png", "speedTip": "Nouveau paragraphe", "tagOpen": "<br />", "tagClose": "", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_liste.png", "speedTip": "Liste", "tagOpen": "* " , "tagClose": "", "sampleText": "élément 1 \n* élément 2"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_enum.png", "speedTip": "Énumération", "tagOpen": "# ", "tagClose": "", "sampleText": "élément 1 \n# élément 2"}; /* mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_tableau.png", "speedTip": "Tableau", "tagOpen": "{| border="1" cellpadding="10" cellspacing="0"\n", "tagClose": "\n|}", "sampleText": "|Orange\n|Apple\n|-\n|Bread\n|Pie\n|-\n|Butter\n|Ice cream"}; */ mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_gallery.png", "speedTip": "Galerie d'images", "tagOpen": "<gallery>", "tagClose": "\n</gallery>", "sampleText": "\nImage:Exemple1.jpg|texte descriptif 1 \nImage:Exemple2.jpg|texte descriptif 2 \nImage:Exemple3.jpg|texte descriptif 3"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_modele.png", "speedTip": "Modèle", "tagOpen": "{{", "tagClose": "}}", "sampleText": "Nom du modèle"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_category.png", "speedTip": "Catégorie", "tagOpen": "[[Catégorie:", "tagClose": "]]", "sampleText": "nom de la catégorie"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_redirect.png", "speedTip": "Redirection", "tagOpen": "#REDIRECT [[", "tagClose": "]]", "sampleText": "Insert text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.geologie.lu/geolwiki/skins/common/images/button_comment.png", "speedTip": "Commentaire visible uniquement aux éditeurs", "tagOpen": "<"+"!--", "tagClose": "--"+">", "sampleText": "Insérer commentaire ici"}; } /*############################################################################################*/ /* Commandes SOUS la fenêtre de l'éditeur installé le 29/10/08 ========================== */ function includePage( name ) { document.write('<script type="text/javascript" src="' + wgScript + '?title=' + name + '&action=raw&ctype=text/javascript"><\/script>' ); } /* End of includePage */ /* Including extra .js pages */ // switches for scripts // TODO: migrate to JSConfig // var load_extratabs = true; var load_edittools = true; // extra drop down menu on editing for adding special characters includePage( 'MediaWiki:Edittools.js' ); /*############################################################################################*/ /* wikEd installation le 05/11/08 RC , http://en.wikipedia.org/wiki/User:Cacycle/wikEd_installation============== */ // install [[User:Cacycle/wikEd]] in-browser text editor document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' + '&action=raw&ctype=text/javascript"></' + 'script>'); /*############################################################################################*/ /* ################################## copié de http://meta.wikimedia.org/w/index.php?title=MediaWiki:Common.js RC 07/11/08 */ /** Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame]]. * Maintainer on Wikipedia: [[User:R. Koot]] */ var autoCollapse = 2; var collapseCaption = "cacher ▲"; var expandCaption = "afficher ▼" ; function hasClass( element, className ) { var Classes = element.className.split( " " ); for ( var i = 0; i < Classes.length; i++ ) { if ( Classes[i] == className ) { return ( true ); } } return ( false ); } 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( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); 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 );