beautypg.com

Adobe Extending Dreamweaver CS4 User Manual

Page 165

background image

159

EXTENDING DREAMWEAVER CS4

Menus and menu commands

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 input 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.

For each item in the selected list, the function tests for the presence of the character string "

://

". If it is not found, the

code performs a series of tests on the list item. If the item is not in the form of a

file:///

URL (if

(selFile.indexOf(urlPrefix) == -1)), it sets the return value to

false

. If the remainder of the string following the

file:///

prefix does not contain a slash (/) (if (strTemp.indexOf("/") == -1)), it sets the return value to

false

. If the

file does not exist (else if (!DWfile.exists(selFile))), it sets the return value to

false

. Last, it checks to see if the specified

file is a folder (else if (DWfile.getAttributes(selFile).indexOf("D") != -1)). If

selfile

is a folder, the function returns

the value

false.

Otherwise, if the target is a file, the function sets

bHavePreviewTarget

to the value

true

.

If a document, Text view, or the Code inspector has input focus (

else if (dw.getFocus() == 'document' ||

dw.getFocus() == 'textView' || dw.getFocus("true") == 'html' )), the function gets the DOM and checks to see if the
document is an HTML or an XML document. If so, the function sets

bHavePreviewTarget

to

true

. Finally, the

function returns the value stored in

bHavePreviewTarget

.

This manual is related to the following products: