The Property inspector API

 < Day Day Up > 

Two of the Property inspector API functions (canInspectSelection() and inspectSelection()) are required.

canInspectSelection()

Description

Determines whether the Property inspector is appropriate for the current selection.

Arguments

None.

NOTE

Use dom.getSelectedNode() to get the current selection as a JavaScript object (for more information about dom.getSelectedNode(), see the Dreamweaver API Reference).


Returns

Dreamweaver expects a Boolean value: TRue if the inspector can inspect the current selection; false otherwise.

Example

The following instance of the canInspectSelection() function returns a true value if the selection contains the CLASSID attribute, and the value of that attribute is "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" (the class ID for Macromedia Flash Player):

function canInspectSelection(){ var theDOM = dw.getDocumentDOM(); var theObj = theDOM.getSelectedNode(); return (theObj.nodeType == Node.ELEMENT_NODE && theObj.hasAttribute("classid") && theObj .getAttribute("classid").toLowerCase()== "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"); }

displayHelp()

Description

If this function is defined, a question mark (?) icon appears in the upper-right corner of the Property inspector. This function is called when the user clicks the icon.

Arguments

None.

Returns

Dreamweaver expects nothing.

Example

The following example of the displayHelp() function opens a file in a browser window. The file explains the fields of the Property inspector.

 function displayHelp(){   dw.browseDocument('http://www.hooha.com/dw/inspectors/inspHelp.html'); } 

inspectSelection()

Description

Refreshes the contents of the text fields based on the attributes of the current selection.

Arguments

 maxOrMin 

  • The maxOrMin argument is either max or min, depending on whether the Property inspector is in its expanded or contracted state.

Returns

Dreamweaver expects nothing.

Example

The following example of the inspectSelection() function gets the value of the CONTENT attribute and uses it to populate a form field called keywords:

 function inspectSelection(){   var dom = dreamweaver.getDocumentDOM();   var theObj = dom.getSelectedNode();   document.forms[0].keywords.value = theObj.getAttribute("content"); } 

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net