Adobe 38040334 - Dreamweaver CS3 User Manual page 137

Extending dreamweaver
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

Save the file.
3
The
function causes Dreamweaver to supply the OK and Cancel buttons and tells Dreamweaver
commandButtons()
what to do when the user clicks them. The
when the user clicks OK and to call
Letting the user specify uppercase or lowercase
When the user clicks a menu item, the extension needs a mechanism to let the user select uppercase or lowercase.
The UI provides this mechanism by defining two radio buttons to let the user make that choice.
To let the user specify uppercase or lowercase:
Open the file Change Case.js.
1
At the end of the file, add the following code:
2
function changeCase() {
var uorl;
// Check whether user requested uppercase or lowercase.
if (document.forms[0].elements[0].checked)
uorl = 'u';
else
uorl = 'l';
// Get the DOM.
var theDOM = dw.getDocumentDOM();
// Get the outerHTML of the HTML tag (the
// entire contents of the document).
var theDocEl = theDOM.documentElement;
var theWholeDoc = theDocEl.outerHTML;
// 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]);
commandButtons()
when the user clicks Cancel.
window.close()
function tells Dreamweaver to call
DREAMWEAVER CS3
131
Extending Dreamweaver
changeCase()

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents