Zimlet JavaScript API Reference - Dwt

Class Dwt


Dwt is a static class that defines a number of constants and helper methods that support the ajax.dwt.* package.

Defined in: Dwt.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Dwt()
Default constructor.
Field Summary
Field Attributes Field Name and Description
<static>  
Absolute position style.
<static>  
Dwt.CLEAR
Used to clear a value.
<static>  
Dwt.CLIP
Clip on overflow.
<static>  
Dwt.DEFAULT
Default value.
<static>  
Block display style.
<static>  
Inline display style.
<static>  
No display style.
<static>  
Table cell style.
<static>  
Table row style.
<static>  
Copy drag and drop operation.
<static>  
Move drag and drop operation.
<static>  
No drag and drop operation.
<static>  
Always have scrollbars whether content overflows or not.
<static>  
Fixed position style.
<static>  
Offscreen position.
<static>  
Dwt.NO_REPEAT
Do not repeat background image.
<static>  
Relative position style.
<static>  
Dwt.REPEAT
Repeat background image.
<static>  
Dwt.REPEAT_X
Repeat background image horizontally.
<static>  
Dwt.REPEAT_Y
Repeat background image vertically.
<static>  
Dwt.SCROLL
Automatically create scrollbars if content overflows.
<static>  
Dwt.SCROLL_X
Only show scrollbars on X when content overflows.
<static>  
Dwt.SCROLL_Y
Only show scrollbars on Y when content overflows.
<static>  
Ballpark figure for width of a scrollbar.
<static>  
Static position style.
<static>  
Dwt.VISIBLE
Allow overflow to be visible.
<static>  
Dwt.Z_BUSY
This layer appears in front of other layers to block all user mouse input.
<static>  
Dwt.Z_CURTAIN
The curtain layer.
<static>  
Dwt.Z_DIALOG
Dialog layer.
<static>  
Used by menus that are part of a dialog.
<static>  
Dwt.Z_DND
Drag and Drop (DnD) icon layer.
<static>  
Dwt.Z_HIDDEN
Hidden layer.
<static>  
Dwt.Z_MENU
Popup menu layer.
<static>  
Dwt.Z_SPLASH
Used by the splash screens.
<static>  
Dwt.Z_TOAST
The toast layer.
<static>  
Dwt.Z_TOOLTIP
Tooltips layer.
<static>  
Dwt.Z_VEIL
Veil layer.
<static>  
Dwt.Z_VIEW
Visible layer.
Method Summary
Method Attributes Method Name and Description
<static>  
Dwt.addClass(el, c)
Adds the given class name to the element's CSS class names
<static>  
Dwt.byClassName(className, ancestor)
Get all elements of the given class name.
<static>  
Dwt.byTag(tagName, ancestor)
Get all elements of a certain tag name.
<static>  
Dwt.condClass(el, condition, a, b)
Conditionally add or remove a class name from an element
<static>  
Dwt.createLinearGradientInfo(startColor, endColor, direction)
-- FF 3.6+ background: -moz-linear-gradient(black, white); -- Safari 4+, Chrome 2+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff)); -- Safari 5.1+, Chrome 10+ background: -webkit-linear-gradient(top, black, white); -- Opera 11.10 background: -o-linear-gradient(black, white); -- IE6 & IE7 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff'); -- IE8 & IE9 -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff')"; -- IE10 background: -ms-linear-gradient(black, white); -- the standard background: linear-gradient(black, white);
<static>  
Dwt.delClass(el, del, add)
Remove the del class name from the element's CSS class names and optionally add add class name if given provided
<static>  
Dwt.doOverlap(el1, el2)
Returns true if the two elements overlap.
<static>  
Dwt.findAncestor(domElement, attrName)
Finds an ancestor element with a non-empty value for the given attr.
<static>  
Dwt.getAncestors(childNode, parentNode, includeChild)
Get ancestor elements of the given node, up to and including the given parent node.
<static>  
Dwt.getBounds(htmlElement, rect)
Gets the bounds of an HTML element.
<static>  
Dwt.getCursor(htmlElement)
Gets the element cursor for a given HTML element.
<static>  
Dwt.getHtmlExtent(html)
Measure the extent in pixels of a section of html.
<static>  
Dwt.getId(element, prefix)
This method is used to query an element for its id, generating one if it isn't set.
<static>  
Dwt.getInsetBounds(htmlElement)
Gets the bounds of an HTML element, excluding borders and paddings.
<static>  
Dwt.getLocation(htmlElement, point)
Gets the location of an HTML element.
<static>  
Dwt.getNextId(prefix)
This method is used to generate a unique id to be used for an HTML element's id attribute.
<static>  
Dwt.getOuterSize(htmlElement, point)
Gets the outer size -- that is, the size including margins, padding, and borders -- of an HTML element.
<static>  
Dwt.getParams(args, paramNames)
Normalizes an argument list into a hash with the given argument names.
<static>  
Dwt.getScrollStyle(htmlElement)
Returns htmlElement's scroll style.
<static>  
Dwt.getSelectionEnd(input)
Retrieves the end of the selection.
<static>  
Dwt.getSelectionStart(input)
Retrieves the start of the selection.
<static>  
Dwt.getSize(htmlElement, point, getFromStyle)
Gets the size of an HTML element.
<static>  
Dwt.getWindowSize(point)
Gets the window size of the browser.
<static>  
Dwt.getZIndex(getFromStyle, getFromStyle)
Get the z-index of an element.
<static>  
Dwt.hasClass(el, className)
Returns true if the specified element has the given class.
<static>  
Dwt.insertText(input, text)
Inserts some text into an input at the caret.
<static>  
Dwt.isAncestor(el1, el2)
Returns true if el1 is an ancestor (in the parent chain) of el2, or if el1 and el2 are the same element.
<static>  
Dwt.moveCursorToEnd(input)
Move cursor to the end of an input.
<static>  
Dwt.parseHtmlFragment(html, isRow)
Creates and returns an element from a string of HTML.
<static>  
Prints the computed time from performance metrics data
<static>  
Dwt.setBounds(htmlElement, x, y, width, height)
Sets the bounds of an HTML element.
<static>  
Dwt.setCursor(htmlElement, cursorName)
Sets an HTML element cursor.
<static>  
Dwt.setLoadedTime(id, date)
Sets up a hidden div for performance metrics.
<static>  
Dwt.setLoadingTime(id, date)
Sets up a hidden div for performance metrics.
<static>  
Dwt.setLocation(htmlElement, x, y)
Sets the location of an HTML element.
<static>  
Dwt.setScrollStyle(htmlElement, scrollStyle)
Sets the htmlElement's scroll style.
<static>  
Dwt.setSelectionRange(input, start, end)
Sets the selection range.
<static>  
Dwt.setSelectionText(input, text)
Sets the selection text
Class Detail
Dwt()
Default constructor.
Author: Ross Dargahi, Conrad Damon.
Field Detail
<static> Dwt.ABSOLUTE_STYLE
Absolute position style.

<static> Dwt.CLEAR
Used to clear a value.

<static> Dwt.CLIP
Clip on overflow.

<static> Dwt.DEFAULT
Default value. Used when setting such things as size and bounds to indicate a component should not be set. For example if setting size and not wishing to set the height.
Dwt.setSize(htmlElement, 100, Dwt.DEFAULT)

<static> Dwt.DISPLAY_BLOCK
Block display style.

<static> Dwt.DISPLAY_INLINE
Inline display style.

<static> Dwt.DISPLAY_NONE
No display style.

<static> Dwt.DISPLAY_TABLE_CELL
Table cell style.

<static> Dwt.DISPLAY_TABLE_ROW
Table row style.

<static> Dwt.DND_DROP_COPY
Copy drag and drop operation.

<static> Dwt.DND_DROP_MOVE
Move drag and drop operation.

<static> Dwt.DND_DROP_NONE
No drag and drop operation.

<static> Dwt.FIXED_SCROLL
Always have scrollbars whether content overflows or not.

<static> Dwt.FIXED_STYLE
Fixed position style.

<static> Dwt.LOC_NOWHERE
Offscreen position. Used when setting a elements position.

<static> Dwt.NO_REPEAT
Do not repeat background image.

<static> Dwt.RELATIVE_STYLE
Relative position style.

<static> Dwt.REPEAT
Repeat background image.

<static> Dwt.REPEAT_X
Repeat background image horizontally.

<static> Dwt.REPEAT_Y
Repeat background image vertically.

<static> Dwt.SCROLL
Automatically create scrollbars if content overflows.

<static> Dwt.SCROLL_X
Only show scrollbars on X when content overflows.

<static> Dwt.SCROLL_Y
Only show scrollbars on Y when content overflows.

<static> Dwt.SCROLLBAR_WIDTH
Ballpark figure for width of a scrollbar.

<static> Dwt.STATIC_STYLE
Static position style.

<static> Dwt.VISIBLE
Allow overflow to be visible.

<static> Dwt.Z_BUSY
This layer appears in front of other layers to block all user mouse input.

<static> {int} Dwt.Z_CURTAIN
The curtain layer.
See:
DwtShell

<static> Dwt.Z_DIALOG
Dialog layer. Dialogs are positioned at this layer.

<static> Dwt.Z_DIALOG_MENU
Used by menus that are part of a dialog.

<static> Dwt.Z_DND
Drag and Drop (DnD) icon layer. DnD icons are positioned at this layer so they move across the top of other components.

<static> Dwt.Z_HIDDEN
Hidden layer. Elements at this layer will be hidden from view.

<static> Dwt.Z_MENU
Popup menu layer. Used by the menu components.

<static> Dwt.Z_SPLASH
Used by the splash screens.

<static> Dwt.Z_TOAST
The toast layer.

<static> Dwt.Z_TOOLTIP
Tooltips layer.

<static> Dwt.Z_VEIL
Veil layer. The veil appears just behind modal dialogs render other components unable to receive mouse input.

<static> Dwt.Z_VIEW
Visible layer. Elements at this layer will be in view.
Method Detail
<static> Dwt.addClass(el, c)
Adds the given class name to the element's CSS class names
Parameters:
{HTMLElement} el
the HTML Element to which to add the class name
{string} c
the class name
See:
#delClass

<static> {Array} Dwt.byClassName(className, ancestor)
Get all elements of the given class name. Similar to document.getElementsByClassName(), but returning an Array instead of a NodeList.
Parameters:
{String} className
{HTMLElement} ancestor
An optional ancestor element, defaults to the document
Returns:
{Array}

<static> {Array} Dwt.byTag(tagName, ancestor)
Get all elements of a certain tag name. Similar to document.getElementsByTagName(), but returning an Array instead of a NodeList.
Parameters:
{String} tagName
the tag name, such as "A"
{HTMLElement} ancestor
An optional ancestor element, defaults to the document
Returns:
{Array}

<static> Dwt.condClass(el, condition, a, b)
Conditionally add or remove a class name from an element
Parameters:
{HTMLElement} el
the target element
{boolean} condition
the condition to check
{string} a
the class name when condition is true
{string} b
the class name when condition is false

<static> Dwt.createLinearGradientInfo(startColor, endColor, direction)
-- FF 3.6+ background: -moz-linear-gradient(black, white); -- Safari 4+, Chrome 2+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff)); -- Safari 5.1+, Chrome 10+ background: -webkit-linear-gradient(top, black, white); -- Opera 11.10 background: -o-linear-gradient(black, white); -- IE6 & IE7 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff'); -- IE8 & IE9 -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff')"; -- IE10 background: -ms-linear-gradient(black, white); -- the standard background: linear-gradient(black, white);
Parameters:
startColor
endColor
direction

<static> Dwt.delClass(el, del, add)
Remove the del class name from the element's CSS class names and optionally add add class name if given provided
Parameters:
{HTMLElement} el
HTML Element to which to add/delete class names
{string} del Optional
the class name to delete
{string} add Optional
the class name to add

<static> Dwt.doOverlap(el1, el2)
Returns true if the two elements overlap.
Parameters:
el1
el2

<static> {DOMElement} Dwt.findAncestor(domElement, attrName)
Finds an ancestor element with a non-empty value for the given attr.
Parameters:
{DOMElement} domElement
the starting DOM element
{string} attrName
the attribute name
Returns:
{DOMElement} the DOM element

<static> {Array} Dwt.getAncestors(childNode, parentNode, includeChild)
Get ancestor elements of the given node, up to and including the given parent node. If no parent is given, assume the root document node. If the parent node is not an ancestor of the child, return null.
Parameters:
{HTMLElement} childNode
the child HTML element
{HTMLElement} parentNode
the parent HTML element
{Boolean} includeChild
if true, include the child itself
Returns:
{Array} a list of HTML elements

<static> {DwtRectangle} Dwt.getBounds(htmlElement, rect)
Gets the bounds of an HTML element.
Parameters:
{HTMLElement} htmlElement
the HTML element
rect
Returns:
{DwtRectangle} the elements bounds
See:
#setBounds
#getInsetBounds
#getLocation
#getSize

<static> {string} Dwt.getCursor(htmlElement)
Gets the element cursor for a given HTML element.
Parameters:
{HTMLElement} htmlElement
the HTML element
Returns:
{string} the html elements cursor
See:
#setCursor

<static> {DwtPoint} Dwt.getHtmlExtent(html)
Measure the extent in pixels of a section of html. This is not the worlds cheapest method to invoke so do so judiciously
Parameters:
{string} html
the html content for which that extents are to be calculated
Returns:
{DwtPoint} the extent of the content

<static> {string} Dwt.getId(element, prefix)
This method is used to query an element for its id, generating one if it isn't set.
Parameters:
element
prefix
Returns:
{string} the element ID

<static> {DwtRectangle} Dwt.getInsetBounds(htmlElement)
Gets the bounds of an HTML element, excluding borders and paddings.
Parameters:
{HTMLElement} htmlElement
the HTML element
Returns:
{DwtRectangle} the elements bounds
See:
#setBounds
#getInsetBounds
#getLocation
#getSize

<static> {DwtPoint} Dwt.getLocation(htmlElement, point)
Gets the location of an HTML element.
Parameters:
{HTMLElement} htmlElement
the HTML element
point
Returns:
{DwtPoint} the location of the HTML element
See:
#setLocation
#getBounds
#getSize

<static> {string} Dwt.getNextId(prefix)
This method is used to generate a unique id to be used for an HTML element's id attribute.
Parameters:
prefix
Returns:
{string} the next available element ID

<static> {DwtPoint} Dwt.getOuterSize(htmlElement, point)
Gets the outer size -- that is, the size including margins, padding, and borders -- of an HTML element.
Parameters:
{HTMLElement} htmlElement
the HTML element
point
Returns:
{DwtPoint} the elements size, margins included
See:
#getSize
#getBounds
#setBounds
#getInsetBounds
#getLocation

<static> Dwt.getParams(args, paramNames)
Normalizes an argument list into a hash with the given argument names. If a single hash argument is passed, it is recognized as a params hash and returned. Otherwise, the argument list is exploded into a params hash with the given param names.
Parameters:
{Object} args
Array-like structure of arguments
{array} paramNames
an ordered list of param names

<static> {Dwt.CLIP|Dwt.VISIBLE|Dwt.SCROLL|Dwt.FIXED_SCROLL} Dwt.getScrollStyle(htmlElement)
Returns htmlElement's scroll style. The scroll style determines the element's behaviour when content overflows its boundaries. Possible values are:
  • Dwt.CLIP - Clip on overflow
  • Dwt.VISIBLE - Allow overflow to be visible
  • Dwt.SCROLL - Automatically create scrollbars if content overflows
  • Dwt.FIXED_SCROLL - Always have scrollbars whether content overflows or not
Parameters:
{HTMLElement} htmlElement
HTML element
Returns:
{Dwt.CLIP|Dwt.VISIBLE|Dwt.SCROLL|Dwt.FIXED_SCROLL} the elements scroll style

<static> {number} Dwt.getSelectionEnd(input)
Retrieves the end of the selection.
Parameters:
{input|iframe} input
the input for which to find the selection end point. This may be a text input field or an iframe in design mode
Returns:
{number} the starting position of the selection
See:
#getSelectionStart
#setSelectionText
#setSelectionRange
#moveCursorToEnd

<static> {number} Dwt.getSelectionStart(input)
Retrieves the start of the selection. For a collapsed range, this is equivalent to #getSelectionEnd.
Parameters:
{input|iframe} input
input for which to find the selection start point. This may be a text input field or an iframe in design mode
Returns:
{number} starting position of the selection
See:
#getSelectionEnd
#setSelectionText
#setSelectionRange
#moveCursorToEnd

<static> {DwtPoint} Dwt.getSize(htmlElement, point, getFromStyle)
Gets the size of an HTML element. Normally, this yields the calculated size of the element. However, if 'getFromStyle' is true, the style is obtained directly from the CSS style.
Parameters:
{HTMLElement} htmlElement
the HTML element
{DwtPoint} point
if given, reuse this point
{Boolean} getFromStyle
whether to use the calculated size
Returns:
{DwtPoint} the elements size, margins included
See:
#getBounds
#setBounds
#getInsetBounds
#getLocation
#getOuterSize

<static> {DwtPoint} Dwt.getWindowSize(point)
Gets the window size of the browser.
Parameters:
{DwtPoint} point
the point to hold the windows x/y size
Returns:
{DwtPoint} the point holding the window x/y size

<static> {number} Dwt.getZIndex(getFromStyle, getFromStyle)
Get the z-index of an element.
Parameters:
{boolean} getFromStyle
get the value from the style attribute of this element, or a parent
getFromStyle
Returns:
{number} the z-index value

<static> Dwt.hasClass(el, className)
Returns true if the specified element has the given class.
Parameters:
el
className

<static> Dwt.insertText(input, text)
Inserts some text into an input at the caret.
Parameters:
{Element} input
INPUT or TEXTAREA
{String} text
text to insert

<static> Dwt.isAncestor(el1, el2)
Returns true if el1 is an ancestor (in the parent chain) of el2, or if el1 and el2 are the same element.
Parameters:
{DOMElement} el1
{DOMElement} el2

<static> Dwt.moveCursorToEnd(input)
Move cursor to the end of an input.
Parameters:
{input} input
text input
See:
#getSelectionStart
#getSelectionEnd
#setSelectionText
#setSelectionRange

<static> {HTMLElement} Dwt.parseHtmlFragment(html, isRow)
Creates and returns an element from a string of HTML.
Parameters:
{string} html
the HTML text
{boolean} isRow
if true, if the element is a <tr>
Returns:
{HTMLElement} an HTMLElement with the html as its content. if isRow is true, then the element will be a table

<static> Dwt.printPerfMetric()
Prints the computed time from performance metrics data

<static> Dwt.setBounds(htmlElement, x, y, width, height)
Sets the bounds of an HTML element. The position type of the element must be absolute or else an exception is thrown. To omit setting a value set the actual parameter value to Dwt.DEFAULT
Parameters:
{HTMLElement} htmlElement
absolutely positioned HTML element
{number|string} x
the x coordinate of the element (for example: 10, "10px", Dwt.DEFAULT)
{number|string} y
the y coordinate of the element (for example: 10, "10px", Dwt.DEFAULT)
{number} width
the width of the element (for example: 100, "100px", "75%", Dwt.DEFAULT)
{number} height
the height of the element (for example: 100, "100px", "75%", Dwt.DEFAULT)
Throws:
DwtException
See:
#getBounds
#setLocation
#setSize

<static> Dwt.setCursor(htmlElement, cursorName)
Sets an HTML element cursor.
Parameters:
{HTMLElement} htmlElement
the element for which to set the cursor
{string} cursorName
name of the new cursor
See:
#setCursor

<static> Dwt.setLoadedTime(id, date)
Sets up a hidden div for performance metrics. Use to set the end of object rendering
Parameters:
id
{String}
date
{Date}

<static> Dwt.setLoadingTime(id, date)
Sets up a hidden div for performance metrics. Use to set the start of object rendering
Parameters:
id
{String}
date
{Date}

<static> Dwt.setLocation(htmlElement, x, y)
Sets the location of an HTML element. The position type of the element must be absolute or else an exception is thrown. To only set one of the coordinates, pass in a value of Dwt.DEFAULT for the coordinate for which the value is not to be set
Parameters:
{HTMLElement} htmlElement
the absolutely positioned HTML element
{number|string} x
the x coordinate of the element (for example: 10, "10px", Dwt.DEFAULT)
{number|string} y
the y coordinate of the element (for example: 10, "10px", Dwt.DEFAULT)
Throws:
DwtException
See:
#getLocation
#setBounds
#setSize

<static> Dwt.setScrollStyle(htmlElement, scrollStyle)
Sets the htmlElement's scroll style. The scroll style determines the elements's behaviour when content overflows its div's boundaries. Possible values are:
  • Dwt.CLIP - Clip on overflow
  • Dwt.VISIBLE - Allow overflow to be visible
  • Dwt.SCROLL - Automatically create scrollbars if content overflows
  • Dwt.FIXED_SCROLL - Always have scrollbars whether content overflows or not
Parameters:
{HTMLElement} htmlElement
HTML element
{Dwt.CLIP|Dwt.VISIBLE|Dwt.SCROLL|Dwt.FIXED_SCROLL} scrollStyle
the elements scroll style

<static> Dwt.setSelectionRange(input, start, end)
Sets the selection range.
Parameters:
{input|iframe} input
input for which to find the selection start point. This may be a text input field or an iframe in design mode
{number} start
the starting position
{number} end
the ending position
See:
#getSelectionStart
#getSelectionEnd
#setSelectionText
#moveCursorToEnd

<static> Dwt.setSelectionText(input, text)
Sets the selection text
Parameters:
{input|iframe} input
the input for which to set the selection text. This may be a text input field or an iframe in design mode
{string} text
the text to set as the selection
See:
#getSelectionStart
#getSelectionEnd
#setSelectionRange
#moveCursorToEnd

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:25 GMT-0400 (EDT)