
A simple toolbar command file 219
canAcceptCommand(): enable the toolbar item
The canAcceptCommand() function consists of one line of code that checks to see whether
there is a current Document Object Model (DOM) and whether the document is parsed as
HTML. The function returns the results of those tests. If the conditions are
true,
Dreamweaver enables the text box item on the toolbar. If the function returns the value
false, Dreamweaver disables the item.
The function is as follows:
function canAcceptCommand()
{
return (dw.getDocumentDOM() != null && dw.getDocumentDOM().getParseMode()
== 'html');
}
receiveArguments(): set the title
Dreamweaver invokes the receiveArguments() function, shown in the following example,
when the user enters a value in the Title text box and presses the Enter key or moves the focus
away from the control.
The function is as follows:
function receiveArguments(newTitle)
{
var dom = dw.getDocumentDOM();
if (dom)
dom.setTitle(newTitle);
}
Dreamweaver passes newTitle, which is the value that the user enters, to the
receiveArguments() function. The receiveArguments() function first checks to see
whether a current DOM exists. If it does, the
receiveArguments() function sets the new
document title by passing
newTitle to the dom.setTitle() function.
getCurrentValue(): get the title
Whenever an update cycle occurs, as determined by the default update frequency of the
onEdit event handler, Dreamweaver calls the getCurrentValue() function to determine
what value to display for the control. The default update frequency of the
onEdit handler
determines the update frequency because the Title text edit control has no update attribute.
For the Title text box, the following
getCurrentValue() function calls the JavaScript
application programming interface (API) function
dom.getTitle() to obtain and return the
current title.
Kommentare zu diesen Handbüchern