material-ui 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +31 -0
  6. data/Rakefile +20 -0
  7. data/lib/material-ui.rb +4 -0
  8. data/material-ui-gem.gemspec +33 -0
  9. data/vendor/assets/javascripts/material-ui.js +1 -0
  10. data/vendor/assets/javascripts/material-ui/components/app-bar.jsx +93 -0
  11. data/vendor/assets/javascripts/material-ui/components/app-canvas.jsx +27 -0
  12. data/vendor/assets/javascripts/material-ui/components/checkbox.jsx +60 -0
  13. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-month.jsx +59 -0
  14. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-toolbar.jsx +64 -0
  15. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar.jsx +194 -0
  16. data/vendor/assets/javascripts/material-ui/components/date-picker/date-display.jsx +79 -0
  17. data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker-dialog.jsx +118 -0
  18. data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker.jsx +116 -0
  19. data/vendor/assets/javascripts/material-ui/components/date-picker/day-button.jsx +49 -0
  20. data/vendor/assets/javascripts/material-ui/components/dialog-window.jsx +183 -0
  21. data/vendor/assets/javascripts/material-ui/components/dialog.jsx +54 -0
  22. data/vendor/assets/javascripts/material-ui/components/drop-down-icon.jsx +68 -0
  23. data/vendor/assets/javascripts/material-ui/components/drop-down-menu.jsx +94 -0
  24. data/vendor/assets/javascripts/material-ui/components/enhanced-button.jsx +147 -0
  25. data/vendor/assets/javascripts/material-ui/components/enhanced-switch.jsx +296 -0
  26. data/vendor/assets/javascripts/material-ui/components/enhanced-textarea.jsx +113 -0
  27. data/vendor/assets/javascripts/material-ui/components/flat-button.jsx +46 -0
  28. data/vendor/assets/javascripts/material-ui/components/floating-action-button.jsx +123 -0
  29. data/vendor/assets/javascripts/material-ui/components/font-icon.jsx +23 -0
  30. data/vendor/assets/javascripts/material-ui/components/icon-button.jsx +123 -0
  31. data/vendor/assets/javascripts/material-ui/components/ink-bar.jsx +25 -0
  32. data/vendor/assets/javascripts/material-ui/components/input.jsx +143 -0
  33. data/vendor/assets/javascripts/material-ui/components/left-nav.jsx +105 -0
  34. data/vendor/assets/javascripts/material-ui/components/menu/link-menu-item.jsx +42 -0
  35. data/vendor/assets/javascripts/material-ui/components/menu/menu-item.jsx +105 -0
  36. data/vendor/assets/javascripts/material-ui/components/menu/menu.jsx +325 -0
  37. data/vendor/assets/javascripts/material-ui/components/menu/subheader-menu-item.jsx +18 -0
  38. data/vendor/assets/javascripts/material-ui/components/mixins/classable.js +42 -0
  39. data/vendor/assets/javascripts/material-ui/components/mixins/click-awayable.js +35 -0
  40. data/vendor/assets/javascripts/material-ui/components/mixins/window-listenable.js +23 -0
  41. data/vendor/assets/javascripts/material-ui/components/overlay.jsx +58 -0
  42. data/vendor/assets/javascripts/material-ui/components/paper.jsx +58 -0
  43. data/vendor/assets/javascripts/material-ui/components/radio-button-group.jsx +112 -0
  44. data/vendor/assets/javascripts/material-ui/components/radio-button.jsx +65 -0
  45. data/vendor/assets/javascripts/material-ui/components/raised-button.jsx +102 -0
  46. data/vendor/assets/javascripts/material-ui/components/ripples/circle.jsx +35 -0
  47. data/vendor/assets/javascripts/material-ui/components/ripples/focus-ripple.jsx +40 -0
  48. data/vendor/assets/javascripts/material-ui/components/ripples/touch-ripple.jsx +174 -0
  49. data/vendor/assets/javascripts/material-ui/components/slider.jsx +178 -0
  50. data/vendor/assets/javascripts/material-ui/components/snackbar.jsx +76 -0
  51. data/vendor/assets/javascripts/material-ui/components/svg-icons/drop-down-arrow.jsx +16 -0
  52. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-left.jsx +16 -0
  53. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-right.jsx +17 -0
  54. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-menu.jsx +16 -0
  55. data/vendor/assets/javascripts/material-ui/components/svg-icons/svg-icon.jsx +23 -0
  56. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-checked.jsx +16 -0
  57. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-outline-blank.jsx +16 -0
  58. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-off.jsx +16 -0
  59. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-on.jsx +16 -0
  60. data/vendor/assets/javascripts/material-ui/components/table-header.jsx +50 -0
  61. data/vendor/assets/javascripts/material-ui/components/table-rows-item.jsx +31 -0
  62. data/vendor/assets/javascripts/material-ui/components/table-rows.jsx +57 -0
  63. data/vendor/assets/javascripts/material-ui/components/tabs/tab.jsx +38 -0
  64. data/vendor/assets/javascripts/material-ui/components/tabs/tabTemplate.jsx +15 -0
  65. data/vendor/assets/javascripts/material-ui/components/tabs/tabs.jsx +96 -0
  66. data/vendor/assets/javascripts/material-ui/components/text-field.jsx +215 -0
  67. data/vendor/assets/javascripts/material-ui/components/toggle.jsx +62 -0
  68. data/vendor/assets/javascripts/material-ui/components/toolbar-group.jsx +28 -0
  69. data/vendor/assets/javascripts/material-ui/components/toolbar.jsx +21 -0
  70. data/vendor/assets/javascripts/material-ui/components/tooltip.jsx +58 -0
  71. data/vendor/assets/javascripts/material-ui/components/transition-groups/slide-in.jsx +48 -0
  72. data/vendor/assets/javascripts/material-ui/components/utils/css-event.js +52 -0
  73. data/vendor/assets/javascripts/material-ui/components/utils/date-time.js +132 -0
  74. data/vendor/assets/javascripts/material-ui/components/utils/dom.js +71 -0
  75. data/vendor/assets/javascripts/material-ui/components/utils/events.js +34 -0
  76. data/vendor/assets/javascripts/material-ui/components/utils/key-code.js +10 -0
  77. data/vendor/assets/javascripts/material-ui/components/utils/key-line.js +13 -0
  78. data/vendor/assets/javascripts/material-ui/components/utils/unique-id.js +7 -0
  79. data/vendor/assets/stylesheets/material-ui.less +2 -0
  80. data/vendor/assets/stylesheets/material-ui/components.less +5 -0
  81. data/vendor/assets/stylesheets/material-ui/components/app-bar.less +37 -0
  82. data/vendor/assets/stylesheets/material-ui/components/card.less +20 -0
  83. data/vendor/assets/stylesheets/material-ui/components/checkbox.less +66 -0
  84. data/vendor/assets/stylesheets/material-ui/components/components.less +37 -0
  85. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-month.less +11 -0
  86. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-toolbar.less +23 -0
  87. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar.less +59 -0
  88. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-display.less +84 -0
  89. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker-dialog.less +18 -0
  90. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker.less +9 -0
  91. data/vendor/assets/stylesheets/material-ui/components/date-picker/day-button.less +35 -0
  92. data/vendor/assets/stylesheets/material-ui/components/dialog-window.less +42 -0
  93. data/vendor/assets/stylesheets/material-ui/components/dialog.less +10 -0
  94. data/vendor/assets/stylesheets/material-ui/components/drop-down-icon.less +43 -0
  95. data/vendor/assets/stylesheets/material-ui/components/drop-down-menu.less +77 -0
  96. data/vendor/assets/stylesheets/material-ui/components/enhanced-button.less +24 -0
  97. data/vendor/assets/stylesheets/material-ui/components/enhanced-switch.less +52 -0
  98. data/vendor/assets/stylesheets/material-ui/components/enhanced-textarea.less +16 -0
  99. data/vendor/assets/stylesheets/material-ui/components/flat-button.less +93 -0
  100. data/vendor/assets/stylesheets/material-ui/components/floating-action-button.less +95 -0
  101. data/vendor/assets/stylesheets/material-ui/components/font-icon.less +6 -0
  102. data/vendor/assets/stylesheets/material-ui/components/icon-button.less +46 -0
  103. data/vendor/assets/stylesheets/material-ui/components/ink-bar.less +9 -0
  104. data/vendor/assets/stylesheets/material-ui/components/input.less +186 -0
  105. data/vendor/assets/stylesheets/material-ui/components/left-nav.less +31 -0
  106. data/vendor/assets/stylesheets/material-ui/components/menu-item.less +69 -0
  107. data/vendor/assets/stylesheets/material-ui/components/menu.less +50 -0
  108. data/vendor/assets/stylesheets/material-ui/components/overlay.less +21 -0
  109. data/vendor/assets/stylesheets/material-ui/components/paper.less +59 -0
  110. data/vendor/assets/stylesheets/material-ui/components/radio-button.less +67 -0
  111. data/vendor/assets/stylesheets/material-ui/components/raised-button.less +132 -0
  112. data/vendor/assets/stylesheets/material-ui/components/ripples/circle.less +31 -0
  113. data/vendor/assets/stylesheets/material-ui/components/ripples/focus-ripple.less +30 -0
  114. data/vendor/assets/stylesheets/material-ui/components/ripples/touch-ripple.less +9 -0
  115. data/vendor/assets/stylesheets/material-ui/components/slider.less +163 -0
  116. data/vendor/assets/stylesheets/material-ui/components/snackbar.less +44 -0
  117. data/vendor/assets/stylesheets/material-ui/components/subheader.less +17 -0
  118. data/vendor/assets/stylesheets/material-ui/components/svg-icon.less +11 -0
  119. data/vendor/assets/stylesheets/material-ui/components/table.less +46 -0
  120. data/vendor/assets/stylesheets/material-ui/components/tabs.less +41 -0
  121. data/vendor/assets/stylesheets/material-ui/components/text-field.less +168 -0
  122. data/vendor/assets/stylesheets/material-ui/components/toggle.less +83 -0
  123. data/vendor/assets/stylesheets/material-ui/components/toolbar.less +95 -0
  124. data/vendor/assets/stylesheets/material-ui/components/tooltip.less +73 -0
  125. data/vendor/assets/stylesheets/material-ui/components/transition-groups/slide-in.less +92 -0
  126. data/vendor/assets/stylesheets/material-ui/core/base.less +31 -0
  127. data/vendor/assets/stylesheets/material-ui/core/core.less +4 -0
  128. data/vendor/assets/stylesheets/material-ui/core/keylines.less +29 -0
  129. data/vendor/assets/stylesheets/material-ui/core/layouts.less +12 -0
  130. data/vendor/assets/stylesheets/material-ui/core/typography.less +158 -0
  131. data/vendor/assets/stylesheets/material-ui/mixins/clearfix.less +22 -0
  132. data/vendor/assets/stylesheets/material-ui/mixins/mixins.less +3 -0
  133. data/vendor/assets/stylesheets/material-ui/mixins/no-wrap.less +3 -0
  134. data/vendor/assets/stylesheets/material-ui/mixins/transitions.less +17 -0
  135. data/vendor/assets/stylesheets/material-ui/resets/normalize.css +430 -0
  136. data/vendor/assets/stylesheets/material-ui/resets/typography-resets.less +34 -0
  137. data/vendor/assets/stylesheets/material-ui/scaffolding.less +10 -0
  138. data/vendor/assets/stylesheets/material-ui/variables/colors.less +285 -0
  139. data/vendor/assets/stylesheets/material-ui/variables/custom-variables.less +163 -0
  140. data/vendor/assets/stylesheets/material-ui/variables/media-queries.less +4 -0
  141. data/vendor/assets/stylesheets/material-ui/variables/spacing.less +16 -0
  142. metadata +268 -0
@@ -0,0 +1,18 @@
1
+ var React = require('react');
2
+
3
+ var SubheaderMenuItem = React.createClass({
4
+
5
+ propTypes: {
6
+ index: React.PropTypes.number.isRequired,
7
+ text: React.PropTypes.string.isRequired
8
+ },
9
+
10
+ render: function() {
11
+ return (
12
+ <div key={this.props.index} className="mui-subheader">{this.props.text}</div>
13
+ );
14
+ }
15
+
16
+ });
17
+
18
+ module.exports = SubheaderMenuItem;
@@ -0,0 +1,42 @@
1
+ var React = require('react');
2
+ var classNames = require('classnames');
3
+
4
+ module.exports = {
5
+
6
+ propTypes: {
7
+ className: React.PropTypes.string
8
+ },
9
+
10
+ getClasses: function(initialClasses, additionalClassObj) {
11
+ var classString = '';
12
+
13
+ //Initialize the classString with the classNames that were passed in
14
+ if (this.props.className) classString += ' ' + this.props.className;
15
+
16
+ //Add in initial classes
17
+ if (typeof initialClasses === 'object') {
18
+ classString += ' ' + classNames(initialClasses);
19
+ } else {
20
+ classString += ' ' + initialClasses;
21
+ }
22
+
23
+ //Add in additional classes
24
+ if (additionalClassObj) classString += ' ' + classNames(additionalClassObj);
25
+
26
+ //Convert the class string into an object and run it through the class set
27
+ return classNames(this.getClassSet(classString));
28
+ },
29
+
30
+ getClassSet: function(classString) {
31
+ var classObj = {};
32
+
33
+ if (classString) {
34
+ classString.split(' ').forEach(function(className) {
35
+ if (className) classObj[className] = true;
36
+ });
37
+ }
38
+
39
+ return classObj;
40
+ }
41
+
42
+ }
@@ -0,0 +1,35 @@
1
+ var Events = require('../utils/events');
2
+ var Dom = require('../utils/dom');
3
+
4
+ module.exports = {
5
+
6
+ //When the component mounts, listen to click events and check if we need to
7
+ //Call the componentClickAway function.
8
+ componentDidMount: function() {
9
+ if (!this.manuallyBindClickAway) this._bindClickAway();
10
+ },
11
+
12
+ componentWillUnmount: function() {
13
+ this._unbindClickAway();
14
+ },
15
+
16
+ _checkClickAway: function(e) {
17
+ var el = this.getDOMNode();
18
+
19
+ // Check if the target is inside the current component
20
+ if (this.isMounted() &&
21
+ e.target != el &&
22
+ !Dom.isDescendant(el, e.target)) {
23
+ if (this.componentClickAway) this.componentClickAway();
24
+ }
25
+ },
26
+
27
+ _bindClickAway: function() {
28
+ Events.on(document, 'click', this._checkClickAway);
29
+ },
30
+
31
+ _unbindClickAway: function() {
32
+ Events.off(document, 'click', this._checkClickAway);
33
+ }
34
+
35
+ };
@@ -0,0 +1,23 @@
1
+ var Events = require('../utils/events');
2
+
3
+ module.exports = {
4
+
5
+ componentDidMount: function() {
6
+ var listeners = this.windowListeners;
7
+
8
+ for (var eventName in listeners) {
9
+ var callbackName = listeners[eventName];
10
+ Events.on(window, eventName, this[callbackName]);
11
+ }
12
+ },
13
+
14
+ componentWillUnmount: function() {
15
+ var listeners = this.windowListeners;
16
+
17
+ for (var eventName in listeners) {
18
+ var callbackName = listeners[eventName];
19
+ Events.off(window, eventName, this[callbackName]);
20
+ }
21
+ }
22
+
23
+ }
@@ -0,0 +1,58 @@
1
+ var React = require('react'),
2
+ Classable = require('./mixins/classable');
3
+
4
+ var Overlay = React.createClass({
5
+
6
+ mixins: [Classable],
7
+
8
+ propTypes: {
9
+ show: React.PropTypes.bool,
10
+ autoLockScrolling: React.PropTypes.bool
11
+ },
12
+
13
+ getDefaultProps: function() {
14
+ return {
15
+ autoLockScrolling: true
16
+ };
17
+ },
18
+
19
+ componentDidUpdate: function(prevProps, prevState) {
20
+ if (this.props.autoLockScrolling) (this.props.show) ? this._preventScrolling() : this._allowScrolling();
21
+ },
22
+
23
+ render: function() {
24
+ var
25
+ {
26
+ className,
27
+ ...other
28
+ } = this.props,
29
+ classes = this.getClasses('mui-overlay', {
30
+ 'mui-is-shown': this.props.show
31
+ });
32
+
33
+ return (
34
+ <div {...other} className={classes} />
35
+ );
36
+ },
37
+
38
+ preventScrolling: function() {
39
+ if (!this.props.autoLockScrolling) this._preventScrolling();
40
+ },
41
+
42
+ allowScrolling: function() {
43
+ if (!this.props.autoLockScrolling) this._allowScrolling();
44
+ },
45
+
46
+ _preventScrolling: function() {
47
+ var body = document.getElementsByTagName('body')[0];
48
+ body.style.overflow = 'hidden';
49
+ },
50
+
51
+ _allowScrolling: function() {
52
+ var body = document.getElementsByTagName('body')[0];
53
+ body.style.overflow = '';
54
+ }
55
+
56
+ });
57
+
58
+ module.exports = Overlay;
@@ -0,0 +1,58 @@
1
+ var React = require('react'),
2
+ Classable = require('./mixins/classable');
3
+
4
+ var Paper = React.createClass({
5
+
6
+ mixins: [Classable],
7
+
8
+ propTypes: {
9
+ circle: React.PropTypes.bool,
10
+ innerClassName: React.PropTypes.string,
11
+ innerStyle: React.PropTypes.object,
12
+ rounded: React.PropTypes.bool,
13
+ zDepth: React.PropTypes.oneOf([0,1,2,3,4,5])
14
+ },
15
+
16
+ getDefaultProps: function() {
17
+ return {
18
+ innerClassName: '',
19
+ rounded: true,
20
+ zDepth: 1
21
+ };
22
+ },
23
+
24
+ render: function() {
25
+ var {
26
+ className,
27
+ circle,
28
+ innerClassName,
29
+ rounded,
30
+ zDepth,
31
+ ...other } = this.props,
32
+ classes = this.getClasses(
33
+ 'mui-paper ' +
34
+ 'mui-z-depth-' + this.props.zDepth, {
35
+ 'mui-rounded': this.props.rounded,
36
+ 'mui-circle': this.props.circle
37
+ }),
38
+ insideClasses =
39
+ this.props.innerClassName + ' ' +
40
+ 'mui-paper-container ' +
41
+ 'mui-z-depth-bottom';
42
+
43
+ return (
44
+ <div {...other} className={classes}>
45
+ <div ref="innerContainer" className={insideClasses} style={this.props.innerStyle || {}}>
46
+ {this.props.children}
47
+ </div>
48
+ </div>
49
+ );
50
+ },
51
+
52
+ getInnerContainer: function() {
53
+ return this.refs.innerContainer;
54
+ }
55
+
56
+ });
57
+
58
+ module.exports = Paper;
@@ -0,0 +1,112 @@
1
+ var React = require('react');
2
+ var Paper = require('./paper');
3
+ var Classable = require('./mixins/classable');
4
+ var EnhancedSwitch = require('./enhanced-switch');
5
+ var RadioButton = require('./radio-button');
6
+
7
+ var RadioButtonGroup = React.createClass({
8
+
9
+ mixins: [Classable],
10
+
11
+ propTypes: {
12
+ name: React.PropTypes.string.isRequired,
13
+ valueSelected: React.PropTypes.string,
14
+ defaultSelected: React.PropTypes.string,
15
+ labelPosition: React.PropTypes.oneOf(['left', 'right']),
16
+ onChange: React.PropTypes.func
17
+ },
18
+
19
+ _hasCheckAttribute: function(radioButton) {
20
+ return radioButton.props.hasOwnProperty('checked') &&
21
+ radioButton.props.checked;
22
+ },
23
+
24
+ getInitialState: function() {
25
+ return {
26
+ numberCheckedRadioButtons: 0,
27
+ selected: this.props.valueSelected || this.props.defaultSelected || ''
28
+ };
29
+ },
30
+
31
+ componentWillMount: function() {
32
+ var cnt = 0;
33
+
34
+ this.props.children.forEach(function(option) {
35
+ if (this._hasCheckAttribute(option)) cnt++;
36
+ }, this);
37
+
38
+ this.setState({numberCheckedRadioButtons: cnt});
39
+ },
40
+
41
+ componentWillReceiveProps: function(nextProps) {
42
+ if (nextProps.hasOwnProperty('valueSelected')) {
43
+ this.setState({selected: nextProps.valueSelected});
44
+ }
45
+ },
46
+
47
+ render: function() {
48
+
49
+ var options = this.props.children.map(function(option) {
50
+
51
+ var {
52
+ name,
53
+ value,
54
+ label,
55
+ onCheck,
56
+ ...other
57
+ } = option.props;
58
+
59
+ return <RadioButton
60
+ {...other}
61
+ ref={option.props.value}
62
+ name={this.props.name}
63
+ key={option.props.value}
64
+ value={option.props.value}
65
+ label={option.props.label}
66
+ labelPosition={this.props.labelPosition}
67
+ onCheck={this._onChange}
68
+ checked={option.props.value == this.state.selected}/>
69
+
70
+ }, this);
71
+
72
+ return (
73
+ <div>
74
+ {options}
75
+ </div>
76
+ );
77
+ },
78
+
79
+ _updateRadioButtons: function(newSelection) {
80
+ if (this.state.numberCheckedRadioButtons == 0) {
81
+ this.setState({selected: newSelection});
82
+ } else if (process.NODE_ENV !== 'production') {
83
+ var message = "Cannot select a different radio button while another radio button " +
84
+ "has the 'checked' property set to true.";
85
+ console.error(message);
86
+ }
87
+ },
88
+
89
+ _onChange: function(e, newSelection) {
90
+ this._updateRadioButtons(newSelection);
91
+
92
+ // Successful update
93
+ if (this.state.numberCheckedRadioButtons == 0) {
94
+ if (this.props.onChange) this.props.onChange(e, newSelection);
95
+ }
96
+ },
97
+
98
+ getSelectedValue: function() {
99
+ return this.state.selected;
100
+ },
101
+
102
+ setSelectedValue: function(newSelection) {
103
+ this._updateRadioButtons(newSelection);
104
+ },
105
+
106
+ clearValue: function() {
107
+ this.setSelectedValue('');
108
+ }
109
+
110
+ });
111
+
112
+ module.exports = RadioButtonGroup;
@@ -0,0 +1,65 @@
1
+ var React = require('react');
2
+ var Classable = require('./mixins/classable');
3
+ var EnhancedSwitch = require('./enhanced-switch');
4
+ var RadioButtonOff = require('./svg-icons/toggle-radio-button-off');
5
+ var RadioButtonOn = require('./svg-icons/toggle-radio-button-on');
6
+
7
+ var RadioButton = React.createClass({
8
+
9
+ mixins: [Classable],
10
+
11
+ propTypes: {
12
+ onCheck: React.PropTypes.func
13
+ },
14
+
15
+ render: function() {
16
+
17
+ var {
18
+ onCheck,
19
+ ...other
20
+ } = this.props;
21
+
22
+ var radioButtonElement = (
23
+ <div>
24
+ <RadioButtonOff className="mui-radio-button-target" />
25
+ <RadioButtonOn className="mui-radio-button-fill" />
26
+ </div>
27
+ );
28
+
29
+ var enhancedSwitchProps = {
30
+ ref: "enhancedSwitch",
31
+ inputType: "radio",
32
+ switchElement: radioButtonElement,
33
+ className: "mui-radio-button",
34
+ iconClassName: "mui-radio-button-icon",
35
+ onSwitch: this._handleCheck,
36
+ labelPosition: (this.props.labelPosition) ? this.props.labelPosition : "right"
37
+ };
38
+
39
+ return (
40
+ <EnhancedSwitch
41
+ {...other}
42
+ {...enhancedSwitchProps}/>
43
+ );
44
+ },
45
+
46
+ // Only called when selected, not when unselected.
47
+ _handleCheck: function(e) {
48
+ if (this.props.onCheck) this.props.onCheck(e, this.props.value);
49
+ },
50
+
51
+ isChecked: function() {
52
+ return this.refs.enhancedSwitch.isSwitched();
53
+ },
54
+
55
+ setChecked: function(newCheckedValue) {
56
+ this.refs.enhancedSwitch.setSwitched(newCheckedValue);
57
+ this.setState({switched: newCheckedValue});
58
+ },
59
+
60
+ getValue: function() {
61
+ return this.refs.enhancedSwitch.getValue();
62
+ }
63
+ });
64
+
65
+ module.exports = RadioButton;
@@ -0,0 +1,102 @@
1
+ var React = require('react');
2
+ var Classable = require('./mixins/classable');
3
+ var EnhancedButton = require('./enhanced-button');
4
+ var Paper = require('./paper');
5
+
6
+ var RaisedButton = React.createClass({
7
+
8
+ mixins: [Classable],
9
+
10
+ propTypes: {
11
+ className: React.PropTypes.string,
12
+ label: function(props, propName, componentName){
13
+ if (!props.children && !props.label) {
14
+ return new Error('Warning: Required prop `label` or `children` was not specified in `'+ componentName + '`.')
15
+ }
16
+ },
17
+ onMouseDown: React.PropTypes.func,
18
+ onMouseUp: React.PropTypes.func,
19
+ onMouseOut: React.PropTypes.func,
20
+ onTouchEnd: React.PropTypes.func,
21
+ onTouchStart: React.PropTypes.func,
22
+ primary: React.PropTypes.bool,
23
+ secondary: React.PropTypes.bool
24
+ },
25
+
26
+ getInitialState: function() {
27
+ var zDepth = this.props.disabled ? 0 : 1;
28
+ return {
29
+ zDepth: zDepth,
30
+ initialZDepth: zDepth
31
+ };
32
+ },
33
+
34
+ componentWillReceiveProps: function(nextProps) {
35
+ var zDepth = nextProps.disabled ? 0 : 1;
36
+ this.setState({
37
+ zDepth: zDepth,
38
+ initialZDepth: zDepth
39
+ });
40
+ },
41
+
42
+ render: function() {
43
+ var {
44
+ label,
45
+ primary,
46
+ secondary,
47
+ ...other } = this.props;
48
+ var classes = this.getClasses('mui-raised-button', {
49
+ 'mui-is-primary': !this.props.disabled && primary,
50
+ 'mui-is-secondary': !this.props.disabled && !primary && secondary
51
+ });
52
+ var children;
53
+
54
+ if (label) children = <span className="mui-raised-button-label">{label}</span>;
55
+ else children = this.props.children;
56
+
57
+ return (
58
+ <Paper className={classes} zDepth={this.state.zDepth}>
59
+ <EnhancedButton {...other}
60
+ className="mui-raised-button-container"
61
+ onMouseUp={this._handleMouseUp}
62
+ onMouseDown={this._handleMouseDown}
63
+ onMouseOut={this._handleMouseOut}
64
+ onTouchStart={this._handleTouchStart}
65
+ onTouchEnd={this._handleTouchEnd}>
66
+ {children}
67
+ </EnhancedButton>
68
+ </Paper>
69
+ );
70
+ },
71
+
72
+ _handleMouseDown: function(e) {
73
+ //only listen to left clicks
74
+ if (e.button === 0) {
75
+ this.setState({ zDepth: this.state.initialZDepth + 1 });
76
+ }
77
+ if (this.props.onMouseDown) this.props.onMouseDown(e);
78
+ },
79
+
80
+ _handleMouseUp: function(e) {
81
+ this.setState({ zDepth: this.state.initialZDepth });
82
+ if (this.props.onMouseUp) this.props.onMouseUp(e);
83
+ },
84
+
85
+ _handleMouseOut: function(e) {
86
+ this.setState({ zDepth: this.state.initialZDepth });
87
+ if (this.props.onMouseOut) this.props.onMouseOut(e);
88
+ },
89
+
90
+ _handleTouchStart: function(e) {
91
+ this.setState({ zDepth: this.state.initialZDepth + 1 });
92
+ if (this.props.onTouchStart) this.props.onTouchStart(e);
93
+ },
94
+
95
+ _handleTouchEnd: function(e) {
96
+ this.setState({ zDepth: this.state.initialZDepth });
97
+ if (this.props.onTouchEnd) this.props.onTouchEnd(e);
98
+ }
99
+
100
+ });
101
+
102
+ module.exports = RaisedButton;