User Guide
166 Chapter 8: Menus and Menu Commands
canAcceptCommand()
Dreamweaver next calls the
canAcceptCommand() function for each menuitem tag that references
a command file with the
file attribute. If the canAcceptCommand() function returns the value
false, the menu item is dimmed. If the canAcceptCommand() function returns the value true,
Dreamweaver enables the item on the menu. If the function returns
true or is not defined,
Dreamweaver calls the
isCommandChecked() function to determine whether to display a check
mark next to the menu item. If the
isCommandChecked() function is not defined, no check
mark appears.
function canAcceptCommand()
{
var PIB = dw.getBrowserList();
if (arguments[0] == 'primary' || arguments[0] == 'secondary')
return havePreviewTarget();
return havePreviewTarget() && (PIB.length > 0);
}
The canAcceptCommand() function in the PIB_Dynamic.js file again retrieves the browser list
that was created in Preferences. Then it checks whether the first argument (
arguments[0]) is
primary or secondary. If so, it returns the value returned by the
havePreviewTarget() function.
If not, it tests the call to the
havePreviewTarget() function and tests whether any browsers have
been specified (
PIB.length > 0). If both tests are true, the function returns the value true. If
either or both of the tests are false, the function returns the value
false.
havePreviewTarget()
The
havePreviewTarget() function is a user-defined function that returns the value true
if Dreamweaver has a valid target to display in the browser. A valid target is a document or a
selected group of files in the site panel. The
havePreviewTarget() function looks like the
following example:
function havePreviewTarget()
{
var bHavePreviewTarget = false;
if (dw.getFocus(true) == 'site')
{
if (site.getFocus() == 'remote')
{
bHavePreviewTarget = site.getRemoteSelection().length > 0 &&
site.canBrowseDocument();
}
else if (site.getFocus() != 'none')
{
var selFiles = site.getSelection();
if (selFiles.length > 0)
{
var i;
bHavePreviewTarget = true;
for (i = 0; i < selFiles.length; i++)
{
var selFile = selFiles[i];