This repository was archived by the owner on Aug 27, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 18 files changed +984
-227
lines changed
imports/materialdesign/components Expand file tree Collapse file tree 18 files changed +984
-227
lines changed Original file line number Diff line number Diff line change @@ -140,15 +140,16 @@ export default class TextField extends Component {
140140 /**
141141 * Toggles on input.
142142 * @param {Boolean }
143+ * @param {Boolean } focus
143144 */
144- toggle ( flag ) {
145+ toggle ( flag , focus = true ) {
145146 const root = this . getRoot ( )
146147 const input = this . getInput ( )
147148
148149 root . classList . remove ( ( flag ) ? 'disabled' : 'enabled' )
149150 root . classList . add ( ( flag ) ? 'enabled' : 'disabled' )
150151
151- if ( flag ) input . focus ( )
152+ if ( flag && focus ) input . focus ( )
152153 this . toggled = flag
153154 }
154155
@@ -178,8 +179,9 @@ export default class TextField extends Component {
178179 /**
179180 * Sets input value.
180181 * @param {String } value
182+ * @param {Boolean } focus
181183 */
182- setValue ( str ) {
184+ setValue ( str , focus ) {
183185 if ( this . props . textarea === true ) {
184186 this . elements . textarea . value = str
185187 } else {
@@ -189,7 +191,7 @@ export default class TextField extends Component {
189191 this . onInput ( )
190192
191193 if ( str . length >= 1 && ! this . toggled ) {
192- this . toggle ( true )
194+ this . toggle ( true , focus )
193195 } else if ( str . length < 1 && this . toggled ) {
194196 this . toggle ( false )
195197 }
Original file line number Diff line number Diff line change 1+ import Component from '../../../../../../helpers/Component'
2+
3+ import Tick from '../Tick'
4+
5+ export default class HoursClock extends Component {
6+ beforeRender ( ) {
7+ this . ticks = [ ]
8+ this . selectedTick = null
9+
10+ this . isMouseDown = false
11+ }
12+
13+ /**
14+ * Gets root.
15+ * @return {DOMElement } root
16+ */
17+ getRoot ( ) {
18+ return this . elements . root
19+ }
20+
21+ /**
22+ * Sets ticks around clock.
23+ */
24+ setTicks ( ) {
25+ const timePicker = this . props . getTimePicker ( )
26+ const ticksContainer = this . elements . ticksContainer
27+
28+ const positions = timePicker . calculateTickPosition ( )
29+
30+ for ( var i = 0 ; i < positions . length ; i ++ ) {
31+ let number = i + 3
32+ if ( number > 12 ) number -= 12
33+
34+ const tick = (
35+ < Tick left = { positions [ i ] . x } top = { positions [ i ] . y } number = { number } getClock = { ( ) => { return this } } getTimePicker = { ( ) => { return this . props . getTimePicker ( ) } } />
36+ )
37+
38+ this . renderComponents ( tick , ticksContainer )
39+ }
40+ }
41+
42+ /**
43+ * Gets line rotate value.
44+ * @param {Int } minutes
45+ * @return {Int } rotate
46+ */
47+ getRotate ( number ) {
48+ return number * 30 + 180
49+ }
50+
51+ render ( ) {
52+ return (
53+ < div className = 'hours-clock' ref = 'root' >
54+ < div className = 'line' ref = 'line' />
55+ < div className = 'ticks-container' ref = 'ticksContainer' />
56+ </ div >
57+ )
58+ }
59+
60+ afterRender ( ) {
61+ this . setTicks ( )
62+ }
63+ }
Original file line number Diff line number Diff line change 1+ import Component from '../../../../../../helpers/Component'
2+
3+ import Tick from '../Tick'
4+
5+ export default class MinutesClock extends Component {
6+ beforeRender ( ) {
7+ this . ticks = [ ]
8+ this . selectedTick = null
9+
10+ this . isMouseDown = false
11+ }
12+
13+ /**
14+ * Gets root.
15+ * @return {DOMElement } root
16+ */
17+ getRoot ( ) {
18+ return this . elements . root
19+ }
20+
21+ /**
22+ * Sets ticks around clock.
23+ * Yes. I know it. There is only five minutes. I'll fix this later.
24+ */
25+ setTicks ( ) {
26+ const timePicker = this . props . getTimePicker ( )
27+ const ticksContainer = this . elements . ticksContainer
28+
29+ const positions = timePicker . calculateTickPosition ( )
30+
31+ let minutes = 10
32+
33+ for ( var i = 0 ; i < positions . length ; i ++ ) {
34+ minutes += 5
35+ if ( minutes >= 60 ) minutes -= 60
36+ const _minutes = ( minutes < 10 ) ? ( '0' + minutes ) : minutes
37+
38+ const tick = (
39+ < Tick left = { positions [ i ] . x } top = { positions [ i ] . y } number = { _minutes } getClock = { ( ) => { return this } } getTimePicker = { ( ) => { return this . props . getTimePicker ( ) } } />
40+ )
41+
42+ this . renderComponents ( tick , ticksContainer )
43+ }
44+
45+ setTimeout ( function ( ) {
46+ timePicker . updateHour ( )
47+ } , 10 )
48+ }
49+
50+ /**
51+ * Gets line rotate value.
52+ * @param {Int } minutes
53+ * @return {Int } rotate
54+ */
55+ getRotate ( number ) {
56+ return number * 6 + 180
57+ }
58+
59+ render ( ) {
60+ return (
61+ < div className = 'minutes-clock' ref = 'root' >
62+ < div className = 'line' ref = 'line' />
63+ < div className = 'ticks-container' ref = 'ticksContainer' />
64+ </ div >
65+ )
66+ }
67+
68+ afterRender ( ) {
69+ this . setTicks ( )
70+ }
71+ }
Original file line number Diff line number Diff line change 1+ import Component from '../../../../../../helpers/Component'
2+
3+ export default class Tick extends Component {
4+ beforeRender ( ) {
5+ this . toggled = false
6+ }
7+
8+ /**
9+ * Gets root.
10+ * @return {DOMElement } root
11+ */
12+ getRoot ( ) {
13+ return this . elements . root
14+ }
15+
16+ /**
17+ * On mouse down.
18+ * Enables ticks selecting.
19+ * @param {Event }
20+ */
21+ onMouseDown = ( e ) => {
22+ const timePicker = this . props . getTimePicker ( )
23+
24+ timePicker . enableSelecting ( )
25+ if ( ! this . isSelected ( ) ) timePicker . selectTick ( this )
26+ }
27+
28+ /**
29+ * On mouse enter.
30+ * Selects touched tick.
31+ * @param {Event }
32+ */
33+ onMouseEnter = ( e ) => {
34+ const clock = this . props . getClock ( )
35+ const timePicker = this . props . getTimePicker ( )
36+
37+ if ( clock . isMouseDown && ! this . isSelected ( ) ) timePicker . selectTick ( this )
38+ }
39+
40+ isSelected ( ) {
41+ return ( this . props . getClock ( ) . selectedTick === this )
42+ }
43+
44+ render ( ) {
45+ return (
46+ < div className = 'tick' ref = 'root' onMouseDown = { this . onMouseDown } onMouseEnter = { this . onMouseEnter } >
47+ < div className = 'number' ref = 'number' />
48+ </ div >
49+ )
50+ }
51+
52+ afterRender ( ) {
53+ const props = this . props
54+ const root = this . getRoot ( )
55+
56+ const clock = props . getClock ( )
57+
58+ root . style . top = props . top + 'px'
59+ root . style . left = props . left + 'px'
60+
61+ this . elements . number . innerHTML = props . number
62+
63+ clock . ticks . push ( this )
64+
65+ if ( props . number === 6 || props . number === 30 ) {
66+ root . classList . add ( 'selected' )
67+ clock . selectedTick = this
68+ }
69+ }
70+ }
You can’t perform that action at this time.
0 commit comments