// Generated by github.com/steida/coffee2closure 0.1.12
goog.provide('spark.components.ToggleSwitch');
goog.require('spark.components.LabeledInput');
/**
iOS style on-off switch for Spark Framework.
@constructor
@export
@param {Object=} options Class options.
@param {*=} data Class data
@extends {spark.components.LabeledInput}
*/
spark.components.ToggleSwitch = function(options, data) {
var inputOptions, labelOptions, _ref;
if (options == null) {
options = {};
}
options.cssClass = this.getCssClass(options, 'toggle-switch');
options.inputFirst = true;
options.name || (options.name = options['name'] || null);
if (options.checked == null) {
options.checked = (_ref = options['checked']) != null ? _ref : false;
}
labelOptions = options.labelOptions || options['labelOptions'] || {};
labelOptions.label = '';
inputOptions = options.inputOptions || options['inputOptions'] || {};
inputOptions.type = 'checkbox';
if (options.name) {
inputOptions.name = options.name;
}
options.labelOptions = labelOptions;
options.inputOptions = inputOptions;
spark.components.ToggleSwitch.superClass_.constructor.call(this, options, data);
if (options.checked) {
this.check();
}
this.input.on('StateChanged', (function(_this) {
return function(e) {
return _this.emit('StateChanged', e.data);
};
})(this));
}
goog.inherits(spark.components.ToggleSwitch, spark.components.LabeledInput);
/**
Check the element.
@export
*/
spark.components.ToggleSwitch.prototype.check = function() {
return this.input.check();
};
/**
Uncheck the element.
@export
*/
spark.components.ToggleSwitch.prototype.uncheck = function() {
return this.input.uncheck();
};
/**
Returns element's checked state.
@export
@return {boolean} Checked state.
*/
spark.components.ToggleSwitch.prototype.isChecked = function() {
return this.input.isChecked();
};