MACROMEDIA DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER Spécifications Page 174

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 504
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 173
174 Commands
// Get the node that contains the selection.
var theSelNode = theDOM.getSelectedNode();
// Get the children of the selected node.
var theChildren = theSelNode.childNodes;
var i = 0;
if (theSelNode.hasChildNodes()){
while (i < theChildren.length){
if (theChildren[i].nodeType == Node.TEXT_NODE){
var selText = theChildren[i].data;
var theSel = theDOM.nodeToOffsets(theChildren[0]);
break;
}
++i;
}
}
else {
// Get the offsets of the selection
var theSel = theDOM.getSelection();
// Extract the selection
var selText = theWholeDoc.substring(theSel[0],theSel[1]);
}
if (uorl == 'u'){
theDocEl.outerHTML = theWholeDoc.substring(0,theSel[0]) +
selText.toUpperCase() + theWholeDoc.substring(theSel[1]);
}
else {
theDocEl.outerHTML = theWholeDoc.substring(0,theSel[0]) +
selText.toLowerCase() + theWholeDoc.substring(theSel[1]);
}
// Set the selection back to where it was when you started
theDOM.setSelection(theSel[0],theSel[1]);
window.close(); // close extension UI
}
3.
Save the file as Change Case.js in the Configuration/Commands folder.
The
changeCase() function is a user-defined function that is called by the
commandButtons() function when the user clicks OK. This function changes the selected
text to uppercase or lowercase. Because the UI uses radio buttons, the code can rely on one
choice or the other being checked; it does not need to test for the possibility that the user
makes neither choice.
Vue de la page 173
1 2 ... 169 170 171 172 173 174 175 176 177 178 179 ... 503 504

Commentaires sur ces manuels

Pas de commentaire