Skip to content

Commit aa0d5f5

Browse files
committed
Updated for release
1 parent 3fae945 commit aa0d5f5

16 files changed

+132
-262
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/bower_components

dist/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.module-cache

dist/react-switch-button.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
* @class SwitchButton
88
* @author =undo= <g.fazioli@wpxtre.me>
99
* @date 2015-03-02
10-
* @version 1.0.3
10+
* @version 1.0.4
11+
*
12+
* @history 1.0.0 First public release
13+
* @history 1.0.3 Minor fixes
14+
* @history 1.0.4 @deprecated since 1.0.4 - use labelRight instead - issue #5 https://github.com/gfazioli/react-switch-button/issues/5
1115
*/
1216

17+
"use strict";
18+
1319
var SwitchButton = React.createClass( {
1420

1521
// Display name
1622
displayName : 'Switch Button',
1723

1824
// Version
19-
version : '1.0.3',
25+
version : '1.0.4',
2026

2127
/**
2228
* The props types.
@@ -27,6 +33,7 @@ var SwitchButton = React.createClass( {
2733
title : React.PropTypes.string,
2834
label : React.PropTypes.string,
2935
label_right : React.PropTypes.string,
36+
labelRight : React.PropTypes.string,
3037
defaultChecked : React.PropTypes.string,
3138
theme : React.PropTypes.string,
3239
checked : React.PropTypes.string,
@@ -47,6 +54,7 @@ var SwitchButton = React.createClass( {
4754
title : '',
4855
label : '',
4956
label_right : '',
57+
labelRight : '',
5058
defaultChecked : '',
5159
theme : 'rsbc-switch-button-flat-round',
5260
checked : null,
@@ -55,7 +63,7 @@ var SwitchButton = React.createClass( {
5563
},
5664

5765
// Handle change
58-
handleChange : function()
66+
handleChange : function()
5967
{
6068
// Override
6169
},
@@ -67,32 +75,38 @@ var SwitchButton = React.createClass( {
6775
*/
6876
render : function()
6977
{
70-
var id, label, label_right;
78+
var id, label, labelRight;
7179

7280
if( this.props.id == '' && this.props.name != '' ) {
7381
id = this.props.name;
7482
}
7583

7684
if( this.props.label != '' ) {
7785
label = (
78-
<label htmlFor={id}>{this.props.label}</label>
86+
React.createElement("label", {htmlFor: id}, this.props.label)
7987
);
8088
}
8189

82-
if( this.props.label_right != '' ) {
83-
label_right = (
84-
<label htmlFor={id}>{this.props.label_right}</label>
90+
// @deprecated since 1.0.4 - use labelRight instead - issue #5 https://github.com/gfazioli/react-switch-button/issues/5
91+
if( 'undefined' !== this.props.label_right || this.props.label_right != '' ) {
92+
this.props.labelRight = this.props.label_right;
93+
}
94+
95+
if( this.props.labelRight != '' ) {
96+
labelRight = (
97+
React.createElement("label", {htmlFor: id}, this.props.labelRight)
8598
);
8699
}
87100

88101
return (
89-
<div className={'rsbc-switch-button ' + this.props.theme }>
90-
{label}
91-
<input onChange={this.props.onChange} checked={this.props.checked} defaultChecked={this.props.defaultChecked} id={id} name={this.props.name} type="checkbox" value="1" />
92-
<label htmlFor={id}></label>
93-
{label_right}
94-
</div>
102+
React.createElement("div", {className: 'rsbc-switch-button ' + this.props.theme},
103+
label,
104+
React.createElement("input", {onChange: this.props.onChange, checked: this.props.checked, defaultChecked: this.props.defaultChecked,
105+
id: id, name: this.props.name, type: "checkbox", value: "1"}),
106+
React.createElement("label", {htmlFor: id}),
107+
labelRight
108+
)
95109
);
96110
}
97111

98-
} );
112+
} );

dist/react-switch-button.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-switch-button.min.js

Lines changed: 1 addition & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/assets/css/demo.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/assets/demo.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Demo Switch Button control.
3+
*
4+
*/
5+
6+
var Demo = React.createClass( {displayName: "Demo",
7+
8+
render : function()
9+
{
10+
11+
var style = { textAlign : 'center' };
12+
13+
var code = [
14+
{ code : '<SwitchButton name="switch-1" />', object : React.createElement(SwitchButton, {name: "switch-1"}) },
15+
{ code : '<SwitchButton name="switch-2" defaultChecked="checked" />', object : React.createElement(SwitchButton, {name: "switch-2", defaultChecked: "checked"}) },
16+
{
17+
code : '<SwitchButton name="switch-3" label="Click me" defaultChecked="checked" />',
18+
object : React.createElement(SwitchButton, {name: "switch-3", label: "Click me", defaultChecked: "checked"})
19+
},
20+
{
21+
code : '<SwitchButton name="switch-4" label_right="Click me" defaultChecked="checked" />',
22+
object : React.createElement(SwitchButton, {name: "switch-4", label_right: "Click me", defaultChecked: "checked"})
23+
},
24+
{
25+
code : '<SwitchButton name="switch-5" label="Both" label_right="Click me" defaultChecked="checked" />',
26+
object : React.createElement(SwitchButton, {name: "switch-5", label: "Both", label_right: "Click me", defaultChecked: "checked"})
27+
}
28+
];
29+
30+
var rows = code.map( function( o, i )
31+
{
32+
33+
return (
34+
React.createElement("div", {key: i},
35+
React.createElement("pre", null, o.code),
36+
o.object
37+
)
38+
);
39+
40+
} );
41+
42+
return (
43+
React.createElement("div", {style: style},
44+
React.createElement("h1", null, "Hello, React Switch Button"),
45+
rows
46+
)
47+
);
48+
}
49+
50+
51+
} );
52+
53+
React.render(
54+
React.createElement(Demo, null),
55+
document.getElementById( 'content' )
56+
);
File renamed without changes.

example/assets/react-switch-button.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)