Class: ToggleButton

caph.stripe.ui.component. ToggleButton

new ToggleButton(option)

A class for make togglebutton

Parameters:
Name Type Description
option Object

option is object for set component's attribute.
Details : caph.stripe.ui.component.ToggleButton#setOption

Since:
  • 2.0.0
Author:
  • jlux.son@samsung.com
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton({
     contents : {
         'on' : 'on state contents',
         'off' : 'off state contents'
     },
     size : [200, 70],
     position : [100, 100, 0],
     dom : {
         id : 'Caph-Button1',
         style : {
             'opacity' : 0.5
         }
     }
 });

Extends

  • caph.ui.base.component.Button

Methods

isTurnedOn() → {Boolean}

Get toggled state.

Since:
  • 2.0.0
Returns:
Type
Boolean
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton();

 button.setOption({
     contents : {
         on : 'on state contents',
         off : 'off state contents'
     },
     state : on //set on state.
 });

button.isTurnedOn();//return true

setAlign(align) → {caph.ui.base.component.ToggleButton}

Set alignment for ToggleButton

Parameters:
Name Type Description
align String

Alignment for button's value.
If user want to set multiple alignment, then using this token '|' like this : 'top|right'.
Details : caph.ui.base.component.Button#setAlign

Since:
  • 2.0.0
Returns:
Type
caph.ui.base.component.ToggleButton
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton();

 button.setContent({
     'on' : 'on state contents',
     'off' : 'off state contents'
 });

 button.setAlign('right');

setContent(contents)

Set the ToggleButton's contents

Parameters:
Name Type Description
contents Object

contents is String which set for button's contents.

Contents Type
String, {caph.ui.base.component.Icon}

Since:
  • 2.0.0
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton();

 button.setContent({
     'on' : 'on state contents',
     'off' : 'off state contents'
 });

setEnable(state) → {caph.stripe.ui.component.ToggleButton}

Set enable state for button.

Parameters:
Name Type Description
state Boolean

set ToggleButton to enable state or disable state.
true is enable, false is disable.

Since:
  • 2.0.0
Returns:
Type
caph.stripe.ui.component.ToggleButton
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');

 var button = new ToggleButton({
     contents : {
         on : Icon.ff(),
         off : Icon.bgm()
     }
 });

 button.setEnable(false); //disable

setOption(option)

Sets this object's own properties with the given option.

Parameters:
Name Type Description
option Object

A set of button's properties.

Since:
  • 2.0.0
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton();

 button.setOption({
     contents : {
         'on' : 'on state contents',
         'off' : 'off state contents'
     }
 });

toggle() → {caph.stripe.ui.component.ToggleButton}

Change togglebuttons' contents from on to off or from off to on.

Since:
  • 2.0.0
Returns:
Type
caph.stripe.ui.component.ToggleButton
Example
var ToggleButton = caph.require('caph.stripe.ui.component.ToggleButton');
 var button = new ToggleButton();

 button.setOption({
     contents : {
         on : 'on state contents',
         off : 'off state contents'
     },
     state : on //set on state.
 });


 button.toggle(); //change to off state.
 button.toggle(); //change to on state.