Skip to content

Commit 4ad7883

Browse files
committed
Completely separate the fork from react-bootstrap-datetimepicker
1 parent c7776a9 commit 4ad7883

File tree

7 files changed

+31
-74
lines changed

7 files changed

+31
-74
lines changed

src/Constants.jsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/DateTimeField.jsx renamed to src/DateTime.jsx

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
'use strict';
22

33
var assign = require('object-assign'),
4-
React = require('react'),
5-
DaysView = require('./DateTimePickerDays'),
6-
MonthsView = require('./DateTimePickerMonths'),
7-
YearsView = require('./DateTimePickerYears'),
8-
TimeView = require('./DateTimePickerTime'),
9-
moment = require('moment'),
10-
Constants = require('./Constants')
4+
React = require('react'),
5+
DaysView = require('./DaysView'),
6+
MonthsView = require('./MonthsView'),
7+
YearsView = require('./YearsView'),
8+
TimeView = require('./TimeView'),
9+
moment = require('moment')
1110
;
1211

13-
var noop = function(){};
12+
var Constants = {
13+
MODE_DATE: 'date',
14+
MODE_DATETIME: 'datetime',
15+
MODE_TIME: 'time'
16+
};
1417

1518
var DateTimeField = React.createClass({
1619
mixins: [
@@ -69,10 +72,6 @@ var DateTimeField = React.createClass({
6972
};
7073
},
7174

72-
getFormat: function( props ){
73-
return this.getFormats( props ).datetime;
74-
},
75-
7675
getFormats: function( props ){
7776
var formats = {
7877
date: '',
@@ -136,7 +135,7 @@ var DateTimeField = React.createClass({
136135
return this.setState({
137136
inputValue: value
138137
}, function() {
139-
return this.props.onChange(moment(this.state.inputValue, this.state.inputFormat, true).format( this.getFormat( this.props )));
138+
return this.props.onChange(moment(this.state.inputValue, this.state.inputFormat, true).format( this.state.inputFormat ));
140139
});
141140
},
142141

@@ -149,10 +148,10 @@ var DateTimeField = React.createClass({
149148

150149
setDate: function( type ){
151150
var me = this,
152-
nextViews = {
153-
month: 'days',
154-
year: 'months'
155-
}
151+
nextViews = {
152+
month: 'days',
153+
year: 'months'
154+
}
156155
;
157156
return function( e ){
158157
me.setState({
@@ -189,16 +188,22 @@ var DateTimeField = React.createClass({
189188
nextType
190189
;
191190

191+
// It is needed to set all the time properties
192+
// to not to reset the time
192193
date[ type ]( value );
193194
for (; index < this.allowedSetTime.length; index++) {
194195
nextType = this.allowedSetTime[index];
195196
date[ nextType ]( date[nextType]() );
196197
}
197-
this.setState({ selectedDate: date, inputValue: date.format( this.state.inputFormat ) }, this.callOnChange );
198+
199+
this.setState({
200+
selectedDate: date,
201+
inputValue: date.format( this.state.inputFormat )
202+
}, this.callOnChange );
198203
},
199204

200205
callOnChange: function(){
201-
this.props.onChange(this.state.selectedDate.format( this.getFormat( this.props )));
206+
this.props.onChange(this.state.selectedDate.format( this.state.inputFormat ));
202207
},
203208

204209
updateDate: function( e ) {
File renamed without changes.
File renamed without changes.

src/DateTimePickerTime.jsx renamed to src/TimeView.jsx

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
var DateTimePickerHours, React;
1+
'use strict';
22

3-
React = require('react');
3+
var React = require('react');
44

5-
var Constants = require('./Constants');
6-
7-
DateTimePickerTime = React.createClass({
5+
var DateTimePickerTime = React.createClass({
86
getInitialState: function(){
97
var date = this.props.selectedDate,
108
format = this.props.timeFormat,
@@ -64,47 +62,6 @@ DateTimePickerTime = React.createClass({
6462
</div>
6563
</div>
6664
);
67-
68-
return (
69-
<div className="timepicker">
70-
<div className="timepicker-picker">
71-
<table className="table-condensed">
72-
{ this.renderHeader() }
73-
<tbody>
74-
<tr>
75-
<td><a className="btn" onClick={this.props.addTime(1, 'hours', true)}>&#x25B2;</a></td>
76-
77-
<td className="separator"></td>
78-
79-
<td><a className="btn" onClick={this.props.addTime(1, 'minutes', true)}>&#x25B2;</a></td>
80-
81-
<td className="separator"></td>
82-
</tr>
83-
84-
<tr>
85-
<td><span className="timepicker-hour">{this.props.selectedDate.format('H')}</span></td>
86-
87-
<td className="separator">:</td>
88-
89-
<td><span className="timepicker-minute">{this.props.selectedDate.format('mm')}</span></td>
90-
91-
<td className="separator"></td>
92-
</tr>
93-
94-
<tr>
95-
<td><a className="btn" onClick={this.props.subtractTime( 1, 'hours', true )}>&#x25BC;</a></td>
96-
97-
<td className="separator"></td>
98-
99-
<td><a className="btn" onClick={this.props.subtractTime( 1, 'minutes', true )}>&#x25BC;</a></td>
100-
101-
<td className="separator"></td>
102-
</tr>
103-
</tbody>
104-
</table>
105-
</div>
106-
</div>
107-
);
10865
},
10966
renderHeader: function(){
11067
if( !this.props.dateFormat )
@@ -148,17 +105,17 @@ DateTimePickerTime = React.createClass({
148105
padValues: {
149106
hours: 1,
150107
minutes: 2,
151-
minutes: 2,
108+
seconds: 2,
152109
milliseconds: 3
153110
},
154111
increase: function( type ){
155-
value = parseInt(this.state[ type ]) + 1;
112+
var value = parseInt(this.state[ type ]) + 1;
156113
if( value > this.maxValues[ type ] )
157114
value = 0;
158115
return this.pad( type, value );
159116
},
160117
decrease: function( type ){
161-
value = parseInt(this.state[ type ]) - 1;
118+
var value = parseInt(this.state[ type ]) - 1;
162119
if( value < 0 )
163120
value = this.maxValues[ type ];
164121
return this.pad( type, value );
File renamed without changes.

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (process.env.COMPRESS) {
1818

1919
module.exports = {
2020

21-
entry: ['./src/DateTimeField.jsx'],
21+
entry: ['./src/DateTime.jsx'],
2222

2323
output: {
2424
path: __dirname + "/dist/",

0 commit comments

Comments
 (0)