From 3bf154e1b0ae57b5d443757f7be17e64fc648d68 Mon Sep 17 00:00:00 2001 From: David Furlong <dvfurlong@googlemail.com> Date: Tue, 30 Aug 2016 17:22:54 +0200 Subject: [PATCH] Add AM/PM Arrows to toggle between states (#124) --- src/TimeView.js | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/src/TimeView.js b/src/TimeView.js index 4ba6324..c6ecee1 100644 --- a/src/TimeView.js +++ b/src/TimeView.js @@ -57,6 +57,13 @@ } return ''; }, + renderDayPart: function() { + return DOM.div({ className: 'rdtCounter'}, [ + DOM.span({ key:'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '���' ), + DOM.div({ key: this.state.daypart, className: 'rdtCount'}, this.state.daypart ), + DOM.span({ key:'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '���' ) + ]); + }, render: function() { var me = this, counters = [] @@ -69,7 +76,7 @@ }); if (this.state.daypart !== false) { - counters.push(DOM.div({ key: this.state.daypart, className: 'rdtDayPart'}, this.state.daypart )); + counters.push( me.renderDayPart() ); } if ( this.state.counters.length === 3 && this.props.timeFormat.indexOf('S') !== -1 ){ @@ -168,6 +175,12 @@ seconds: 2, milliseconds: 3 }, + toggleDayPart: function( type ){ // type is always 'hours' + var value = parseInt(this.state[ type ], 10) + 12; + if ( value > this.timeConstraints[ type ].max ) + value = this.timeConstraints[ type ].min + (value - (this.timeConstraints[ type ].max + 1)); + return this.pad( type, value ); + }, increase: function( type ){ var value = parseInt(this.state[ type ], 10) + this.timeConstraints[ type ].step; if ( value > this.timeConstraints[ type ].max ) -- Gitblit v1.9.3