# Switch

onSwitchCLick = function (e) { var state = e.currentTarget.state; alert("Toggle state is: " + state) } var switchEl = new innovaphone.ui1.Switch("margin: 30px"); switchEl.addEvent("click", onSwitchCLick); out.appendChild(switchEl.container);

## innovaphone.ui1.Switch(style, height, width, value, cl, foreground, backgroundOff, backgroundOn)

Creates a Switch-Element which toggles two states.

Arguments:

style (optional)
  The style attribute of the node (e.g. "margin: 10px;").
height (optional)
  The style attribute "height" of the node, to define the height of the element (default: 20px).
width (optional)
  The style attribute "width" of the node, to define the width of the element (default: 30px).
value (optional)
  Initial state of the switch (true or false), it's false by default.
cl (optional)
  The CSS class of the node (e.g. "switch").
foreground (optional)
  The slider color (default: "white").
backgroundOff (optional)
  The background node color for the "off"-state of the switch-element (default: "dimgrey").
backgroundOn (optional)
  The background node color for the "on"-state of the switch-element (default: "darkgreen").

Public functions:

getValue()
  Get the state of the switch element (true or false, means "on" or "off").
setValue(value)
  Set the state of the switch element (true or false).
setDisabled(value)
  Set the switch to 'disabled' (true or false).
setTooltip(text)
  Set a text to be displayed on mouseover.