Client Class wwControl

The wwControl class is a thin wrapper around HTML DOM controls that provides browser independent functionality for a handful of common behaviors and operations as well as some useful and frequently resusable visual effects. There are two ways you can get a reference to a wwControl from a DOM element:

var ctl = new wwControl("divElement"); var ctl2 = $ww("divElement");

The easiest to create a wwControl object is to pass it a Client Control Id as a string:

var Ctl = new $ww("Panel") ; if (Ctl.isNull) return; Ctl.setHtml("<b>Hello World<b>"); Ctl.setText("This string contains a <div> tag as text."); Ctl.setOpacity(.85); Ctl.showShadow(.20,7); Ctl.centerInClient(); Ctl.css("Color","green"); // same as = "green"; var domElement = Ctl.element;

To create the control you can also pass in an existing DOM reference:

var divPanel = $('Panel'); var Ctl = new wwControl(divPanel);


This class has no dependencies on server side features.

Class Members

centerInClient Centers the control in the client area of the browser.
css Sets a CSS style using DOM style element notation for CSS property names. This is the same as referencing and assiging a value to it. This shortcut is provided to reduce code size.
fadein Fades in the specified control by using Opacity.
fadeout Fades out the control content by using opacity.
getBounds Returns and object that returns x, y, width, height properties that contains the bounds of the object for the absolute position of the control. The optional parameter allows returning a client window relative position that is adjusted for scrollbars.
getLocation Returns an object with x and y properties that returns the absolute document position of the control. Optional parameter allows returning client coordinates adjusted for scroll position.
hide Hides a control by setting its display or visibility attributes.
hideShadow Hides a shadow that was previously shown on the control.
setBounds Sets the bounds of the current control.
setHtml Assigns HTML to the control. Currently simply set the innerHTML if avalailable.
setLocation Sets the absolute position of a control.
setOpactity Sets the opacity of the control to the specified value. The value is specifed as a fractional percentage (ie. 0.23 for 23%).
setText Sets text on the control. If the control has a value property the value is set, otherwise the innerText or textContent property is set. Text set will be HTML encoded by the browser automatically. If you need to encode on your own or provide custom formatting use setHtml instead.
show Makes the control visible by setting the display and visibility attributes. If SetOpacity is passed opacity is also set to 1.
showShadow Displays a shadow on the control. The control must be absolutely positioned.
element A reference to the underlying HTML DOM element that the wwControl object is bound to. The element is passed as part of the constructor either as a string which is retrieved and stored or as an existing DOM object reference
id The id of the underlying control. Same as Provided for convenience.
isNull Can be checked whether the control is properly initialized. Due to the fact that constructors will create an object even if you fail, this property can be used to determine if the control assigned to the wwControl instance was properly initialized.


See also:

Class wwControl

  Last Updated: 10/9/2007 | © West Wind Technologies, 2008