commit | author | age
|
d76f7b
|
1 |
/* |
be9654
|
2 |
react-datetime v2.8.5 |
SE |
3 |
https://github.com/YouCanBookMe/react-datetime |
|
4 |
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE |
d76f7b
|
5 |
*/ |
M |
6 |
(function webpackUniversalModuleDefinition(root, factory) { |
|
7 |
if(typeof exports === 'object' && typeof module === 'object') |
c5aa9b
|
8 |
module.exports = factory(require("moment"), require("React"), require("ReactDOM")); |
d76f7b
|
9 |
else if(typeof define === 'function' && define.amd) |
c5aa9b
|
10 |
define(["moment", "React", "ReactDOM"], factory); |
d76f7b
|
11 |
else if(typeof exports === 'object') |
c5aa9b
|
12 |
exports["Datetime"] = factory(require("moment"), require("React"), require("ReactDOM")); |
d76f7b
|
13 |
else |
c5aa9b
|
14 |
root["Datetime"] = factory(root["moment"], root["React"], root["ReactDOM"]); |
SE |
15 |
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_9__) { |
d76f7b
|
16 |
return /******/ (function(modules) { // webpackBootstrap |
M |
17 |
/******/ // The module cache |
|
18 |
/******/ var installedModules = {}; |
|
19 |
|
|
20 |
/******/ // The require function |
|
21 |
/******/ function __webpack_require__(moduleId) { |
|
22 |
|
|
23 |
/******/ // Check if module is in cache |
|
24 |
/******/ if(installedModules[moduleId]) |
|
25 |
/******/ return installedModules[moduleId].exports; |
|
26 |
|
|
27 |
/******/ // Create a new module (and put it into the cache) |
|
28 |
/******/ var module = installedModules[moduleId] = { |
|
29 |
/******/ exports: {}, |
|
30 |
/******/ id: moduleId, |
|
31 |
/******/ loaded: false |
|
32 |
/******/ }; |
|
33 |
|
|
34 |
/******/ // Execute the module function |
|
35 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
36 |
|
|
37 |
/******/ // Flag the module as loaded |
|
38 |
/******/ module.loaded = true; |
|
39 |
|
|
40 |
/******/ // Return the exports of the module |
|
41 |
/******/ return module.exports; |
|
42 |
/******/ } |
|
43 |
|
|
44 |
|
|
45 |
/******/ // expose the modules object (__webpack_modules__) |
|
46 |
/******/ __webpack_require__.m = modules; |
|
47 |
|
|
48 |
/******/ // expose the module cache |
|
49 |
/******/ __webpack_require__.c = installedModules; |
|
50 |
|
|
51 |
/******/ // __webpack_public_path__ |
|
52 |
/******/ __webpack_require__.p = ""; |
|
53 |
|
|
54 |
/******/ // Load entry module and return exports |
|
55 |
/******/ return __webpack_require__(0); |
|
56 |
/******/ }) |
|
57 |
/************************************************************************/ |
|
58 |
/******/ ([ |
|
59 |
/* 0 */ |
|
60 |
/***/ function(module, exports, __webpack_require__) { |
|
61 |
|
be9654
|
62 |
'use strict'; |
SE |
63 |
|
|
64 |
var assign = __webpack_require__(1), |
|
65 |
moment = __webpack_require__(2), |
|
66 |
React = __webpack_require__(3), |
|
67 |
DaysView = __webpack_require__(4), |
|
68 |
MonthsView = __webpack_require__(5), |
|
69 |
YearsView = __webpack_require__(6), |
|
70 |
TimeView = __webpack_require__(7) |
|
71 |
; |
|
72 |
|
|
73 |
var TYPES = React.PropTypes; |
|
74 |
var Datetime = React.createClass({ |
|
75 |
mixins: [ |
|
76 |
__webpack_require__(8) |
|
77 |
], |
|
78 |
viewComponents: { |
|
79 |
days: DaysView, |
|
80 |
months: MonthsView, |
|
81 |
years: YearsView, |
|
82 |
time: TimeView |
|
83 |
}, |
|
84 |
propTypes: { |
|
85 |
// value: TYPES.object | TYPES.string, |
|
86 |
// defaultValue: TYPES.object | TYPES.string, |
|
87 |
onFocus: TYPES.func, |
|
88 |
onBlur: TYPES.func, |
|
89 |
onChange: TYPES.func, |
|
90 |
locale: TYPES.string, |
|
91 |
utc: TYPES.bool, |
|
92 |
input: TYPES.bool, |
|
93 |
// dateFormat: TYPES.string | TYPES.bool, |
|
94 |
// timeFormat: TYPES.string | TYPES.bool, |
|
95 |
inputProps: TYPES.object, |
|
96 |
timeConstraints: TYPES.object, |
|
97 |
viewMode: TYPES.oneOf(['years', 'months', 'days', 'time']), |
|
98 |
isValidDate: TYPES.func, |
|
99 |
open: TYPES.bool, |
|
100 |
strictParsing: TYPES.bool, |
|
101 |
closeOnSelect: TYPES.bool, |
|
102 |
closeOnTab: TYPES.bool |
|
103 |
}, |
|
104 |
|
|
105 |
getDefaultProps: function() { |
|
106 |
var nof = function() {}; |
|
107 |
return { |
|
108 |
className: '', |
|
109 |
defaultValue: '', |
|
110 |
inputProps: {}, |
|
111 |
input: true, |
|
112 |
onFocus: nof, |
|
113 |
onBlur: nof, |
|
114 |
onChange: nof, |
|
115 |
timeFormat: true, |
|
116 |
timeConstraints: {}, |
|
117 |
dateFormat: true, |
|
118 |
strictParsing: true, |
|
119 |
closeOnSelect: false, |
|
120 |
closeOnTab: true, |
|
121 |
utc: false |
|
122 |
}; |
|
123 |
}, |
|
124 |
|
|
125 |
getInitialState: function() { |
|
126 |
var state = this.getStateFromProps( this.props ); |
|
127 |
|
|
128 |
if ( state.open === undefined ) |
|
129 |
state.open = !this.props.input; |
|
130 |
|
|
131 |
state.currentView = this.props.dateFormat ? (this.props.viewMode || state.updateOn || 'days') : 'time'; |
|
132 |
|
|
133 |
return state; |
|
134 |
}, |
|
135 |
|
|
136 |
getStateFromProps: function( props ) { |
|
137 |
var formats = this.getFormats( props ), |
|
138 |
date = props.value || props.defaultValue, |
|
139 |
selectedDate, viewDate, updateOn, inputValue |
|
140 |
; |
|
141 |
|
|
142 |
if ( date && typeof date === 'string' ) |
|
143 |
selectedDate = this.localMoment( date, formats.datetime ); |
|
144 |
else if ( date ) |
|
145 |
selectedDate = this.localMoment( date ); |
|
146 |
|
|
147 |
if ( selectedDate && !selectedDate.isValid() ) |
|
148 |
selectedDate = null; |
|
149 |
|
|
150 |
viewDate = selectedDate ? |
|
151 |
selectedDate.clone().startOf('month') : |
|
152 |
this.localMoment().startOf('month') |
|
153 |
; |
|
154 |
|
|
155 |
updateOn = this.getUpdateOn(formats); |
|
156 |
|
|
157 |
if ( selectedDate ) |
|
158 |
inputValue = selectedDate.format(formats.datetime); |
|
159 |
else if ( date.isValid && !date.isValid() ) |
|
160 |
inputValue = ''; |
|
161 |
else |
|
162 |
inputValue = date || ''; |
|
163 |
|
|
164 |
return { |
|
165 |
updateOn: updateOn, |
|
166 |
inputFormat: formats.datetime, |
|
167 |
viewDate: viewDate, |
|
168 |
selectedDate: selectedDate, |
|
169 |
inputValue: inputValue, |
|
170 |
open: props.open |
|
171 |
}; |
|
172 |
}, |
|
173 |
|
|
174 |
getUpdateOn: function( formats ) { |
|
175 |
if ( formats.date.match(/[lLD]/) ) { |
|
176 |
return 'days'; |
|
177 |
} |
|
178 |
else if ( formats.date.indexOf('M') !== -1 ) { |
|
179 |
return 'months'; |
|
180 |
} |
|
181 |
else if ( formats.date.indexOf('Y') !== -1 ) { |
|
182 |
return 'years'; |
|
183 |
} |
|
184 |
|
|
185 |
return 'days'; |
|
186 |
}, |
|
187 |
|
|
188 |
getFormats: function( props ) { |
|
189 |
var formats = { |
|
190 |
date: props.dateFormat || '', |
|
191 |
time: props.timeFormat || '' |
|
192 |
}, |
|
193 |
locale = this.localMoment( props.date, null, props ).localeData() |
|
194 |
; |
|
195 |
|
|
196 |
if ( formats.date === true ) { |
|
197 |
formats.date = locale.longDateFormat('L'); |
|
198 |
} |
|
199 |
else if ( this.getUpdateOn(formats) !== 'days' ) { |
|
200 |
formats.time = ''; |
|
201 |
} |
|
202 |
|
|
203 |
if ( formats.time === true ) { |
|
204 |
formats.time = locale.longDateFormat('LT'); |
|
205 |
} |
|
206 |
|
|
207 |
formats.datetime = formats.date && formats.time ? |
|
208 |
formats.date + ' ' + formats.time : |
|
209 |
formats.date || formats.time |
|
210 |
; |
|
211 |
|
|
212 |
return formats; |
|
213 |
}, |
|
214 |
|
|
215 |
componentWillReceiveProps: function( nextProps ) { |
|
216 |
var formats = this.getFormats( nextProps ), |
|
217 |
updatedState = {} |
|
218 |
; |
|
219 |
|
|
220 |
if ( nextProps.value !== this.props.value || |
|
221 |
formats.datetime !== this.getFormats( this.props ).datetime ) { |
|
222 |
updatedState = this.getStateFromProps( nextProps ); |
|
223 |
} |
|
224 |
|
|
225 |
// What is this for? Keeping for now, will remove later |
|
226 |
if ( updatedState.open === undefined ) { |
|
227 |
updatedState.open = this.state.open; |
|
228 |
} |
|
229 |
|
|
230 |
if ( this.props.closeOnSelect === false ) { |
|
231 |
updatedState.open = true; |
|
232 |
} |
|
233 |
|
|
234 |
if ( nextProps.viewMode !== this.props.viewMode ) { |
|
235 |
updatedState.currentView = nextProps.viewMode; |
|
236 |
} |
|
237 |
|
|
238 |
if ( nextProps.locale !== this.props.locale ) { |
|
239 |
if ( this.state.viewDate ) { |
|
240 |
var updatedViewDate = this.state.viewDate.clone().locale( nextProps.locale ); |
|
241 |
updatedState.viewDate = updatedViewDate; |
|
242 |
} |
|
243 |
if ( this.state.selectedDate ) { |
|
244 |
var updatedSelectedDate = this.state.selectedDate.clone().locale( nextProps.locale ); |
|
245 |
updatedState.selectedDate = updatedSelectedDate; |
|
246 |
updatedState.inputValue = updatedSelectedDate.format( formats.datetime ); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
if ( nextProps.utc !== this.props.utc ) { |
|
251 |
if ( nextProps.utc ) { |
|
252 |
if ( this.state.viewDate ) |
|
253 |
updatedState.viewDate = this.state.viewDate.clone().utc(); |
|
254 |
if ( this.state.selectedDate ) { |
|
255 |
updatedState.selectedDate = this.state.selectedDate.clone().utc(); |
|
256 |
updatedState.inputValue = updatedState.selectedDate.format( formats.datetime ); |
|
257 |
} |
|
258 |
} else { |
|
259 |
if ( this.state.viewDate ) |
|
260 |
updatedState.viewDate = this.state.viewDate.clone().local(); |
|
261 |
if ( this.state.selectedDate ) { |
|
262 |
updatedState.selectedDate = this.state.selectedDate.clone().local(); |
|
263 |
updatedState.inputValue = updatedState.selectedDate.format(formats.datetime); |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
|
|
268 |
this.setState( updatedState ); |
|
269 |
}, |
|
270 |
|
|
271 |
onInputChange: function( e ) { |
|
272 |
var value = e.target === null ? e : e.target.value, |
|
273 |
localMoment = this.localMoment( value, this.state.inputFormat ), |
|
274 |
update = { inputValue: value } |
|
275 |
; |
|
276 |
|
|
277 |
if ( localMoment.isValid() && !this.props.value ) { |
|
278 |
update.selectedDate = localMoment; |
|
279 |
update.viewDate = localMoment.clone().startOf('month'); |
|
280 |
} |
|
281 |
else { |
|
282 |
update.selectedDate = null; |
|
283 |
} |
|
284 |
|
|
285 |
return this.setState( update, function() { |
|
286 |
return this.props.onChange( localMoment.isValid() ? localMoment : this.state.inputValue ); |
|
287 |
}); |
|
288 |
}, |
|
289 |
|
|
290 |
onInputKey: function( e ) { |
|
291 |
if ( e.which === 9 && this.props.closeOnTab ) { |
|
292 |
this.closeCalendar(); |
|
293 |
} |
|
294 |
}, |
|
295 |
|
|
296 |
showView: function( view ) { |
|
297 |
var me = this; |
|
298 |
return function() { |
|
299 |
me.setState({ currentView: view }); |
|
300 |
}; |
|
301 |
}, |
|
302 |
|
|
303 |
setDate: function( type ) { |
|
304 |
var me = this, |
|
305 |
nextViews = { |
|
306 |
month: 'days', |
|
307 |
year: 'months' |
|
308 |
} |
|
309 |
; |
|
310 |
return function( e ) { |
|
311 |
me.setState({ |
|
312 |
viewDate: me.state.viewDate.clone()[ type ]( parseInt(e.target.getAttribute('data-value'), 10) ).startOf( type ), |
|
313 |
currentView: nextViews[ type ] |
|
314 |
}); |
|
315 |
}; |
|
316 |
}, |
|
317 |
|
|
318 |
addTime: function( amount, type, toSelected ) { |
|
319 |
return this.updateTime( 'add', amount, type, toSelected ); |
|
320 |
}, |
|
321 |
|
|
322 |
subtractTime: function( amount, type, toSelected ) { |
|
323 |
return this.updateTime( 'subtract', amount, type, toSelected ); |
|
324 |
}, |
|
325 |
|
|
326 |
updateTime: function( op, amount, type, toSelected ) { |
|
327 |
var me = this; |
|
328 |
|
|
329 |
return function() { |
|
330 |
var update = {}, |
|
331 |
date = toSelected ? 'selectedDate' : 'viewDate' |
|
332 |
; |
|
333 |
|
|
334 |
update[ date ] = me.state[ date ].clone()[ op ]( amount, type ); |
|
335 |
|
|
336 |
me.setState( update ); |
|
337 |
}; |
|
338 |
}, |
|
339 |
|
|
340 |
allowedSetTime: ['hours', 'minutes', 'seconds', 'milliseconds'], |
|
341 |
setTime: function( type, value ) { |
|
342 |
var index = this.allowedSetTime.indexOf( type ) + 1, |
|
343 |
state = this.state, |
|
344 |
date = (state.selectedDate || state.viewDate).clone(), |
|
345 |
nextType |
|
346 |
; |
|
347 |
|
|
348 |
// It is needed to set all the time properties |
|
349 |
// to not to reset the time |
|
350 |
date[ type ]( value ); |
|
351 |
for (; index < this.allowedSetTime.length; index++) { |
|
352 |
nextType = this.allowedSetTime[index]; |
|
353 |
date[ nextType ]( date[nextType]() ); |
|
354 |
} |
|
355 |
|
|
356 |
if ( !this.props.value ) { |
|
357 |
this.setState({ |
|
358 |
selectedDate: date, |
|
359 |
inputValue: date.format( state.inputFormat ) |
|
360 |
}); |
|
361 |
} |
|
362 |
this.props.onChange( date ); |
|
363 |
}, |
|
364 |
|
|
365 |
updateSelectedDate: function( e, close ) { |
|
366 |
var target = e.target, |
|
367 |
modifier = 0, |
|
368 |
viewDate = this.state.viewDate, |
|
369 |
currentDate = this.state.selectedDate || viewDate, |
|
370 |
date |
|
371 |
; |
|
372 |
|
|
373 |
if (target.className.indexOf('rdtDay') !== -1) { |
|
374 |
if (target.className.indexOf('rdtNew') !== -1) |
|
375 |
modifier = 1; |
|
376 |
else if (target.className.indexOf('rdtOld') !== -1) |
|
377 |
modifier = -1; |
|
378 |
|
|
379 |
date = viewDate.clone() |
|
380 |
.month( viewDate.month() + modifier ) |
|
381 |
.date( parseInt( target.getAttribute('data-value'), 10 ) ); |
|
382 |
} else if (target.className.indexOf('rdtMonth') !== -1) { |
|
383 |
date = viewDate.clone() |
|
384 |
.month( parseInt( target.getAttribute('data-value'), 10 ) ) |
|
385 |
.date( currentDate.date() ); |
|
386 |
} else if (target.className.indexOf('rdtYear') !== -1) { |
|
387 |
date = viewDate.clone() |
|
388 |
.month( currentDate.month() ) |
|
389 |
.date( currentDate.date() ) |
|
390 |
.year( parseInt( target.getAttribute('data-value'), 10 ) ); |
|
391 |
} |
|
392 |
|
|
393 |
date.hours( currentDate.hours() ) |
|
394 |
.minutes( currentDate.minutes() ) |
|
395 |
.seconds( currentDate.seconds() ) |
|
396 |
.milliseconds( currentDate.milliseconds() ); |
|
397 |
|
|
398 |
if ( !this.props.value ) { |
|
399 |
this.setState({ |
|
400 |
selectedDate: date, |
|
401 |
viewDate: date.clone().startOf('month'), |
|
402 |
inputValue: date.format( this.state.inputFormat ), |
|
403 |
open: !(this.props.closeOnSelect && close ) |
|
404 |
}); |
|
405 |
} else { |
|
406 |
if (this.props.closeOnSelect && close) { |
|
407 |
this.closeCalendar(); |
|
408 |
} |
|
409 |
} |
|
410 |
|
|
411 |
this.props.onChange( date ); |
|
412 |
}, |
|
413 |
|
|
414 |
openCalendar: function() { |
|
415 |
if (!this.state.open) { |
|
416 |
this.setState({ open: true }, function() { |
|
417 |
this.props.onFocus(); |
|
418 |
}); |
|
419 |
} |
|
420 |
}, |
|
421 |
|
|
422 |
closeCalendar: function() { |
|
423 |
this.setState({ open: false }, function () { |
|
424 |
this.props.onBlur( this.state.selectedDate || this.state.inputValue ); |
|
425 |
}); |
|
426 |
}, |
|
427 |
|
|
428 |
handleClickOutside: function() { |
|
429 |
if ( this.props.input && this.state.open && !this.props.open ) { |
|
430 |
this.setState({ open: false }, function() { |
|
431 |
this.props.onBlur( this.state.selectedDate || this.state.inputValue ); |
|
432 |
}); |
|
433 |
} |
|
434 |
}, |
|
435 |
|
|
436 |
localMoment: function( date, format, props ) { |
|
437 |
props = props || this.props; |
|
438 |
var momentFn = props.utc ? moment.utc : moment; |
|
439 |
var m = momentFn( date, format, props.strictParsing ); |
|
440 |
if ( props.locale ) |
|
441 |
m.locale( props.locale ); |
|
442 |
return m; |
|
443 |
}, |
|
444 |
|
|
445 |
componentProps: { |
|
446 |
fromProps: ['value', 'isValidDate', 'renderDay', 'renderMonth', 'renderYear', 'timeConstraints'], |
|
447 |
fromState: ['viewDate', 'selectedDate', 'updateOn'], |
|
448 |
fromThis: ['setDate', 'setTime', 'showView', 'addTime', 'subtractTime', 'updateSelectedDate', 'localMoment'] |
|
449 |
}, |
|
450 |
|
|
451 |
getComponentProps: function() { |
|
452 |
var me = this, |
|
453 |
formats = this.getFormats( this.props ), |
|
454 |
props = {dateFormat: formats.date, timeFormat: formats.time} |
|
455 |
; |
|
456 |
|
|
457 |
this.componentProps.fromProps.forEach( function( name ) { |
|
458 |
props[ name ] = me.props[ name ]; |
|
459 |
}); |
|
460 |
this.componentProps.fromState.forEach( function( name ) { |
|
461 |
props[ name ] = me.state[ name ]; |
|
462 |
}); |
|
463 |
this.componentProps.fromThis.forEach( function( name ) { |
|
464 |
props[ name ] = me[ name ]; |
|
465 |
}); |
|
466 |
|
|
467 |
return props; |
|
468 |
}, |
|
469 |
|
|
470 |
render: function() { |
|
471 |
var Component = this.viewComponents[ this.state.currentView ], |
|
472 |
DOM = React.DOM, |
|
473 |
className = 'rdt' + (this.props.className ? |
|
474 |
( Array.isArray( this.props.className ) ? |
|
475 |
' ' + this.props.className.join( ' ' ) : ' ' + this.props.className) : ''), |
|
476 |
children = [] |
|
477 |
; |
|
478 |
|
|
479 |
if ( this.props.input ) { |
|
480 |
children = [ DOM.input( assign({ |
|
481 |
key: 'i', |
|
482 |
type: 'text', |
|
483 |
className: 'form-control', |
|
484 |
onFocus: this.openCalendar, |
|
485 |
onChange: this.onInputChange, |
|
486 |
onKeyDown: this.onInputKey, |
|
487 |
value: this.state.inputValue |
|
488 |
}, this.props.inputProps ))]; |
|
489 |
} else { |
|
490 |
className += ' rdtStatic'; |
|
491 |
} |
|
492 |
|
|
493 |
if ( this.state.open ) |
|
494 |
className += ' rdtOpen'; |
|
495 |
|
|
496 |
return DOM.div({className: className}, children.concat( |
|
497 |
DOM.div( |
|
498 |
{ key: 'dt', className: 'rdtPicker' }, |
|
499 |
React.createElement( Component, this.getComponentProps()) |
|
500 |
) |
|
501 |
)); |
|
502 |
} |
|
503 |
}); |
|
504 |
|
|
505 |
// Make moment accessible through the Datetime class |
|
506 |
Datetime.moment = moment; |
|
507 |
|
|
508 |
module.exports = Datetime; |
|
509 |
|
d76f7b
|
510 |
|
M |
511 |
/***/ }, |
|
512 |
/* 1 */ |
272903
|
513 |
/***/ function(module, exports) { |
d76f7b
|
514 |
|
be9654
|
515 |
'use strict'; |
SE |
516 |
var propIsEnumerable = Object.prototype.propertyIsEnumerable; |
|
517 |
|
|
518 |
function ToObject(val) { |
|
519 |
if (val == null) { |
|
520 |
throw new TypeError('Object.assign cannot be called with null or undefined'); |
|
521 |
} |
|
522 |
|
|
523 |
return Object(val); |
|
524 |
} |
|
525 |
|
|
526 |
function ownEnumerableKeys(obj) { |
|
527 |
var keys = Object.getOwnPropertyNames(obj); |
|
528 |
|
|
529 |
if (Object.getOwnPropertySymbols) { |
|
530 |
keys = keys.concat(Object.getOwnPropertySymbols(obj)); |
|
531 |
} |
|
532 |
|
|
533 |
return keys.filter(function (key) { |
|
534 |
return propIsEnumerable.call(obj, key); |
|
535 |
}); |
|
536 |
} |
|
537 |
|
|
538 |
module.exports = Object.assign || function (target, source) { |
|
539 |
var from; |
|
540 |
var keys; |
|
541 |
var to = ToObject(target); |
|
542 |
|
|
543 |
for (var s = 1; s < arguments.length; s++) { |
|
544 |
from = arguments[s]; |
|
545 |
keys = ownEnumerableKeys(Object(from)); |
|
546 |
|
|
547 |
for (var i = 0; i < keys.length; i++) { |
|
548 |
to[keys[i]] = from[keys[i]]; |
|
549 |
} |
|
550 |
} |
|
551 |
|
|
552 |
return to; |
|
553 |
}; |
|
554 |
|
d76f7b
|
555 |
|
M |
556 |
/***/ }, |
|
557 |
/* 2 */ |
|
558 |
/***/ function(module, exports) { |
|
559 |
|
be9654
|
560 |
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; |
d76f7b
|
561 |
|
M |
562 |
/***/ }, |
|
563 |
/* 3 */ |
c5aa9b
|
564 |
/***/ function(module, exports) { |
d76f7b
|
565 |
|
be9654
|
566 |
module.exports = __WEBPACK_EXTERNAL_MODULE_3__; |
d76f7b
|
567 |
|
M |
568 |
/***/ }, |
|
569 |
/* 4 */ |
c5aa9b
|
570 |
/***/ function(module, exports, __webpack_require__) { |
d76f7b
|
571 |
|
be9654
|
572 |
'use strict'; |
SE |
573 |
|
|
574 |
var React = __webpack_require__(3), |
|
575 |
moment = __webpack_require__(2) |
|
576 |
; |
|
577 |
|
|
578 |
var DOM = React.DOM; |
|
579 |
var DateTimePickerDays = React.createClass({ |
|
580 |
render: function() { |
|
581 |
var footer = this.renderFooter(), |
|
582 |
date = this.props.viewDate, |
|
583 |
locale = date.localeData(), |
|
584 |
tableChildren |
|
585 |
; |
|
586 |
|
|
587 |
tableChildren = [ |
|
588 |
DOM.thead({ key: 'th' }, [ |
|
589 |
DOM.tr({ key: 'h' }, [ |
|
590 |
DOM.th({ key: 'p', className: 'rdtPrev' }, DOM.span({ onClick: this.props.subtractTime( 1, 'months' )}, '‹' )), |
|
591 |
DOM.th({ key: 's', className: 'rdtSwitch', onClick: this.props.showView( 'months' ), colSpan: 5, 'data-value': this.props.viewDate.month() }, locale.months( date ) + ' ' + date.year() ), |
|
592 |
DOM.th({ key: 'n', className: 'rdtNext' }, DOM.span({ onClick: this.props.addTime( 1, 'months' )}, '›' )) |
|
593 |
]), |
|
594 |
DOM.tr({ key: 'd'}, this.getDaysOfWeek( locale ).map( function( day, index ) { return DOM.th({ key: day + index, className: 'dow'}, day ); }) ) |
|
595 |
]), |
|
596 |
DOM.tbody({ key: 'tb' }, this.renderDays()) |
|
597 |
]; |
|
598 |
|
|
599 |
if ( footer ) |
|
600 |
tableChildren.push( footer ); |
|
601 |
|
|
602 |
return DOM.div({ className: 'rdtDays' }, |
|
603 |
DOM.table({}, tableChildren ) |
|
604 |
); |
|
605 |
}, |
|
606 |
|
|
607 |
/** |
|
608 |
* Get a list of the days of the week |
|
609 |
* depending on the current locale |
|
610 |
* @return {array} A list with the shortname of the days |
|
611 |
*/ |
|
612 |
getDaysOfWeek: function( locale ) { |
|
613 |
var days = locale._weekdaysMin, |
|
614 |
first = locale.firstDayOfWeek(), |
|
615 |
dow = [], |
|
616 |
i = 0 |
|
617 |
; |
|
618 |
|
|
619 |
days.forEach( function( day ) { |
|
620 |
dow[ (7 + ( i++ ) - first) % 7 ] = day; |
|
621 |
}); |
|
622 |
|
|
623 |
return dow; |
|
624 |
}, |
|
625 |
|
|
626 |
renderDays: function() { |
|
627 |
var date = this.props.viewDate, |
|
628 |
selected = this.props.selectedDate && this.props.selectedDate.clone(), |
|
629 |
prevMonth = date.clone().subtract( 1, 'months' ), |
|
630 |
currentYear = date.year(), |
|
631 |
currentMonth = date.month(), |
|
632 |
weeks = [], |
|
633 |
days = [], |
|
634 |
renderer = this.props.renderDay || this.renderDay, |
|
635 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
636 |
classes, isDisabled, dayProps, currentDate |
|
637 |
; |
|
638 |
|
|
639 |
// Go to the last week of the previous month |
|
640 |
prevMonth.date( prevMonth.daysInMonth() ).startOf( 'week' ); |
|
641 |
var lastDay = prevMonth.clone().add( 42, 'd' ); |
|
642 |
|
|
643 |
while ( prevMonth.isBefore( lastDay ) ) { |
|
644 |
classes = 'rdtDay'; |
|
645 |
currentDate = prevMonth.clone(); |
|
646 |
|
|
647 |
if ( ( prevMonth.year() === currentYear && prevMonth.month() < currentMonth ) || ( prevMonth.year() < currentYear ) ) |
|
648 |
classes += ' rdtOld'; |
|
649 |
else if ( ( prevMonth.year() === currentYear && prevMonth.month() > currentMonth ) || ( prevMonth.year() > currentYear ) ) |
|
650 |
classes += ' rdtNew'; |
|
651 |
|
|
652 |
if ( selected && prevMonth.isSame( selected, 'day' ) ) |
|
653 |
classes += ' rdtActive'; |
|
654 |
|
|
655 |
if (prevMonth.isSame( moment(), 'day' ) ) |
|
656 |
classes += ' rdtToday'; |
|
657 |
|
|
658 |
isDisabled = !isValid( currentDate, selected ); |
|
659 |
if ( isDisabled ) |
|
660 |
classes += ' rdtDisabled'; |
|
661 |
|
|
662 |
dayProps = { |
|
663 |
key: prevMonth.format( 'M_D' ), |
|
664 |
'data-value': prevMonth.date(), |
|
665 |
className: classes |
|
666 |
}; |
|
667 |
|
|
668 |
if ( !isDisabled ) |
|
669 |
dayProps.onClick = this.updateSelectedDate; |
|
670 |
|
|
671 |
days.push( renderer( dayProps, currentDate, selected ) ); |
|
672 |
|
|
673 |
if ( days.length === 7 ) { |
|
674 |
weeks.push( DOM.tr({ key: prevMonth.format( 'M_D' )}, days ) ); |
|
675 |
days = []; |
|
676 |
} |
|
677 |
|
|
678 |
prevMonth.add( 1, 'd' ); |
|
679 |
} |
|
680 |
|
|
681 |
return weeks; |
|
682 |
}, |
|
683 |
|
|
684 |
updateSelectedDate: function( event ) { |
|
685 |
this.props.updateSelectedDate( event, true ); |
|
686 |
}, |
|
687 |
|
|
688 |
renderDay: function( props, currentDate ) { |
|
689 |
return DOM.td( props, currentDate.date() ); |
|
690 |
}, |
|
691 |
|
|
692 |
renderFooter: function() { |
|
693 |
if ( !this.props.timeFormat ) |
|
694 |
return ''; |
|
695 |
|
|
696 |
var date = this.props.selectedDate || this.props.viewDate; |
|
697 |
|
|
698 |
return DOM.tfoot({ key: 'tf'}, |
|
699 |
DOM.tr({}, |
|
700 |
DOM.td({ onClick: this.props.showView( 'time' ), colSpan: 7, className: 'rdtTimeToggle' }, date.format( this.props.timeFormat )) |
|
701 |
) |
|
702 |
); |
|
703 |
}, |
|
704 |
|
|
705 |
alwaysValidDate: function() { |
|
706 |
return 1; |
|
707 |
} |
|
708 |
}); |
|
709 |
|
|
710 |
module.exports = DateTimePickerDays; |
|
711 |
|
d76f7b
|
712 |
|
M |
713 |
/***/ }, |
|
714 |
/* 5 */ |
272903
|
715 |
/***/ function(module, exports, __webpack_require__) { |
d76f7b
|
716 |
|
be9654
|
717 |
'use strict'; |
SE |
718 |
|
|
719 |
var React = __webpack_require__(3); |
|
720 |
|
|
721 |
var DOM = React.DOM; |
|
722 |
var DateTimePickerMonths = React.createClass({ |
|
723 |
render: function() { |
|
724 |
return DOM.div({ className: 'rdtMonths' }, [ |
|
725 |
DOM.table({ key: 'a' }, DOM.thead( {}, DOM.tr( {}, [ |
|
726 |
DOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.span({ onClick: this.props.subtractTime( 1, 'years' )}, '‹' )), |
|
727 |
DOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView( 'years' ), colSpan: 2, 'data-value': this.props.viewDate.year() }, this.props.viewDate.year() ), |
|
728 |
DOM.th({ key: 'next', className: 'rdtNext' }, DOM.span({ onClick: this.props.addTime( 1, 'years' )}, '›' )) |
|
729 |
]))), |
|
730 |
DOM.table({ key: 'months' }, DOM.tbody({ key: 'b' }, this.renderMonths())) |
|
731 |
]); |
|
732 |
}, |
|
733 |
|
|
734 |
renderMonths: function() { |
|
735 |
var date = this.props.selectedDate, |
|
736 |
month = this.props.viewDate.month(), |
|
737 |
year = this.props.viewDate.year(), |
|
738 |
rows = [], |
|
739 |
i = 0, |
|
740 |
months = [], |
|
741 |
renderer = this.props.renderMonth || this.renderMonth, |
|
742 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
743 |
classes, props, currentMonth, isDisabled, noOfDaysInMonth, daysInMonth, validDay, |
|
744 |
// Date is irrelevant because we're only interested in month |
|
745 |
irrelevantDate = 1 |
|
746 |
; |
|
747 |
|
|
748 |
while (i < 12) { |
|
749 |
classes = 'rdtMonth'; |
|
750 |
currentMonth = |
|
751 |
this.props.viewDate.clone().set({ year: year, month: i, date: irrelevantDate }); |
|
752 |
|
|
753 |
noOfDaysInMonth = currentMonth.endOf( 'month' ).format( 'D' ); |
|
754 |
daysInMonth = Array.from({ length: noOfDaysInMonth }, function( e, i ) { |
|
755 |
return i + 1; |
|
756 |
}); |
|
757 |
|
|
758 |
validDay = daysInMonth.find(function( d ) { |
|
759 |
var day = currentMonth.clone().set( 'date', d ); |
|
760 |
return isValid( day ); |
|
761 |
}); |
|
762 |
|
|
763 |
isDisabled = ( validDay === undefined ); |
|
764 |
|
|
765 |
if ( isDisabled ) |
|
766 |
classes += ' rdtDisabled'; |
|
767 |
|
|
768 |
if ( date && i === month && year === date.year() ) |
|
769 |
classes += ' rdtActive'; |
|
770 |
|
|
771 |
props = { |
|
772 |
key: i, |
|
773 |
'data-value': i, |
|
774 |
className: classes |
|
775 |
}; |
|
776 |
|
|
777 |
if ( !isDisabled ) |
|
778 |
props.onClick = ( this.props.updateOn === 'months' ? |
|
779 |
this.updateSelectedMonth : this.props.setDate( 'month' ) ); |
|
780 |
|
|
781 |
months.push( renderer( props, i, year, date && date.clone() ) ); |
|
782 |
|
|
783 |
if ( months.length === 4 ) { |
|
784 |
rows.push( DOM.tr({ key: month + '_' + rows.length }, months ) ); |
|
785 |
months = []; |
|
786 |
} |
|
787 |
|
|
788 |
i++; |
|
789 |
} |
|
790 |
|
|
791 |
return rows; |
|
792 |
}, |
|
793 |
|
|
794 |
updateSelectedMonth: function( event ) { |
|
795 |
this.props.updateSelectedDate( event, true ); |
|
796 |
}, |
|
797 |
|
|
798 |
renderMonth: function( props, month ) { |
|
799 |
var localMoment = this.props.viewDate; |
|
800 |
var monthStr = localMoment.localeData().monthsShort( localMoment.month( month ) ); |
|
801 |
var strLength = 3; |
|
802 |
// Because some months are up to 5 characters long, we want to |
|
803 |
// use a fixed string length for consistency |
|
804 |
var monthStrFixedLength = monthStr.substring( 0, strLength ); |
|
805 |
return DOM.td( props, capitalize( monthStrFixedLength ) ); |
|
806 |
}, |
|
807 |
|
|
808 |
alwaysValidDate: function() { |
|
809 |
return 1; |
|
810 |
} |
|
811 |
}); |
|
812 |
|
|
813 |
function capitalize( str ) { |
|
814 |
return str.charAt( 0 ).toUpperCase() + str.slice( 1 ); |
|
815 |
} |
|
816 |
|
|
817 |
module.exports = DateTimePickerMonths; |
|
818 |
|
d76f7b
|
819 |
|
M |
820 |
/***/ }, |
|
821 |
/* 6 */ |
|
822 |
/***/ function(module, exports, __webpack_require__) { |
|
823 |
|
be9654
|
824 |
'use strict'; |
SE |
825 |
|
|
826 |
var React = __webpack_require__(3); |
|
827 |
|
|
828 |
var DOM = React.DOM; |
|
829 |
var DateTimePickerYears = React.createClass({ |
|
830 |
render: function() { |
|
831 |
var year = parseInt( this.props.viewDate.year() / 10, 10 ) * 10; |
|
832 |
|
|
833 |
return DOM.div({ className: 'rdtYears' }, [ |
|
834 |
DOM.table({ key: 'a' }, DOM.thead({}, DOM.tr({}, [ |
|
835 |
DOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.span({ onClick: this.props.subtractTime( 10, 'years' )}, '‹' )), |
|
836 |
DOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView( 'years' ), colSpan: 2 }, year + '-' + ( year + 9 ) ), |
|
837 |
DOM.th({ key: 'next', className: 'rdtNext' }, DOM.span({ onClick: this.props.addTime( 10, 'years' )}, '›' )) |
|
838 |
]))), |
|
839 |
DOM.table({ key: 'years' }, DOM.tbody( {}, this.renderYears( year ))) |
|
840 |
]); |
|
841 |
}, |
|
842 |
|
|
843 |
renderYears: function( year ) { |
|
844 |
var years = [], |
|
845 |
i = -1, |
|
846 |
rows = [], |
|
847 |
renderer = this.props.renderYear || this.renderYear, |
|
848 |
selectedDate = this.props.selectedDate, |
|
849 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
850 |
classes, props, currentYear, isDisabled, noOfDaysInYear, daysInYear, validDay, |
|
851 |
// Month and date are irrelevant here because |
|
852 |
// we're only interested in the year |
|
853 |
irrelevantMonth = 0, |
|
854 |
irrelevantDate = 1 |
|
855 |
; |
|
856 |
|
|
857 |
year--; |
|
858 |
while (i < 11) { |
|
859 |
classes = 'rdtYear'; |
|
860 |
currentYear = this.props.viewDate.clone().set( |
|
861 |
{ year: year, month: irrelevantMonth, date: irrelevantDate } ); |
|
862 |
|
|
863 |
// Not sure what 'rdtOld' is for, commenting out for now as it's not working properly |
|
864 |
// if ( i === -1 | i === 10 ) |
|
865 |
// classes += ' rdtOld'; |
|
866 |
|
|
867 |
noOfDaysInYear = currentYear.endOf( 'year' ).format( 'DDD' ); |
|
868 |
daysInYear = Array.from({ length: noOfDaysInYear }, function( e, i ) { |
|
869 |
return i + 1; |
|
870 |
}); |
|
871 |
|
|
872 |
validDay = daysInYear.find(function( d ) { |
|
873 |
var day = currentYear.clone().dayOfYear( d ); |
|
874 |
return isValid( day ); |
|
875 |
}); |
|
876 |
|
|
877 |
isDisabled = ( validDay === undefined ); |
|
878 |
|
|
879 |
if ( isDisabled ) |
|
880 |
classes += ' rdtDisabled'; |
|
881 |
|
|
882 |
if ( selectedDate && selectedDate.year() === year ) |
|
883 |
classes += ' rdtActive'; |
|
884 |
|
|
885 |
props = { |
|
886 |
key: year, |
|
887 |
'data-value': year, |
|
888 |
className: classes |
|
889 |
}; |
|
890 |
|
|
891 |
if ( !isDisabled ) |
|
892 |
props.onClick = ( this.props.updateOn === 'years' ? |
|
893 |
this.updateSelectedYear : this.props.setDate('year') ); |
|
894 |
|
|
895 |
years.push( renderer( props, year, selectedDate && selectedDate.clone() )); |
|
896 |
|
|
897 |
if ( years.length === 4 ) { |
|
898 |
rows.push( DOM.tr({ key: i }, years ) ); |
|
899 |
years = []; |
|
900 |
} |
|
901 |
|
|
902 |
year++; |
|
903 |
i++; |
|
904 |
} |
|
905 |
|
|
906 |
return rows; |
|
907 |
}, |
|
908 |
|
|
909 |
updateSelectedYear: function( event ) { |
|
910 |
this.props.updateSelectedDate( event, true ); |
|
911 |
}, |
|
912 |
|
|
913 |
renderYear: function( props, year ) { |
|
914 |
return DOM.td( props, year ); |
|
915 |
}, |
|
916 |
|
|
917 |
alwaysValidDate: function() { |
|
918 |
return 1; |
|
919 |
} |
|
920 |
}); |
|
921 |
|
|
922 |
module.exports = DateTimePickerYears; |
|
923 |
|
d76f7b
|
924 |
|
M |
925 |
/***/ }, |
|
926 |
/* 7 */ |
|
927 |
/***/ function(module, exports, __webpack_require__) { |
|
928 |
|
be9654
|
929 |
'use strict'; |
SE |
930 |
|
|
931 |
var React = __webpack_require__(3), |
|
932 |
assign = __webpack_require__(1) |
|
933 |
; |
|
934 |
|
|
935 |
var DOM = React.DOM; |
|
936 |
var DateTimePickerTime = React.createClass({ |
|
937 |
getInitialState: function() { |
|
938 |
return this.calculateState( this.props ); |
|
939 |
}, |
|
940 |
|
|
941 |
calculateState: function( props ) { |
|
942 |
var date = props.selectedDate || props.viewDate, |
|
943 |
format = props.timeFormat, |
|
944 |
counters = [] |
|
945 |
; |
|
946 |
|
|
947 |
if ( format.toLowerCase().indexOf('h') !== -1 ) { |
|
948 |
counters.push('hours'); |
|
949 |
if ( format.indexOf('m') !== -1 ) { |
|
950 |
counters.push('minutes'); |
|
951 |
if ( format.indexOf('s') !== -1 ) { |
|
952 |
counters.push('seconds'); |
|
953 |
} |
|
954 |
} |
|
955 |
} |
|
956 |
|
|
957 |
var daypart = false; |
|
958 |
if ( this.state !== null && this.props.timeFormat.toLowerCase().indexOf( ' a' ) !== -1 ) { |
|
959 |
if ( this.props.timeFormat.indexOf( ' A' ) !== -1 ) { |
|
960 |
daypart = ( this.state.hours >= 12 ) ? 'PM' : 'AM'; |
|
961 |
} else { |
|
962 |
daypart = ( this.state.hours >= 12 ) ? 'pm' : 'am'; |
|
963 |
} |
|
964 |
} |
|
965 |
|
|
966 |
return { |
|
967 |
hours: date.format( 'H' ), |
|
968 |
minutes: date.format( 'mm' ), |
|
969 |
seconds: date.format( 'ss' ), |
|
970 |
milliseconds: date.format( 'SSS' ), |
|
971 |
daypart: daypart, |
|
972 |
counters: counters |
|
973 |
}; |
|
974 |
}, |
|
975 |
|
|
976 |
renderCounter: function( type ) { |
|
977 |
if ( type !== 'daypart' ) { |
|
978 |
var value = this.state[ type ]; |
|
979 |
if ( type === 'hours' && this.props.timeFormat.toLowerCase().indexOf( ' a' ) !== -1 ) { |
|
980 |
value = ( value - 1 ) % 12 + 1; |
|
981 |
|
|
982 |
if ( value === 0 ) { |
|
983 |
value = 12; |
|
984 |
} |
|
985 |
} |
|
986 |
return DOM.div({ key: type, className: 'rdtCounter' }, [ |
|
987 |
DOM.span({ key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'increase', type ) }, 'â–²' ), |
|
988 |
DOM.div({ key: 'c', className: 'rdtCount' }, value ), |
|
989 |
DOM.span({ key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'decrease', type ) }, 'â–¼' ) |
|
990 |
]); |
|
991 |
} |
|
992 |
return ''; |
|
993 |
}, |
|
994 |
|
|
995 |
renderDayPart: function() { |
|
996 |
return DOM.div({ key: 'dayPart', className: 'rdtCounter' }, [ |
|
997 |
DOM.span({ key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, 'â–²' ), |
|
998 |
DOM.div({ key: this.state.daypart, className: 'rdtCount' }, this.state.daypart ), |
|
999 |
DOM.span({ key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, 'â–¼' ) |
|
1000 |
]); |
|
1001 |
}, |
|
1002 |
|
|
1003 |
render: function() { |
|
1004 |
var me = this, |
|
1005 |
counters = [] |
|
1006 |
; |
|
1007 |
|
|
1008 |
this.state.counters.forEach( function( c ) { |
|
1009 |
if ( counters.length ) |
|
1010 |
counters.push( DOM.div({ key: 'sep' + counters.length, className: 'rdtCounterSeparator' }, ':' ) ); |
|
1011 |
counters.push( me.renderCounter( c ) ); |
|
1012 |
}); |
|
1013 |
|
|
1014 |
if ( this.state.daypart !== false ) { |
|
1015 |
counters.push( me.renderDayPart() ); |
|
1016 |
} |
|
1017 |
|
|
1018 |
if ( this.state.counters.length === 3 && this.props.timeFormat.indexOf( 'S' ) !== -1 ) { |
|
1019 |
counters.push( DOM.div({ className: 'rdtCounterSeparator', key: 'sep5' }, ':' ) ); |
|
1020 |
counters.push( |
|
1021 |
DOM.div({ className: 'rdtCounter rdtMilli', key: 'm' }, |
|
1022 |
DOM.input({ value: this.state.milliseconds, type: 'text', onChange: this.updateMilli } ) |
|
1023 |
) |
|
1024 |
); |
|
1025 |
} |
|
1026 |
|
|
1027 |
return DOM.div({ className: 'rdtTime' }, |
|
1028 |
DOM.table({}, [ |
|
1029 |
this.renderHeader(), |
|
1030 |
DOM.tbody({ key: 'b'}, DOM.tr({}, DOM.td({}, |
|
1031 |
DOM.div({ className: 'rdtCounters' }, counters ) |
|
1032 |
))) |
|
1033 |
]) |
|
1034 |
); |
|
1035 |
}, |
|
1036 |
|
|
1037 |
componentWillMount: function() { |
|
1038 |
var me = this; |
|
1039 |
me.timeConstraints = { |
|
1040 |
hours: { |
|
1041 |
min: 0, |
|
1042 |
max: 23, |
|
1043 |
step: 1 |
|
1044 |
}, |
|
1045 |
minutes: { |
|
1046 |
min: 0, |
|
1047 |
max: 59, |
|
1048 |
step: 1 |
|
1049 |
}, |
|
1050 |
seconds: { |
|
1051 |
min: 0, |
|
1052 |
max: 59, |
|
1053 |
step: 1 |
|
1054 |
}, |
|
1055 |
milliseconds: { |
|
1056 |
min: 0, |
|
1057 |
max: 999, |
|
1058 |
step: 1 |
|
1059 |
} |
|
1060 |
}; |
|
1061 |
['hours', 'minutes', 'seconds', 'milliseconds'].forEach( function( type ) { |
|
1062 |
assign(me.timeConstraints[ type ], me.props.timeConstraints[ type ]); |
|
1063 |
}); |
|
1064 |
this.setState( this.calculateState( this.props ) ); |
|
1065 |
}, |
|
1066 |
|
|
1067 |
componentWillReceiveProps: function( nextProps ) { |
|
1068 |
this.setState( this.calculateState( nextProps ) ); |
|
1069 |
}, |
|
1070 |
|
|
1071 |
updateMilli: function( e ) { |
|
1072 |
var milli = parseInt( e.target.value, 10 ); |
|
1073 |
if ( milli === e.target.value && milli >= 0 && milli < 1000 ) { |
|
1074 |
this.props.setTime( 'milliseconds', milli ); |
|
1075 |
this.setState( { milliseconds: milli } ); |
|
1076 |
} |
|
1077 |
}, |
|
1078 |
|
|
1079 |
renderHeader: function() { |
|
1080 |
if ( !this.props.dateFormat ) |
|
1081 |
return null; |
|
1082 |
|
|
1083 |
var date = this.props.selectedDate || this.props.viewDate; |
|
1084 |
return DOM.thead({ key: 'h' }, DOM.tr({}, |
|
1085 |
DOM.th({ className: 'rdtSwitch', colSpan: 4, onClick: this.props.showView( 'days' ) }, date.format( this.props.dateFormat ) ) |
|
1086 |
)); |
|
1087 |
}, |
|
1088 |
|
|
1089 |
onStartClicking: function( action, type ) { |
|
1090 |
var me = this; |
|
1091 |
|
|
1092 |
return function() { |
|
1093 |
var update = {}; |
|
1094 |
update[ type ] = me[ action ]( type ); |
|
1095 |
me.setState( update ); |
|
1096 |
|
|
1097 |
me.timer = setTimeout( function() { |
|
1098 |
me.increaseTimer = setInterval( function() { |
|
1099 |
update[ type ] = me[ action ]( type ); |
|
1100 |
me.setState( update ); |
|
1101 |
}, 70); |
|
1102 |
}, 500); |
|
1103 |
|
|
1104 |
me.mouseUpListener = function() { |
|
1105 |
clearTimeout( me.timer ); |
|
1106 |
clearInterval( me.increaseTimer ); |
|
1107 |
me.props.setTime( type, me.state[ type ] ); |
|
1108 |
document.body.removeEventListener( 'mouseup', me.mouseUpListener ); |
|
1109 |
}; |
|
1110 |
|
|
1111 |
document.body.addEventListener( 'mouseup', me.mouseUpListener ); |
|
1112 |
}; |
|
1113 |
}, |
|
1114 |
|
|
1115 |
padValues: { |
|
1116 |
hours: 1, |
|
1117 |
minutes: 2, |
|
1118 |
seconds: 2, |
|
1119 |
milliseconds: 3 |
|
1120 |
}, |
|
1121 |
|
|
1122 |
toggleDayPart: function( type ) { // type is always 'hours' |
|
1123 |
var value = parseInt( this.state[ type ], 10) + 12; |
|
1124 |
if ( value > this.timeConstraints[ type ].max ) |
|
1125 |
value = this.timeConstraints[ type ].min + ( value - ( this.timeConstraints[ type ].max + 1 ) ); |
|
1126 |
return this.pad( type, value ); |
|
1127 |
}, |
|
1128 |
|
|
1129 |
increase: function( type ) { |
|
1130 |
var value = parseInt( this.state[ type ], 10) + this.timeConstraints[ type ].step; |
|
1131 |
if ( value > this.timeConstraints[ type ].max ) |
|
1132 |
value = this.timeConstraints[ type ].min + ( value - ( this.timeConstraints[ type ].max + 1 ) ); |
|
1133 |
return this.pad( type, value ); |
|
1134 |
}, |
|
1135 |
|
|
1136 |
decrease: function( type ) { |
|
1137 |
var value = parseInt( this.state[ type ], 10) - this.timeConstraints[ type ].step; |
|
1138 |
if ( value < this.timeConstraints[ type ].min ) |
|
1139 |
value = this.timeConstraints[ type ].max + 1 - ( this.timeConstraints[ type ].min - value ); |
|
1140 |
return this.pad( type, value ); |
|
1141 |
}, |
|
1142 |
|
|
1143 |
pad: function( type, value ) { |
|
1144 |
var str = value + ''; |
|
1145 |
while ( str.length < this.padValues[ type ] ) |
|
1146 |
str = '0' + str; |
|
1147 |
return str; |
|
1148 |
} |
|
1149 |
}); |
|
1150 |
|
|
1151 |
module.exports = DateTimePickerTime; |
|
1152 |
|
d76f7b
|
1153 |
|
M |
1154 |
/***/ }, |
|
1155 |
/* 8 */ |
|
1156 |
/***/ function(module, exports, __webpack_require__) { |
|
1157 |
|
be9654
|
1158 |
'use strict'; |
SE |
1159 |
|
|
1160 |
// This is extracted from https://github.com/Pomax/react-onclickoutside |
|
1161 |
// And modified to support react 0.13 and react 0.14 |
|
1162 |
|
|
1163 |
var React = __webpack_require__(3), |
|
1164 |
version = React.version && React.version.split('.') |
|
1165 |
; |
|
1166 |
|
|
1167 |
if ( version && ( version[0] > 0 || version[1] > 13 ) ) |
|
1168 |
React = __webpack_require__(9); |
|
1169 |
|
|
1170 |
// Use a parallel array because we can't use |
|
1171 |
// objects as keys, they get toString-coerced |
|
1172 |
var registeredComponents = []; |
|
1173 |
var handlers = []; |
|
1174 |
|
|
1175 |
var IGNORE_CLASS = 'ignore-react-onclickoutside'; |
|
1176 |
|
|
1177 |
var isSourceFound = function(source, localNode) { |
|
1178 |
if (source === localNode) { |
|
1179 |
return true; |
|
1180 |
} |
|
1181 |
// SVG <use/> elements do not technically reside in the rendered DOM, so |
|
1182 |
// they do not have classList directly, but they offer a link to their |
|
1183 |
// corresponding element, which can have classList. This extra check is for |
|
1184 |
// that case. |
|
1185 |
// See: http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGUseElement |
|
1186 |
// Discussion: https://github.com/Pomax/react-onclickoutside/pull/17 |
|
1187 |
if (source.correspondingElement) { |
|
1188 |
return source.correspondingElement.classList.contains(IGNORE_CLASS); |
|
1189 |
} |
|
1190 |
return source.classList.contains(IGNORE_CLASS); |
|
1191 |
}; |
|
1192 |
|
|
1193 |
module.exports = { |
|
1194 |
componentDidMount: function() { |
|
1195 |
if (typeof this.handleClickOutside !== 'function') |
|
1196 |
throw new Error('Component lacks a handleClickOutside(event) function for processing outside click events.'); |
|
1197 |
|
|
1198 |
var fn = this.__outsideClickHandler = (function(localNode, eventHandler) { |
|
1199 |
return function(evt) { |
|
1200 |
evt.stopPropagation(); |
|
1201 |
var source = evt.target; |
|
1202 |
var found = false; |
|
1203 |
// If source=local then this event came from "somewhere" |
|
1204 |
// inside and should be ignored. We could handle this with |
|
1205 |
// a layered approach, too, but that requires going back to |
|
1206 |
// thinking in terms of Dom node nesting, running counter |
|
1207 |
// to React's "you shouldn't care about the DOM" philosophy. |
|
1208 |
while (source.parentNode) { |
|
1209 |
found = isSourceFound(source, localNode); |
|
1210 |
if (found) return; |
|
1211 |
source = source.parentNode; |
|
1212 |
} |
|
1213 |
eventHandler(evt); |
|
1214 |
}; |
|
1215 |
}(React.findDOMNode(this), this.handleClickOutside)); |
|
1216 |
|
|
1217 |
var pos = registeredComponents.length; |
|
1218 |
registeredComponents.push(this); |
|
1219 |
handlers[pos] = fn; |
|
1220 |
|
|
1221 |
// If there is a truthy disableOnClickOutside property for this |
|
1222 |
// component, don't immediately start listening for outside events. |
|
1223 |
if (!this.props.disableOnClickOutside) { |
|
1224 |
this.enableOnClickOutside(); |
|
1225 |
} |
|
1226 |
}, |
|
1227 |
|
|
1228 |
componentWillUnmount: function() { |
|
1229 |
this.disableOnClickOutside(); |
|
1230 |
this.__outsideClickHandler = false; |
|
1231 |
var pos = registeredComponents.indexOf(this); |
|
1232 |
if ( pos>-1) { |
|
1233 |
if (handlers[pos]) { |
|
1234 |
// clean up so we don't leak memory |
|
1235 |
handlers.splice(pos, 1); |
|
1236 |
registeredComponents.splice(pos, 1); |
|
1237 |
} |
|
1238 |
} |
|
1239 |
}, |
|
1240 |
|
|
1241 |
/** |
|
1242 |
* Can be called to explicitly enable event listening |
|
1243 |
* for clicks and touches outside of this element. |
|
1244 |
*/ |
|
1245 |
enableOnClickOutside: function() { |
|
1246 |
var fn = this.__outsideClickHandler; |
|
1247 |
document.addEventListener('mousedown', fn); |
|
1248 |
document.addEventListener('touchstart', fn); |
|
1249 |
}, |
|
1250 |
|
|
1251 |
/** |
|
1252 |
* Can be called to explicitly disable event listening |
|
1253 |
* for clicks and touches outside of this element. |
|
1254 |
*/ |
|
1255 |
disableOnClickOutside: function() { |
|
1256 |
var fn = this.__outsideClickHandler; |
|
1257 |
document.removeEventListener('mousedown', fn); |
|
1258 |
document.removeEventListener('touchstart', fn); |
|
1259 |
} |
|
1260 |
}; |
|
1261 |
|
d359eb
|
1262 |
|
M |
1263 |
/***/ }, |
|
1264 |
/* 9 */ |
|
1265 |
/***/ function(module, exports) { |
|
1266 |
|
be9654
|
1267 |
module.exports = __WEBPACK_EXTERNAL_MODULE_9__; |
d76f7b
|
1268 |
|
M |
1269 |
/***/ } |
|
1270 |
/******/ ]) |
|
1271 |
}); |
be9654
|
1272 |
; |