|
|
Ligne 1 : |
Ligne 1 : |
| //Ajoute des boutons à la barre d'outils
| | |
| if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
| |
| if( !mw.user.options.get('usebetatoolbar')) {
| |
| alert("Vous devez utiliser la barre d'outil améliorée pour profiter du gadget « Ajouts à la nouvelle barre d’outils améliorée ». Activez la dans vos préférences d'édition ou désactivez ce gadget.");
| |
| } else {
| |
| $(function() {
| |
|
| |
| //Boutons de formatage : poem et changement de casse
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'advanced',
| |
| group: 'format',
| |
| tools: {
| |
| 'poem': {
| |
| label: 'Poème',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/thumb/d/dd/P_writing_icon.svg/23px-P_writing_icon.svg.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '<poem>',
| |
| peri: 'Texte du poème',
| |
| post: '</poem>',
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'toggleCase': {
| |
| label: 'Modifier la casse',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/thumb/d/de/Wynn.svg/23px-Wynn.svg.png',
| |
| action: {
| |
| type: 'callback',
| |
| execute: function() {
| |
| var context = $('img[rel="toggleCase"]').data('context');
| |
| var selection = context.$textarea.textSelection('getSelection');
| |
| if (!selection.collapsed) {
| |
| var str = selection.toString();
| |
| if (str == str.toUpperCase()) {
| |
| str = str.toLowerCase();
| |
| } else {
| |
| str = str.toUpperCase();
| |
| }
| |
| context.$textarea.textSelection('encapsulateSelection', {'pre': '', 'peri': str, 'post': '', 'replace': true});
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| //Boutons d’insertion : modèle et guillemets
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'advanced',
| |
| group: 'insert',
| |
| tools: {
| |
| 'template': {
| |
| label: 'Modèle',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/8/86/Wikieditor-template.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '{{',
| |
| peri: 'Nom du modèle',
| |
| post: '|}}'
| |
| }
| |
| }
| |
| },
| |
| 'quote': {
| |
| label: 'Citation',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Norwegian_quote_sign.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '« ',
| |
| peri: 'Texte',
| |
| post: ' »'
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| //Ajoute une section wikisource avec le contenu de l'editool
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| sections: {
| |
| 'wikisource': {
| |
| type: 'booklet',
| |
| label: 'Wikisource',
| |
| pages: {
| |
| 'wiki': {
| |
| layout: 'characters',
| |
| label: 'Syntaxe wiki',
| |
| characters: []
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| var section = $('.section-wikisource .page-wiki div');
| |
| var links = $('.mw-editTools .plainlinks p').eq(0);
| |
| links.find('a').each(function() {
| |
| var button = $('<span>');
| |
| button.text($(this).text());
| |
| button.attr('rel', $(this).text());
| |
| button.attr('onclick', $(this).attr('onclick'));
| |
| button.css('font-size', '1em');
| |
| //button.click($(this).attr('onclick'));
| |
| section.append(button);
| |
| });
| |
| });
| |
| }
| |
|
| |
|
| |
|
| |
| //Ajoute un bouton index dans l'espace principal
| |
| if(mw.config.get('wgNamespaceNumber') == 0 && $.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
| |
| $(function() {
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'advanced',
| |
| group: 'insert',
| |
| tools: {
| |
| 'pages': {
| |
| label: 'Pages',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/6/6a/Nuvola_apps_icons.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '<pages index="',
| |
| peri: 'Nom du fac-similé',
| |
| post: '" from= to= fromsection= tosection= header=1 />',
| |
| ownline: true
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| });
| |
| }
| |
|
| |
| //Ajoute la capacité d'afficher et de masquer les en-têtes et pied de pages dans l'espace page.
| |
| if(mw.config.get('wgNamespaceNumber') == 104 && $.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
| |
| $(function() {
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| groups: {
| |
| 'nav':{
| |
| tools: {
| |
| 'header-footer': {
| |
| label: 'Afficher l’en-tête et pied de page',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/b/bc/Farm-Fresh_layout_header.png',
| |
| action: {
| |
| type: 'callback',
| |
| execute: function() {
| |
| if($('#prp_header').css('display') == 'none') {
| |
| $('#prp_header').css({'display': 'block'});
| |
| $('#prp_footer').css({'display': 'block'});
| |
| } else {
| |
| $('#prp_header').css({'display': 'none'});
| |
| $('#prp_footer').css({'display': 'none'});
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| });
| |
| }
| |
| }
| |