_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

MediaWiki:Gadget-LiveRC.js/Extensions/ToolbarExtension.js

Dans cet article nous allons aborder le sujet de MediaWiki:Gadget-LiveRC.js/Extensions/ToolbarExtension.js et explorer ses différentes facettes. MediaWiki:Gadget-LiveRC.js/Extensions/ToolbarExtension.js est un sujet d'une grande importance dans la société actuelle, car il impacte divers aspects de la vie quotidienne. Tout au long de cet article nous analyserons son origine, son évolution dans le temps et son influence dans différents domaines. De plus, nous examinerons les différentes perspectives qui existent autour de MediaWiki:Gadget-LiveRC.js/Extensions/ToolbarExtension.js, dans le but de proposer une vision complète et enrichissante sur ce sujet. A travers une approche multidimensionnelle, nous souhaitons offrir à nos lecteurs une vision large et détaillée de MediaWiki:Gadget-LiveRC.js/Extensions/ToolbarExtension.js, dans le but de susciter la réflexion et le débat autour de ce sujet si d'actualité aujourd'hui.
/* 
 --------------------------------------------------------------------------------------
 ---------LLLL---------III--------------------------RRRRRRRRRR--------CCCCC------------
 ---------LLLL---------III--------------------------RRRRRRRRRRRR----CCCCCCCCC----------
 ---------LLLL--------------------------------------RRR------RRR---CCC-----CCC---------
 ---------LLLL---------III--VV-----VV--EEEEEEEEE----RRR------RRR--CCC------------------
 ---------LLLL---------III---VV---VV---EEE----------RRRRRRRRRRR---CCC------------------
 ---------LLLL---------III---VV---VV---EEEEEE-------RRRRRRRRRR----CCC------------------
 ---------LLLL---------III----VV-VV----EEEEEE-------RRR-----RRR----CCC-----CCC---------
 ---------LLLLLLLLLLL--III----VVVVV----EEE----------RRR------RRR----CCCCCCCCC----------
 ---------LLLLLLLLLLL--III-----VVV-----EEEEEEEEE----RRR-------RRR-----CCCCC------------
 --------------------------------------------------------------------------------------
 
'''Extension de LiveRC'''
 
Permet d'avoir une barre d'outils lors d'une modification 

 
* Licence : ...?
* Documentation :
* Auteur : ]
* Développement et maintenance :
 
 
{{Catégorisation JS|LiveRC}}
 
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
 
LiveRC_Config.push("ToolbarExtension");
/* ************************************************************************************************************************************************ */

window.Custom_lrcEditToolBarSetup = ;
window.lrcEditToolBarSetup = [
  { iconid : "ToolbarIcon_bold", before : "'''", sampletext : "", after : "'''"},
  { iconid : "ToolbarIcon_italic", before : "''", sampletext : "", after : "''"},
  { iconid : "ToolbarIcon_underline", before : "<u>", sampletext : "", after : "</u>"},
  { iconid : "ToolbarIcon_strike", before : "<s>", sampletext : "", after : "</s>"},
  { iconid : "ToolbarIcon_sup", before : "<sup>", sampletext : "", after : "</sup>"},
  { iconid : "ToolbarIcon_sub", before : "<sub>", sampletext : "", after : "</sub>"},
  { iconid : "ToolbarIcon_big", before : "<big>", sampletext : "", after : "</big>"},
  { iconid : "ToolbarIcon_small", before : "", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_headline2", before : "== ", sampletext : "", after : " =="},
  { iconid : "ToolbarIcon_headline3", before : "=== ", sampletext : "", after : " ==="},
  { iconid : "ToolbarIcon_headline4", before : "==== ", sampletext : "", after : " ===="},
  { iconid : "ToolbarIcon_headline5", before : "===== ", sampletext : "", after : " ====="},
  { iconid : "ToolbarIcon_link", before : "]"},
  { iconid : "ToolbarIcon_extlink", before : ""},
  { iconid : "ToolbarIcon_category", before : "]"}, 
  { iconid : "ToolbarIcon_template", before : "{{", sampletext : "", after : "}}"},
  { iconid : "ToolbarIcon_comment", before : "<!-- ", sampletext : "", after : " -->"},
  { iconid : "ToolbarIcon_enum", before : "\n# élément 1\n# élément 2\n# élément 3", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_list", before : '\n* élément A\n* élément B\n* élément C', sampletext : "", after : ""},
  { iconid : "ToolbarIcon_image", before : "]"},
  { iconid : "ToolbarIcon_media", before : "]"},
  { iconid : "ToolbarIcon_gallery", before : "\n<gallery>\nExemple.jpg|]\nExemple1.jpg|]\nExemple2.jpg|Un ]\n</gallery>\n", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_math", before : "<math>", sampletext : "\\rho=\\sqrt{x_0^2+y_0^2}", after : "</math>"},
  { iconid : "ToolbarIcon_nowiki", before : "<nowiki"+">", sampletext : "", after : "</nowiki"+">"},
  { iconid : "ToolbarIcon_sign", before : "-- ~~"+"~~", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_hr", before : "--"+"--", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_br", before : "<br>", sampletext : "", after : ""},
  { iconid : "ToolbarIcon_redirect", before : "#REDIRECTION ]"},
  { iconid : "ToolbarIcon_table", before : "{| class=\"wikitable\"\n", sampletext : "|-\n! titre 1\n! titre 2\n! titre 3\n|-\n| rangée 1, case 1\n| rangée 1, case 2\n| rangée 1, case 3\n|-\n| rangée 2, case 1\n| rangée 2, case 2\n| rangée 2, case 3", after : "\n|}"}, 
  { iconid : "ToolbarIcon_ref", before : "<ref>", sampletext : "", after : "</ref>"},
  { iconid : "ToolbarIcon_references", before : "<references />", sampletext : "", after : ""}
];

  // Icônes

lrcIcons = {
  type:0,
  src:"e/e2/Button_bold.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/1d/Button_italic.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"f/fd/Button_underline.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"3/30/Btn_toolbar_rayer.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"6/6a/Button_sup_letter.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"a/aa/Button_sub_letter.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"8/89/Button_bigger.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"0/0d/Button_smaller.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"7/78/Button_head_A2.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"4/4f/Button_head_A3.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/14/Button_head_A4.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"8/8c/Button_head_A5.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"c/c0/Button_link.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"e/ec/Button_extlink.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"b/b4/Button_category03.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"3/3b/Button_template_alt.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/1b/Button_hide_wiki_tag.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"8/88/Btn_toolbar_enum.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/11/Btn_toolbar_liste.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"d/de/Button_image.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/19/Button_media.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"9/9e/Btn_toolbar_gallery.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"5/5b/Math_icon.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"8/82/Nowiki_icon.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"6/6d/Button_sig.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"0/0d/Button_hr.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"1/13/Button_enter.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"c/c8/Button_redirect.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"0/04/Button_array.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"c/c4/Button_ref.png",
  width:23,
  height:23
};
lrcIcons = {
  type:0,
  src:"6/64/Buttonrefvs8.png",
  width:23,
  height:23
};
 

 // Textes

lrcTexts = "Texte en gras";
lrcTexts = "Texte en italique";
lrcTexts = "Texte souligné";
lrcTexts = "Texte barré";
lrcTexts = "Texte en exposant";
lrcTexts = "Texte en indice";
lrcTexts = "Texte en grand";
lrcTexts = "Texte en petit";
lrcTexts = "Chapitre de niveau 2";
lrcTexts = "Chapitre de niveau 3";
lrcTexts = "Chapitre de niveau 4";
lrcTexts = "Chapitre de niveau 5";
lrcTexts = "Lien interne";
lrcTexts = "Lien externe";
lrcTexts = "Catégorie";
lrcTexts = "Modèle";
lrcTexts = "Commentaire caché";
lrcTexts = "Énumération";
lrcTexts = "Liste";
lrcTexts = "Image";
lrcTexts = "Média";
lrcTexts = "Galerie d'images";
lrcTexts = "Expression mathématique (format LaTeX)";
lrcTexts = "Ignorer le format wiki";
lrcTexts = "Signature datée";
lrcTexts = "Ligne horizontale";
lrcTexts = "Saut de ligne";
lrcTexts = "Redirection";
lrcTexts = "Tableau";
lrcTexts = "Référence";
lrcTexts = "Index des références";

lrcTexts = " « $1 »";
lrcTexts = " Infobulle du bouton « $1 »";


lrcParamDesc = 'Paramètres de l’extension Toolbar';
lrcParamDesc = 'Toolbar';
lrcParamDesc = ' Description standard d’un bouton';
lrcParamDesc = ' Description standard d’une infobulle de bouton';

lstParamMenuTabs = true;

window.ToolbarExtension_Preprocess = function(){
  var buttons = Custom_lrcEditToolBarSetup;
  if(!buttons || buttons.length===0) buttons = lrcEditToolBarSetup;
  for(var a=0,l=buttons.length;a<l;a++){
    var ID = buttons.iconid;
    var Tooltip = lrcMakeText((ID+"_title"));
    lrcParamDesc = lrcMakeText("ToolbarIconStandardDesc").split("$1").join(Tooltip);
    lrcParamDesc = lrcMakeText("ToolbarIconTooltipStandardDesc").split("$1").join(Tooltip);
  }
}

window.ToolbarExtension_Init = function(){
  var preview = document.getElementById('livePreview');
  if(!preview) return;
  var TextBox = getElementWithId("wpTextbox1", 'textarea', preview);
  if(!TextBox) return;
  var Toolbar = getElementWithId("LiveRC_EditToolBar", 'div', preview);
  if(!Toolbar){
    Toolbar = document.createElement('div');
    Toolbar.id = "LiveRC_EditToolBar";
    TextBox.parentNode.insertBefore(Toolbar, TextBox);
  }
  var buttons = Custom_lrcEditToolBarSetup;
  if(!buttons || buttons.length===0) buttons = lrcEditToolBarSetup;
  for(var a=0,l=buttons.length;a<l;a++){
    var ThisButton = buttons
    var ID = ThisButton.iconid;
    var Link = document.createElement('a');
    Link.innerHTML = lrcMakeIcon(ID);
    Link.id = ID+"_LINK";
    Link.href = "javascript:;";
    Link.onclick = function(){ 
      ToolbarExtension_InsertTag(this);
    }
    Toolbar.appendChild(Link);
  }
}


window.ToolbarExtension_InsertTag = function(Link){
  if(!Link) return;
  var ID = Link.id;
  if(!ID) return;
  ID = ID.split("_LINK").join("");
  var buttons = Custom_lrcEditToolBarSetup;
  if(!buttons || buttons.length==0) buttons = lrcEditToolBarSetup;
  for(var a=0,l=buttons.length;a<l;a++){
    var ThisButton = buttons;
    var ThisButtonID = ThisButton.iconid;
    if(ThisButtonID !== ID) continue;
    ToolbarExtension_ReallyInsertTag(ThisButton);
    return false;
  }
  return false;
}

window.ToolbarExtension_ReallyInsertTag = function(ThisButton){
  var iconid = ThisButton.iconid;
  var tagOpen = ThisButton.before;
  var sampleText = ThisButton.sampletext;
  var tagClose = ThisButton.after;
  var preview = document.getElementById('livePreview');
  if(!preview) return;
  var TextBox = getElementWithId("wpTextbox1", 'textarea', preview);
  if(!TextBox) return; 
  function ToolbarExtension_checkSelectedText(){
    if(!selText) {
      selText = sampleText;
      isSample = true;
    }else if(selText.charAt(selText.length - 1) == ' ') { //exclude ending space char
      selText = selText.substring(0, selText.length - 1);
      tagClose += ' ';
    }
  }
  var selText, isSample = false;
  var winScroll = TextBox.scrollTop;
  TextBox.focus(); 
  if(document.selection && document.selection.createRange){
    var range = document.selection.createRange();
    selText = range.text;
    ToolbarExtension_checkSelectedText();
    range.text = tagOpen + selText + tagClose;
    if(isSample && range.moveStart) {
      if(window.opera) tagClose = tagClose.replace(/\n/g,'');
      range.moveStart('character', - tagClose.length - selText.length); 
      range.moveEnd('character', - tagClose.length);    
    }
    range.select();
  }else if(TextBox.selectionStart || TextBox.selectionStart == '0'){
    var startPos = TextBox.selectionStart;
    var endPos = TextBox.selectionEnd;
    selText = TextBox.value.substring(startPos, endPos);
    ToolbarExtension_checkSelectedText();
    TextBox.value = TextBox.value.substring(0, startPos) + tagOpen + selText + tagClose + TextBox.value.substring(endPos, TextBox.value.length);
  }
  TextBox.scrollTop = winScroll;
  return false;
}

LiveRC_AddHook("BeforeInitActivationProcess", ToolbarExtension_Preprocess);


LiveRC_AddHook("AfterPreviewEdit", ToolbarExtension_Init);


LiveRC_AddHook("AfterFillParamPanel", function(){
  LiveRC_ManageParams_Fill(lrcEditToolBarSetup, "lrcEditToolBarSetup", false, true);
});

window.ToolbarExtension_TransformOptions = function(){
  var Fieldset = document.getElementById("LiveRC_OptionsContent_lrcEditToolBarSetup");
  if(!Fieldset) return;
  var Lis = Fieldset.getElementsByTagName('li');
  for(var a=0,l=Lis.length;a<l;a++){
    var Li = Lis;
    var ThisItemName = false;
    var Inputs = Li.getElementsByTagName('input');
    for(var b=0,m=Inputs.length;b<m;b++){
      if(Inputs.name === "iconid") ThisItemName = Inputs.value;
    }
    if(!ThisItemName) continue;
    var Label = document.createElement('label');
    lrcAddClass(Label, "lrcIcons_Label");
    Label.innerHTML = lrcMakeText(ThisItemName+"_title");
    Li.appendChild(document.createTextNode(" : "));
    Li.appendChild(Label);
    var DeleteLink = Li.getElementsByTagName('a');
    DeleteLink.parentNode.removeChild(DeleteLink);
    Li.insertBefore(document.createTextNode(" "), Li.firstChild);
    Li.insertBefore(DeleteLink, Li.firstChild);
  } 
}

LiveRC_AddHook("AfterCreateParamPanel", ToolbarExtension_TransformOptions);

/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>