MediaWiki:BoutonsListing.js
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
// Add listing buttons in edit toolbar
var customizeToolbar = function() {
$( function() {
if ( typeof $.fn.wikiEditor != 'undefined' ) {
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'main',
'group': 'insert',
'tool': 'reference'
});
}
});
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'listings': {
'label': 'Listings' // or use labelMsg for a localized label, see above
}
}
} );
function currentLastEditDate() {
// return the date as "2015-01-15"
var d = new Date();
var year = d.getFullYear();
// Date.getMonth() returns 0-11
var month = d.getMonth() + 1;
if (month < 10) month = '0' + month;
var day = d.getDate();
if (day < 10) day = '0' + day;
return year + '/' + month + '/' + day;
}
var CURRENT_LAST_EDIT_DATE = currentLastEditDate();
var LISTING_TOOLBAR_ITEMS = {
'Aller': {
label: 'listing "Aller"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Italian_traffic_signs_-_icona_stazione.svg/22px-Italian_traffic_signs_-_icona_stazione.svg.png',
options: {
pre: '* \{\{Aller\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Circuler': {
label: 'listing "Circuler"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/6/62/Italian_traffic_signs_-_icona_autobus_urbano.svg/22px-Italian_traffic_signs_-_icona_autobus_urbano.svg.png',
options: {
pre: '* \{\{Circuler\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Voir': {
label: 'listing "Voir"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Italian_traffic_signs_-_icona_museo.svg/22px-Italian_traffic_signs_-_icona_museo.svg.png',
options: {
pre: '* \{\{Voir\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Faire': {
label: 'listing "Faire"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/3/30/Pictograms-nps-bicycle_trail-2.svg/22px-Pictograms-nps-bicycle_trail-2.svg.png',
options: {
pre: '* \{\{Faire\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Acheter': {
label: 'listing "Acheter"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Italian_traffic_signs_-_icona_supermercato.svg/22px-Italian_traffic_signs_-_icona_supermercato.svg.png',
options: {
pre: '* \{\{Acheter\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Manger': {
label: 'listing "Manger"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Italian_traffic_signs_-_icona_ristorante.svg/22px-Italian_traffic_signs_-_icona_ristorante.svg.png',
options: {
pre: '* \{\{Manger\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Sortir': {
label: 'listing "Sortir"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Verre_cocktail.svg/22px-Verre_cocktail.svg.png',
options: {
pre: '* \{\{Sortir\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Se_loger': {
label: 'listing "Se loger"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/2/25/Pictograms-nps-lodging.svg/22px-Pictograms-nps-lodging.svg.png',
options: {
pre: '* \{\{Se loger\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | arrivée= | départ= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Ville': {
label: 'listing "Ville"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Italian_traffic_signs_-_simbolo_comune_%28figura_II_102%29.svg/22px-Italian_traffic_signs_-_simbolo_comune_%28figura_II_102%29.svg.png',
options: {
pre: '* \{\{Ville\n| nom=',
post: ' | lien nom= | alt= | wikipédia= | wikidata=\n| latitude= | longitude= | direction= \n| image = \n| description= \n}}' // text to be inserted
}
},
'Destination': {
label: 'listing "Destination"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/12/Destination_icon_in_a_square.svg/22px-Destination_icon_in_a_square.svg.png',
options: {
pre: '* \{\{Destination\n| nom=',
post: ' | lien nom= | alt= | wikipédia= | wikidata=\n| latitude= | longitude= | direction= \n| image = \n| description= \n}}' // text to be inserted
}
},
'Representation diplomatique': {
label: 'Listing "Représentation diplomatique"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/7/7d/Flag_icon_in_a_square.svg/22px-Flag_icon_in_a_square.svg.png',
options: {
pre: '* \{\{Représentation diplomatique\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
},
'Listings': {
label: 'Listing "Autres"', // or use labelMsg for a localized label, see above
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/f/f5/Italian_traffic_signs_-_icona_informazioni_%28figura_II_108%29.svg/22px-Italian_traffic_signs_-_icona_informazioni_%28figura_II_108%29.svg.png',
options: {
pre: '* \{\{Listing\n| nom=',
post: ' | alt= | url= | email= | wikipédia= | wikidata= | facebook= \n| adresse= | latitude= | longitude= | direction= \n| image = \n| téléphone= | fax= \n| prix= | horaire= \n| mise à jour=' + CURRENT_LAST_EDIT_DATE + '\n| description=\n}}' // text to be inserted
}
}
};
$.each(LISTING_TOOLBAR_ITEMS, function(index, element) {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: element.label,
type: 'button',
icon: element.icon,
action: {
type: 'encapsulate',
options: element.options
}
}
}
} );
});
};
/* 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', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor', function () {
$(document).ready( customizeToolbar );
} );
}
} );
}