/** @jsx React.DOM */ var Slider = createReactClass({ key: function(e) { if (e.keyCode == 32) { // Toggle on space. if (this.props.onChange) { this.props.onChange(!this.props.value); } } else if (e.keyCode == 39) { // Slide with cursor keys. if (this.props.onChange && this.props.value) { this.props.onChange(!this.props.value); } } else if (e.keyCode == 37) { // Slide with cursor keys. if (this.props.onChange && !this.props.value) { this.props.onChange(!this.props.value); } } else { // Don't handle, so don't hit the default prevent below. return; } e.preventDefault(); e.stopPropagation(); }, render: function() { return (
{ this.props.value ? <> {this.props.on} : <> {this.props.off} }
); }, });