Utilisateur:FitzSai/common.js

La bibliothèque libre.

Note : après avoir enregistré 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 pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac) ;
  • Google Chrome : Appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac) ;
  • Internet Explorer : Maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ;
  • Opera : Allez dans Menu → Settings (Opera → Préférences sur un Mac) et ensuite à Confidentialité & sécurité → Effacer les données d'exploration → Images et fichiers en cache.
// *********************************************************************
// Add a new button in the toolbar which replaces `s' caracters by a
// `ſ' (long s, old style), but NOT at the end of a word.
// *********************************************************************
$(function() {
  $.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/xregexp.js&action=raw', // load XRegExp
              function() {
                $.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/unicode-base.js&action=raw', // load Letter category only
                            function() {
                              // Check that the toolbar is available
                              if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {
                                // Execute on load
                                $( function() {
                                  // General format:
                                  // $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { configuration object here } );
                                  // Add a button to an existing toolbar group:
                                  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
                                    section: 'advanced',
                                    group: 'format',
                                    tools: {
                                      'long_s': {
                                        label: 'ſ (long s)',
                                        type: 'button',
                                        icon: 'https://upload.wikimedia.org/wikipedia/commons/1/1d/Knop_vrouwelijk.png'
                                      }
                                    }
                                  });
                                  $('img[rel="long_s"]').mouseup(function() {
                                    $('#wpTextbox1').val($('#wpTextbox1').val().replace(XRegExp('s(?=\\p{L})', // regex to be matched
                                                                                                 'g'), // global flag
                                                                                         'ſ')); // substitution
                                  });
                                });
                              }
                            }
                           );
              }
             );
});
// *********************************************************************