
204 Menus and Menu Commands
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++)
{
Kommentare zu diesen Handbüchern