1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
<div id="ToolBar_1" class="ToolBar" style="display : block; padding-bottom : 2px;">
<img unselectable="on" src="doc/orange_spacer.gif" title="" />
<img src="doc/orange_cut.gif" onclick="doCommand('cut');" title="Couper (Ctrl X)"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_copy.gif" onclick="doCommand('copy');" title="Copier (Ctrl C)"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_paste.gif" onclick="doCommand('paste');" title="Coller (Ctrl V)"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img unselectable="on" src="doc/orange_spacer.gif" title="" />
<img src="doc/orange_undo.gif" onclick="doCommand('undo');" title="Annuler (Ctrl Z)"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_redo.gif" onclick="doCommand('redo');" title="Rétablir (Ctrl Y)"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img unselectable="on" src="doc/orange_spacer.gif" title="" />
<img src="doc/orange_link.gif" onclick="doCommand('createLink');"
title="Lien hypertexte" unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_nolink.gif" onclick="doCommand('Unlink');"
title="Supprimer un lien hypertexte" unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img unselectable="on" src="doc/orange_spacer.gif" title="" />
<img src="doc/orange_image.gif" onclick="doCommand('insertImage');"
title="Image" unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_hr.gif" onclick="doCommand('InsertHorizontalRule');" title="Ligne horizontale"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_liste_puce.gif" onclick="doCommand('InsertUnorderedList');" title="Liste à puces"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_liste_num.gif" onclick="doCommand('InsertOrderedList');" title="Liste à numéros"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_indent.gif" onclick="doCommand('Indent');" title="Augmenter le retrait - Décaler à droite"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
<img src="doc/orange_outdent.gif" onclick="doCommand('Outdent');" title="Diminuer le retrait - Décaler à gauche"
unselectable="on" class="ToolOut"
onmouseover="this.className='ToolOver';" onmouseout="this.className='ToolOut';" />
</div>
// exécuter les commandes
function doCommand (idCommand){
setFocus();
oSelection = document.selection.createRange();
// Cas où police texte
if(idCommand == "FontName"){
if(arguments[1] != 1){
document.execCommand(idCommand,false, arguments[1]);
setFocus();
document.FontForm.FontSelect.selectedIndex = 0;
return;
}
}
// Cas où taille texte
else if(idCommand == "FontSize"){
if(arguments[1] != 0){
document.execCommand(idCommand,false, arguments[1]);
setFocus();
document.FontForm.FontSizeSelect.selectedIndex = 0;
return;
}
}
// Cas "ForeColor" ou "FormatBlock" ou "FormatBlock"
else if(idCommand == "ForeColor" || idCommand == "BackColor" || idCommand == "FormatBlock"){
document.execCommand(idCommand,false, arguments[1]);
setFocus();
return;
}
// Cas où suppression d'une ancre
else if (idCommand == 'UnBookmark'){
if (oSelection.text == ""){ // s'il n'y apas de texte sélectionné
// on essaye de sélectionner le caractère suivant
oSelection.moveEnd("character", +1);
oSelection.collapse();
oSelection.expand("character");
if(oSelection.text != " "){ // si le caratère suivant n'est pas un "espace", on sélectionne le précedent
oSelection.moveEnd("character", -2);
oSelection.collapse();
oSelection.expand("character");
if(oSelection.text != " "){ // si ce n'est toujours pas un espace, on ne sélectionne rien
oSelection.collapse();
}
}
}
oSelection.select();
oSelection = document.selection.createRange();
}
// Cas où insertion d'une ancre
else if (idCommand == 'CreateBookmark'){
var ancre = prompt("Entrez le nom de l'ancre","");
if(ancre == ""){
alert("Vous devez donner un nom à votre ancre");
return;
}
else if(ancre){
if (oSelection.text == ""){ // s'il n'y apas de texte sélectionné
// on essaye de sélectionner le caractère suivant
oSelection.moveEnd("character", +1);
oSelection.collapse();
oSelection.expand("character");
if(oSelection.text != " "){ // si le caratère suivant n'est pas un "espace", on sélectionne le précedent
oSelection.moveEnd("character", -2);
oSelection.collapse();
oSelection.expand("character");
if(oSelection.text != " "){ // si ce n'est toujours pas un espace, on sélectionne le mot
oSelection.collapse();
oSelection.expand("word");
if(oSelection.text.lastIndexOf(" ") != -1){ // si le mot se termine par un espace => ne pas sélectionner l'espace
oSelection.moveEnd("character", -1);
}
}
}
oSelection.select();
oSelection = document.selection.createRange();
}
document.execCommand(idCommand, false, ancre);
}
return;
}
// Cas où insertion d'une image
else if (idCommand == "insertImage"){
Calk = window.document.getElementById("Avertissement_0");
Calk.style.display = 'block' ;
document.execCommand(idCommand, true);
Calk.style.display = 'none' ;
return;
}
// Exécute les autres commandes telles quelles
document.execCommand(idCommand);
} |