Completely separate the fork from react-bootstrap-datetimepicker
1 files deleted
1 files modified
5 files renamed
File was renamed from src/DateTimeField.jsx |
| | |
| | | '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: [ |
| | |
| | | selectedDate: moment(date), |
| | | inputValue: typeof this.props.defaultText != 'undefined' ? this.props.defaultText : moment(date).format( formats.datetime ) |
| | | }; |
| | | }, |
| | | |
| | | getFormat: function( props ){ |
| | | return this.getFormats( props ).datetime; |
| | | }, |
| | | |
| | | getFormats: function( props ){ |
| | |
| | | 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 )); |
| | | }); |
| | | }, |
| | | |
| | |
| | | |
| | | setDate: function( type ){ |
| | | var me = this, |
| | | nextViews = { |
| | | month: 'days', |
| | | year: 'months' |
| | | } |
| | | nextViews = { |
| | | month: 'days', |
| | | year: 'months' |
| | | } |
| | | ; |
| | | return function( e ){ |
| | | me.setState({ |
| | |
| | | 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 ) { |
File was renamed from src/DateTimePickerTime.jsx |
| | |
| | | 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, |
| | |
| | | </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)}>▲</a></td> |
| | | |
| | | <td className="separator"></td> |
| | | |
| | | <td><a className="btn" onClick={this.props.addTime(1, 'minutes', true)}>▲</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 )}>▼</a></td> |
| | | |
| | | <td className="separator"></td> |
| | | |
| | | <td><a className="btn" onClick={this.props.subtractTime( 1, 'minutes', true )}>▼</a></td> |
| | | |
| | | <td className="separator"></td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | </div> |
| | | </div> |
| | | ); |
| | | }, |
| | | renderHeader: function(){ |
| | | if( !this.props.dateFormat ) |
| | |
| | | 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 ); |
| | |
| | | |
| | | module.exports = { |
| | | |
| | | entry: ['./src/DateTimeField.jsx'], |
| | | entry: ['./src/DateTime.jsx'], |
| | | |
| | | output: { |
| | | path: __dirname + "/dist/", |