Toolbar functions

 < Day Day Up > 

The following JavaScript functions let you get and set the visibility of toolbars and toolbar labels, obtain the labels of toolbar items in the current window, position toolbars, and obtain toolbar IDs. For more information on creating or modifying toolbars, see "Toolbars" in Extending Dreamweaver Help.

dom.forceToolbarUpdate()

Availability

Dreamweaver MX 2004.

Description

Forces the update handlers to run for all the items on the specified toolbar.

Arguments

 toolbarID 

  • The toolbarID argument is the ID of the toolbar with the items Dreamweaver should update.

Returns

Nothing.

dom.getShowToolbarIconLabels()

Availability

Dreamweaver MX.

Description

This function determines whether labels for buttons are visible in the current document window. Dreamweaver always shows labels for non-button controls, if the labels are defined.

Arguments

None.

Returns

A Boolean value: TRue if labels for buttons are visible in the current document window; false otherwise.

Example

The following example makes labels for buttons visible:

 var dom = dw.getDocumentDom(); if (dom.getShowToolbarIconLabels() == false) {   dom.setShowToolbarIconLabels(true); } 

dom.getToolbarIdArray()

Availability

Dreamweaver MX.

Description

This function returns an array of the IDs of all the toolbars in the application. You can use dom.getToolbarIdArray() to turn off all toolbars so you can reposition them and make only a specific set visible.

Arguments

None.

Returns

An array of all toolbar IDs.

Example

The following example stores the array of toolbar IDs in the tb_ids variable:

 var tb_ids = new Array(); tb_ids = dom.getToolbarIdArray(); 

dom.getToolbarItemValue()

Availability

Dreamweaver MX 2004.

Description

Gets the value of the specified toolbar item.

Arguments

 toolbarID, itemID 

  • The toolbarID argument is a string that specifies the ID of the toolbar that contains the item for which you want a value.

  • The itemID argument is a string that specifies the ID of the item for which you want the value.

Returns

A string that represents the value of the toolbar item.

Example

The following example of receiveArguments() is in a toolbar command that controls the behavior of a Size text field; it gets the value of the Size field as an argument and then reads the value of the Units field in order to produce a valid value for the CSS property font-size function:

 receiveArguments(newSize){ var dom = dw.getDocumentDOM(); if (newSize != ""){   dom.applyFontMarkupAsStyle('font-size', newSize +   dom.getToolbarItemValue("DW_Toolbar_Text","DW_Text_Units"));   } else{   dom.removeFontMarkupAsStyle('font-size');   } } 

dom.getToolbarLabel()

Availability

Dreamweaver MX.

Description

This function obtains the label of the specified toolbar. You can use dom.getToolbarLabel() for menus that show or hide toolbars.

Arguments

 toolbar_id 

  • The toolbar_id argument is the ID of the toolbar, which is the value of the ID attribute on the toolbar tag in the toolbars.xml file.

Returns

The label name string that is assigned as an attribute on the toolbar tag.

Example

The following example stores the label for myEditbar in the variable label:

var label = dom.getToolbarLabel("myEditbar");

dom.getToolbarVisibility()

Availability

Dreamweaver MX.

Description

This function returns a Boolean value that indicates whether the toolbar that is specified by toolbar_id is visible.

Arguments

 toolbar_id 

  • The toolbar_id argument is the ID string that is assigned to the toolbar.

Returns

A Boolean value: true if the toolbar is visible, false if the toolbar is not visible or does not exist.

Example

The following example checks whether the toolbar myEditbar is visible in the document window, and then stores that value in the retval variable:

 var retval = dom.getToolbarVisibility("myEditbar"); return retval; 

dom.setToolbarItemAttribute()

Availability

Dreamweaver MX 2004.

Description

Changes an attribute value for the three image attributes or the tooltip attribute on a toolbar item.

Arguments

 toolbarID, toolbarItemId, attrName, attrValue 

  • The toolbarID argument is a string that specifies the ID of the toolbar.

  • The toolbarItemId argument is a string that specifies the ID of the toolbar item.

  • The attrName argument is a string that specifies the name of the attribute to set. Valid values are 'image', 'overImage', 'disabledImage', or 'tooltip'.

  • The attrValue argument is a string that specifies the value to set.

Returns

Nothing.

Example

The following example calls dom.setToolbarItemAttribute() tHRee times to set the image, imageOver, and tooltip attributes for the toolbar item MyButton on the toolbar having the ID DW_Toolbar_Main:

var dom = dw.getDocumentDOM(); dom.setToolbarItemAttribute('DW_Toolbar_Main', 'MyButton', 'image', 'Toolbars/imgs /newimage.gif'); dom.setToolbarItemAttribute('DW_Toolbar_Main', 'MyButton', 'imageOver', 'Toolbars/imgs /newimageOver.gif'); dom.setToolbarItemAttribute('DW_Toolbar_Main', 'MyButton', 'tooltip', 'One fine button');

dom.setShowToolbarIconLabels()

Availability

Dreamweaver MX.

Description

This function tells Dreamweaver to show the labels of buttons that have labels. Dreamweaver always shows labels for non-button controls, if the labels are defined.

Arguments

 bShow 

  • The bShow argument is a Boolean value: true shows the labels for buttons; false otherwise.

Returns

Nothing.

Example

The following example tells Dreamweaver to show the labels for the buttons on the toolbars:

 dom.setShowToolbarIconLabels(true); 

dom.setToolbarPosition()

Availability

Dreamweaver MX.

Description

This function moves the specified toolbar to the specified position.

NOTE

There is no way to determine the current position of a toolbar.


Arguments

 toobar_id, position, relative_to 

  • The toolbar_id argument is the ID of the toolbar, which is the value of the ID attribute on the toolbar tag in the toolbars.xml file.

  • The position argument specifies where Dreamweaver positions the toolbar, relative to other toolbars. The possible values for position are described in the following list:

    • top is the default position. The toolbar appears at the top of the document window.

    • below makes the toolbar appear at the beginning of the row immediately below the toolbar that relative_to specifies. Dreamweaver reports an error if the toolbar does not find the toolbar that relative_to specifies.

    • floating makes the toolbar float above the document. Dreamweaver automatically places the toolbar so it is offset from other floating toolbars. On the Macintosh, floating is treated the same way as top.

  • relative_to="toolbar_id" is required if position specifies below. Otherwise, it is ignored. Specifies the ID of the toolbar below which this toolbar should be positioned.

Returns

Nothing.

Example

The following example sets the position of myEditbar below the myPicturebar toolbar:

 dom.setToolbarPosition("myEditbar", "below", "myPicturebar"); 

dom.setToolbarVisibility()

Availability

Dreamweaver MX.

Description

This function shows or hides the specified toolbar.

Arguments

 toolbar_id, bShow 

  • The toolbar_id argument is the ID of the toolbar, the value of the ID attribute on the toolbar tag in the toolbars.xml file.

  • The bShow argument is a Boolean value that indicates whether to show or hide the toolbar. If bshow is TRue, dom.setToolbarVisibility() makes the toolbar visible. If bShow is false, dom.setToolbarVisibility() makes the toolbar invisible.

Returns

Nothing.

Example

The following example checks to see if the toolbar myEditbar is visible in the document window; if it is not visible, it sets myEditbar to be visible:

 var dom = dw.getDocumentDOM(); if(dom != null && dom.getToolbarVisibility("myEditbar") == false) {   dom.setToolbarVisibility("myEditbar", true); { 

     < 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