Skip to content

Commit

Permalink
Completely separate the fork from react-bootstrap-datetimepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
arqex committed Jun 19, 2015
1 parent c7776a9 commit 4ad7883
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 74 deletions.
5 changes: 0 additions & 5 deletions src/Constants.jsx

This file was deleted.

43 changes: 24 additions & 19 deletions src/DateTimeField.jsx → src/DateTime.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
'use strict';

var assign = require('object-assign'),
React = require('react'),
DaysView = require('./DateTimePickerDays'),
MonthsView = require('./DateTimePickerMonths'),
YearsView = require('./DateTimePickerYears'),
TimeView = require('./DateTimePickerTime'),
moment = require('moment'),
Constants = require('./Constants')
React = require('react'),
DaysView = require('./DaysView'),
MonthsView = require('./MonthsView'),
YearsView = require('./YearsView'),
TimeView = require('./TimeView'),
moment = require('moment')
;

var noop = function(){};
var Constants = {
MODE_DATE: 'date',
MODE_DATETIME: 'datetime',
MODE_TIME: 'time'
};

var DateTimeField = React.createClass({
mixins: [
Expand Down Expand Up @@ -69,10 +72,6 @@ var DateTimeField = React.createClass({
};
},

getFormat: function( props ){
return this.getFormats( props ).datetime;
},

getFormats: function( props ){
var formats = {
date: '',
Expand Down Expand Up @@ -136,7 +135,7 @@ var DateTimeField = React.createClass({
return this.setState({
inputValue: value
}, function() {
return this.props.onChange(moment(this.state.inputValue, this.state.inputFormat, true).format( this.getFormat( this.props )));
return this.props.onChange(moment(this.state.inputValue, this.state.inputFormat, true).format( this.state.inputFormat ));
});
},

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

setDate: function( type ){
var me = this,
nextViews = {
month: 'days',
year: 'months'
}
nextViews = {
month: 'days',
year: 'months'
}
;
return function( e ){
me.setState({
Expand Down Expand Up @@ -189,16 +188,22 @@ var DateTimeField = React.createClass({
nextType
;

// It is needed to set all the time properties
// to not to reset the time
date[ type ]( value );
for (; index < this.allowedSetTime.length; index++) {
nextType = this.allowedSetTime[index];
date[ nextType ]( date[nextType]() );
}
this.setState({ selectedDate: date, inputValue: date.format( this.state.inputFormat ) }, this.callOnChange );

this.setState({
selectedDate: date,
inputValue: date.format( this.state.inputFormat )
}, this.callOnChange );
},

callOnChange: function(){
this.props.onChange(this.state.selectedDate.format( this.getFormat( this.props )));
this.props.onChange(this.state.selectedDate.format( this.state.inputFormat ));
},

updateDate: function( e ) {
Expand Down
File renamed without changes.
File renamed without changes.
55 changes: 6 additions & 49 deletions src/DateTimePickerTime.jsx → src/TimeView.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var DateTimePickerHours, React;
'use strict';

React = require('react');
var React = require('react');

var Constants = require('./Constants');

DateTimePickerTime = React.createClass({
var DateTimePickerTime = React.createClass({
getInitialState: function(){
var date = this.props.selectedDate,
format = this.props.timeFormat,
Expand Down Expand Up @@ -64,47 +62,6 @@ DateTimePickerTime = React.createClass({
</div>
</div>
);

return (
<div className="timepicker">
<div className="timepicker-picker">
<table className="table-condensed">
{ this.renderHeader() }
<tbody>
<tr>
<td><a className="btn" onClick={this.props.addTime(1, 'hours', true)}>&#x25B2;</a></td>

<td className="separator"></td>

<td><a className="btn" onClick={this.props.addTime(1, 'minutes', true)}>&#x25B2;</a></td>

<td className="separator"></td>
</tr>

<tr>
<td><span className="timepicker-hour">{this.props.selectedDate.format('H')}</span></td>

<td className="separator">:</td>

<td><span className="timepicker-minute">{this.props.selectedDate.format('mm')}</span></td>

<td className="separator"></td>
</tr>

<tr>
<td><a className="btn" onClick={this.props.subtractTime( 1, 'hours', true )}>&#x25BC;</a></td>

<td className="separator"></td>

<td><a className="btn" onClick={this.props.subtractTime( 1, 'minutes', true )}>&#x25BC;</a></td>

<td className="separator"></td>
</tr>
</tbody>
</table>
</div>
</div>
);
},
renderHeader: function(){
if( !this.props.dateFormat )
Expand Down Expand Up @@ -148,17 +105,17 @@ DateTimePickerTime = React.createClass({
padValues: {
hours: 1,
minutes: 2,
minutes: 2,
seconds: 2,
milliseconds: 3
},
increase: function( type ){
value = parseInt(this.state[ type ]) + 1;
var value = parseInt(this.state[ type ]) + 1;
if( value > this.maxValues[ type ] )
value = 0;
return this.pad( type, value );
},
decrease: function( type ){
value = parseInt(this.state[ type ]) - 1;
var value = parseInt(this.state[ type ]) - 1;
if( value < 0 )
value = this.maxValues[ type ];
return this.pad( type, value );
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (process.env.COMPRESS) {

module.exports = {

entry: ['./src/DateTimeField.jsx'],
entry: ['./src/DateTime.jsx'],

output: {
path: __dirname + "/dist/",
Expand Down

0 comments on commit 4ad7883

Please sign in to comment.