aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Header.jsx
diff options
context:
space:
mode:
authorMG12 <wuzhao.mail@gmail.com>2015-12-16 12:19:56 +0800
committerMG12 <wuzhao.mail@gmail.com>2015-12-16 12:19:56 +0800
commit700c77e4f32e2ec18f3c63b176bf83bac24cdb74 (patch)
treedd7b0d090e946586dbc3bb5268a0a5b5619f81e4 /src/module/Header.jsx
parent182e9fccc90ae709322b7cc314c8775a9d8d46b8 (diff)
parentbec70d57f3ef17ed1ef29c660936be235804061e (diff)
downloadtime-picker-700c77e4f32e2ec18f3c63b176bf83bac24cdb74.tar.gz
time-picker-700c77e4f32e2ec18f3c63b176bf83bac24cdb74.tar.zst
time-picker-700c77e4f32e2ec18f3c63b176bf83bac24cdb74.zip
Merge pull request #10 from react-component/1.0.0-alpha7
1.0.0 alpha7
Diffstat (limited to 'src/module/Header.jsx')
-rw-r--r--src/module/Header.jsx21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/module/Header.jsx b/src/module/Header.jsx
index ef88948..9a048dc 100644
--- a/src/module/Header.jsx
+++ b/src/module/Header.jsx
@@ -13,6 +13,9 @@ const Header = React.createClass({
13 hourOptions: PropTypes.array, 13 hourOptions: PropTypes.array,
14 minuteOptions: PropTypes.array, 14 minuteOptions: PropTypes.array,
15 secondOptions: PropTypes.array, 15 secondOptions: PropTypes.array,
16 disabledHours: PropTypes.func,
17 disabledMinutes: PropTypes.func,
18 disabledSeconds: PropTypes.func,
16 onChange: PropTypes.func, 19 onChange: PropTypes.func,
17 onClear: PropTypes.func, 20 onClear: PropTypes.func,
18 onEsc: PropTypes.func, 21 onEsc: PropTypes.func,
@@ -54,7 +57,7 @@ const Header = React.createClass({
54 str, 57 str,
55 }); 58 });
56 let value = null; 59 let value = null;
57 const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, onChange, allowEmpty} = this.props; 60 const {formatter, gregorianCalendarLocale, hourOptions, minuteOptions, secondOptions, disabledHours, disabledMinutes, disabledSeconds, onChange, allowEmpty} = this.props;
58 61
59 if (str) { 62 if (str) {
60 const originalValue = this.props.value; 63 const originalValue = this.props.value;
@@ -71,6 +74,7 @@ const Header = React.createClass({
71 } 74 }
72 75
73 if (value) { 76 if (value) {
77 // if time value not allowed, response warning.
74 if ( 78 if (
75 hourOptions.indexOf(value.getHourOfDay()) < 0 || 79 hourOptions.indexOf(value.getHourOfDay()) < 0 ||
76 minuteOptions.indexOf(value.getMinutes()) < 0 || 80 minuteOptions.indexOf(value.getMinutes()) < 0 ||
@@ -82,6 +86,21 @@ const Header = React.createClass({
82 return; 86 return;
83 } 87 }
84 88
89 // if time value is disabled, response warning.
90 const disabledHourOptions = disabledHours();
91 const disabledMinuteOptions = disabledMinutes(value.getHourOfDay());
92 const disabledSecondOptions = disabledSeconds(value.getHourOfDay(), value.getMinutes());
93 if (
94 (disabledHourOptions && disabledHourOptions.indexOf(value.getHourOfDay()) >= 0) ||
95 (disabledMinuteOptions && disabledMinuteOptions.indexOf(value.getMinutes()) >= 0) ||
96 (disabledSecondOptions && disabledSecondOptions.indexOf(value.getSeconds()) >= 0)
97 ) {
98 this.setState({
99 invalid: true,
100 });
101 return;
102 }
103
85 if (originalValue && value) { 104 if (originalValue && value) {
86 if ( 105 if (
87 originalValue.getHourOfDay() !== value.getHourOfDay() || 106 originalValue.getHourOfDay() !== value.getHourOfDay() ||