Skip to content

Commit

Permalink
make time-picker support custom wordings like date-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
feit committed Jan 25, 2016
1 parent 0e58efb commit 9d57710
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/time-picker/time-picker-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const TimePickerDialog = React.createClass({
onAccept: React.PropTypes.func,
onDismiss: React.PropTypes.func,
onShow: React.PropTypes.func,
wordings: React.PropTypes.object,
},

contextTypes: {
Expand All @@ -30,6 +31,15 @@ const TimePickerDialog = React.createClass({

mixins: [StylePropable, WindowListenable],

getDefaultProps() {
return {
wordings: {
ok: 'OK',
cancel: 'Cancel',
},
};
},

getInitialState() {
return {
open: false,
Expand Down Expand Up @@ -95,6 +105,7 @@ const TimePickerDialog = React.createClass({
onAccept,
format,
autoOk,
wordings,
...other,
} = this.props;

Expand All @@ -114,18 +125,23 @@ const TimePickerDialog = React.createClass({
let actions = [
<FlatButton
key={0}
label="Cancel"
label={wordings.cancel}
secondary={true}
onTouchTap={this.dismiss}
/>,
<FlatButton
key={1}
label="OK"
secondary={true}
onTouchTap={this._handleOKTouchTap}
/>,
];

if (!autoOk) {
actions.push(
<FlatButton
key={1}
label={wordings.ok}
secondary={true}
onTouchTap={this._handleOKTouchTap}
/>
);
}

const onClockChangeMinutes = (autoOk === true ? this._handleOKTouchTap : undefined);

return (
Expand Down
7 changes: 7 additions & 0 deletions src/time-picker/time-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const TimePicker = React.createClass({
* Override the inline-styles of TimePicker's TextField element.
*/
textFieldStyle: React.PropTypes.object,

/**
* Wordings used inside the button of the dialog.
*/
wordings: React.PropTypes.object,
},

contextTypes: {
Expand Down Expand Up @@ -189,6 +194,7 @@ const TimePicker = React.createClass({
onShow,
onDismiss,
style,
wordings,
textFieldStyle,
...other,
} = this.props;
Expand All @@ -212,6 +218,7 @@ const TimePicker = React.createClass({
onShow={onShow}
onDismiss={onDismiss}
format={format}
wordings={wordings}
autoOk={autoOk}
/>
</div>
Expand Down

0 comments on commit 9d57710

Please sign in to comment.