User Guide
A dynamic menu 167
// For server connections, the files will
// already be remote urls.
if (selFile.indexOf("://") == (-1))
{
var urlPrefix = "file:///";
var strTemp = selFile.substr(urlPrefix.length);
if (selFile.indexOf(urlPrefix) == -1)
bHavePreviewTarget = false;
else if (strTemp.indexOf("/") == -1)
bHavePreviewTarget = false;
else if (!DWfile.exists(selFile))
bHavePreviewTarget = false;
else if (DWfile.getAttributes(selFile).indexOf("D") != -1)
bHavePreviewTarget = false;
}
else
{
bHavePreviewTarget = true;
}
}
}
}
}
else if (dw.getFocus() == 'document' ||
dw.getFocus() == 'textView' || dw.getFocus("true") == 'html' )
{
var dom = dw.getDocumentDOM('document');
if (dom != null)
{
var parseMode = dom.getParseMode();
if (parseMode == 'html' || parseMode == 'xml')
bHavePreviewTarget = true;
}
}
return bHavePreviewTarget;
}
The havePreviewTarget() function sets the value bHavePreviewTarget to false as the
default return value. The function performs two basic tests calling the
dw.getFocus() function
to determine what part of the application currently has focus. The first test checks whether the
site panel has focus (
if (dw.getFocus(true) == 'site')). If the site panel does not have
focus, the second test checks to see if a document (dw.getFocus() == 'document'), Text view
(
dw.getFocus() == 'textView'), or the Code inspector (dw.getFocus("true") == 'html')
has focus. If neither test is true, the function returns the value
false.
If the site panel has focus, the function checks whether the view setting is Remote view. If it is, the
function sets
bHavePreviewTarget to true if there are remote files
(site.getRemoteSelection().length > 0) and the files can be opened in a browser
(
site.canBrowseDocument()). If the view setting is not Remote view, and if the view is not
None, the function gets a list of the selected files (
var selFiles = site.getSelection();) in
the form of file:/// URLs.