Jump to content

User:Pyb/monobook.js

From Wikisource
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

/**********************************************************/
/* Insertion de nouveaux boutons dans la barre d'outils   */
/* "http://fr.wikipedia.org/wiki/MediaWiki:Common.js"     */
/* "http://fr.wikisource.org/wiki/MediaWiki:Monobook.js"  */
/**********************************************************/
/*
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
  mwCustomEditButtons[mwCustomEditButtons.length] =
    {"imageId": imageId,
     "imageFile": imageFile,
     "speedTip": speedTip,
     "tagOpen": tagOpen,
     "tagClose": tagClose,
     "sampleText": sampleText};
}
*/
 
 

if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a2/SmallcapsButton.png",
     "speedTip": "sc",
     "tagOpen": '{{sc|',
     "tagClose": '}}',
     "sampleText": "Insert text here"};
};


if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/41/Button_hr_halfwidth.png",
     "speedTip": "Hyphenated word start",
     "tagOpen": '{{hws|',
     "tagClose": '|}}',
     "sampleText": "Insert text here"};
};


if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/41/Button_hr_halfwidth.png",
     "speedTip": "Hyphenated word end",
     "tagOpen": '{{hwe|',
     "tagClose": '|}}',
     "sampleText": "Insert text here"};
};


if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/97/Button_S_italic.png",
     "speedTip": "s long",
     "tagOpen": 'ſ',
     "tagClose": '',
     "sampleText": "Insert text here"};
};


if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/ba/Headline_icon.png",
     "speedTip": "Lettrine",
     "tagOpen": '{{dropinitial|',
     "tagClose": '}}',
     "sampleText": "Insert text here"};
};


if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/74/Button_indented_transcluded_pages.png",
     "speedTip": "Texte dans la marge",
     "tagOpen": '{{right sidenote|',
     "tagClose": '}}',
     "sampleText": "Insert text here"};
};

/**********************************************************/
/* shortcuts   */
/* Sources
/* http://darkoneko.wordpress.com/2009/11/01/personnalisons-wikipedia-ajouter-des-raccourcis-clavier/ */
/* http://www.lyxia.org/blog/developpement/javascriptajax/raccourcis-claviers-en-javascript-214 */
/**********************************************************/


function keyboardShortcuts() {

  var isCtrl = false;

  document.onkeyup=function(e) { //l'user relâche la touche ctrl. La variable passe a False
    if(e.which == 17) isCtrl=false;
  }

  document.onkeydown=function(e){
    if(e.which == 17) { //l'user appuie sur la touche ctrl. La variable passe a True
      isCtrl=true;
      return;
    }

    //gestion des ctrl+lettre que l'on veux ajouter.
    if( isCtrl == true ) {
       switch (e.which) { //quelle touche a été enfoncée ?
	  case 73: //i
	    insertTags("''", "''", 'italique');
            return false
	    break;
	  case 71: //g
	    insertTags("« ", " »", 'guillemets');
            return false
	    break;
	  case 69: //e
	    insertTags("{{e|", "}}", 'exposant');
            return false
	    break;
       }
     }
  }
  return true
}


//la fonction qui gère tous les appel de fonctions (du moins dans mes divers billets :)
//!\ CELA VEUX DIRE QU'IL FAUT FUSIONNER AVEC LA FONCTION main() EXISTANTE, SI VOUS EN AVEZ UNE /!\
function main() {
  // [...  autres fonctions  ... ]

   if (wgAction == "edit" || wgAction == "submit")  { //à n'appeller que si en mode edition, sinon c'est inutile
      keyboardShortcuts()
   }
}

$(main)


importScript('User:Prosody/layoutchoice.js');