A simple command example
173
Linking functions to the OK and Cancel buttons
When the user clicks OK or Cancel, the extension needs to perform the appropriate action.
You determine the appropriate action by specifying which JavaScript function to perform
when either button is clicked.
To link the OK and Cancel button to functions:
1.
Open the file Change Case.js in the Configuration/Commands folder.
2.
At the end of the file, add the following code:
function commandButtons() {
return new Array("OK", "changeCase()", "Cancel", "window.close()");
}
3.
Save the file.
The
commandButtons()
function causes Dreamweaver to supply the OK and Cancel buttons
and tells Dreamweaver what to do when the user clicks them. The
commandButtons()
function tells Dreamweaver to call
changeCase()
when the user clicks OK and to call
window.close()
when the user clicks Cancel.
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:
1.
Open the file Change Case.js.
2.
At the end of the file, add the following code:
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;
Содержание DREAMWEAVER 8-EXTENDING DREAMWEAVER
Страница 1: ...Extending Dreamweaver...
Страница 8: ...8 Contents...
Страница 14: ...14 Introduction...
Страница 16: ......
Страница 54: ...54 Customizing Dreamweaver...
Страница 96: ...96 Customizing Code View...
Страница 98: ......
Страница 110: ...110 Extending Dreamweaver...
Страница 138: ......
Страница 166: ...166 Insert Bar Objects...
Страница 180: ...180 Commands...
Страница 248: ...248 Toolbars...
Страница 260: ...260 Reports...
Страница 278: ...278 Tag Libraries and Editors...
Страница 288: ...288 Property Inspectors...
Страница 378: ...378 Server Behaviors...
Страница 398: ...398 Data Sources...
Страница 432: ...432 Server Models...
Страница 456: ...456 Data Translators...
Страница 482: ......
Страница 492: ...492 The Shared Folder...