aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/common.js
diff options
context:
space:
mode:
authorafc163 <afc163@gmail.com>2017-03-08 15:01:49 +0800
committerafc163 <afc163@gmail.com>2017-03-08 15:01:49 +0800
commit9a24009f67ac917abfc35ec5f061cf1c240e1cea (patch)
tree505d923cb6b925e8583d023abaa0427d4f1a09a9 /examples/common.js
parent7967d52afc0bb7edee7dc26f30d291970a0d81a7 (diff)
downloadtime-picker-9a24009f67ac917abfc35ec5f061cf1c240e1cea.tar.gz
time-picker-9a24009f67ac917abfc35ec5f061cf1c240e1cea.tar.zst
time-picker-9a24009f67ac917abfc35ec5f061cf1c240e1cea.zip
Updates
Diffstat (limited to 'examples/common.js')
-rw-r--r--examples/common.js135
1 files changed, 112 insertions, 23 deletions
diff --git a/examples/common.js b/examples/common.js
index 8562f55..e67abd0 100644
--- a/examples/common.js
+++ b/examples/common.js
@@ -51,7 +51,7 @@
51/******/ // "0" means "already loaded" 51/******/ // "0" means "already loaded"
52/******/ // Array means "loading", array contains callbacks 52/******/ // Array means "loading", array contains callbacks
53/******/ var installedChunks = { 53/******/ var installedChunks = {
54/******/ 6:0 54/******/ 7:0
55/******/ }; 55/******/ };
56/******/ 56/******/
57/******/ // The require function 57/******/ // The require function
@@ -97,7 +97,7 @@
97/******/ script.charset = 'utf-8'; 97/******/ script.charset = 'utf-8';
98/******/ script.async = true; 98/******/ script.async = true;
99/******/ 99/******/
100/******/ script.src = __webpack_require__.p + "" + chunkId + "." + ({"0":"disabled","1":"format","2":"hidden","3":"open","4":"pick-time","5":"value-and-defaultValue"}[chunkId]||chunkId) + ".js"; 100/******/ script.src = __webpack_require__.p + "" + chunkId + "." + ({"0":"12hours","1":"disabled","2":"format","3":"hidden","4":"open","5":"pick-time","6":"value-and-defaultValue"}[chunkId]||chunkId) + ".js";
101/******/ head.appendChild(script); 101/******/ head.appendChild(script);
102/******/ } 102/******/ }
103/******/ }; 103/******/ };
@@ -725,7 +725,7 @@
725 725
726/***/ }, 726/***/ },
727/* 8 */ 727/* 8 */
728[271, 9], 728[272, 9],
729/* 9 */ 729/* 9 */
730/***/ function(module, exports) { 730/***/ function(module, exports) {
731 731
@@ -6437,7 +6437,7 @@
6437 6437
6438/***/ }, 6438/***/ },
6439/* 52 */ 6439/* 52 */
6440[271, 37], 6440[272, 37],
6441/* 53 */ 6441/* 53 */
6442/***/ function(module, exports, __webpack_require__) { 6442/***/ function(module, exports, __webpack_require__) {
6443 6443
@@ -25533,7 +25533,8 @@
25533 onClose: _react.PropTypes.func, 25533 onClose: _react.PropTypes.func,
25534 addon: _react.PropTypes.func, 25534 addon: _react.PropTypes.func,
25535 name: _react.PropTypes.string, 25535 name: _react.PropTypes.string,
25536 autoComplete: _react.PropTypes.string 25536 autoComplete: _react.PropTypes.string,
25537 use12Hours: _react.PropTypes.bool
25537 }, 25538 },
25538 25539
25539 getDefaultProps: function getDefaultProps() { 25540 getDefaultProps: function getDefaultProps() {
@@ -25557,7 +25558,8 @@
25557 onChange: noop, 25558 onChange: noop,
25558 onOpen: noop, 25559 onOpen: noop,
25559 onClose: noop, 25560 onClose: noop,
25560 addon: noop 25561 addon: noop,
25562 use12Hours: false
25561 }; 25563 };
25562 }, 25564 },
25563 getInitialState: function getInitialState() { 25565 getInitialState: function getInitialState() {
@@ -25621,11 +25623,21 @@
25621 format = _props2.format, 25623 format = _props2.format,
25622 showHour = _props2.showHour, 25624 showHour = _props2.showHour,
25623 showMinute = _props2.showMinute, 25625 showMinute = _props2.showMinute,
25624 showSecond = _props2.showSecond; 25626 showSecond = _props2.showSecond,
25627 use12Hours = _props2.use12Hours;
25625 25628
25626 if (format) { 25629 if (format) {
25627 return format; 25630 return format;
25628 } 25631 }
25632
25633 if (use12Hours) {
25634 var fmtString = [showHour ? 'h' : '', showMinute ? 'mm' : '', showSecond ? 'ss' : ''].filter(function (item) {
25635 return !!item;
25636 }).join(':');
25637
25638 return fmtString.concat(' a');
25639 }
25640
25629 return [showHour ? 'HH' : '', showMinute ? 'mm' : '', showSecond ? 'ss' : ''].filter(function (item) { 25641 return [showHour ? 'HH' : '', showMinute ? 'mm' : '', showSecond ? 'ss' : ''].filter(function (item) {
25630 return !!item; 25642 return !!item;
25631 }).join(':'); 25643 }).join(':');
@@ -25644,7 +25656,8 @@
25644 showSecond = _props3.showSecond, 25656 showSecond = _props3.showSecond,
25645 defaultOpenValue = _props3.defaultOpenValue, 25657 defaultOpenValue = _props3.defaultOpenValue,
25646 clearText = _props3.clearText, 25658 clearText = _props3.clearText,
25647 addon = _props3.addon; 25659 addon = _props3.addon,
25660 use12Hours = _props3.use12Hours;
25648 25661
25649 return _react2.default.createElement(_Panel2.default, { 25662 return _react2.default.createElement(_Panel2.default, {
25650 clearText: clearText, 25663 clearText: clearText,
@@ -25665,6 +25678,7 @@
25665 disabledMinutes: disabledMinutes, 25678 disabledMinutes: disabledMinutes,
25666 disabledSeconds: disabledSeconds, 25679 disabledSeconds: disabledSeconds,
25667 hideDisabledOptions: hideDisabledOptions, 25680 hideDisabledOptions: hideDisabledOptions,
25681 use12Hours: use12Hours,
25668 addon: addon 25682 addon: addon
25669 }); 25683 });
25670 }, 25684 },
@@ -30313,6 +30327,7 @@
30313 showMinute: _react.PropTypes.bool, 30327 showMinute: _react.PropTypes.bool,
30314 showSecond: _react.PropTypes.bool, 30328 showSecond: _react.PropTypes.bool,
30315 onClear: _react.PropTypes.func, 30329 onClear: _react.PropTypes.func,
30330 use12Hours: _react.PropTypes.bool,
30316 addon: _react.PropTypes.func 30331 addon: _react.PropTypes.func
30317 }, 30332 },
30318 30333
@@ -30325,6 +30340,7 @@
30325 disabledMinutes: noop, 30340 disabledMinutes: noop,
30326 disabledSeconds: noop, 30341 disabledSeconds: noop,
30327 defaultOpenValue: (0, _moment2.default)(), 30342 defaultOpenValue: (0, _moment2.default)(),
30343 use12Hours: false,
30328 addon: noop 30344 addon: noop
30329 }; 30345 };
30330 }, 30346 },
@@ -30374,7 +30390,8 @@
30374 defaultOpenValue = _props.defaultOpenValue, 30390 defaultOpenValue = _props.defaultOpenValue,
30375 clearText = _props.clearText, 30391 clearText = _props.clearText,
30376 onEsc = _props.onEsc, 30392 onEsc = _props.onEsc,
30377 addon = _props.addon; 30393 addon = _props.addon,
30394 use12Hours = _props.use12Hours;
30378 var _state = this.state, 30395 var _state = this.state,
30379 value = _state.value, 30396 value = _state.value,
30380 currentSelectPanel = _state.currentSelectPanel; 30397 currentSelectPanel = _state.currentSelectPanel;
@@ -30423,7 +30440,8 @@
30423 disabledHours: disabledHours, 30440 disabledHours: disabledHours,
30424 disabledMinutes: disabledMinutes, 30441 disabledMinutes: disabledMinutes,
30425 disabledSeconds: disabledSeconds, 30442 disabledSeconds: disabledSeconds,
30426 onCurrentSelectPanelChange: this.onCurrentSelectPanelChange 30443 onCurrentSelectPanelChange: this.onCurrentSelectPanelChange,
30444 use12Hours: use12Hours
30427 }), 30445 }),
30428 addon(this) 30446 addon(this)
30429 ); 30447 );
@@ -30737,21 +30755,45 @@
30737 disabledHours: _react.PropTypes.func, 30755 disabledHours: _react.PropTypes.func,
30738 disabledMinutes: _react.PropTypes.func, 30756 disabledMinutes: _react.PropTypes.func,
30739 disabledSeconds: _react.PropTypes.func, 30757 disabledSeconds: _react.PropTypes.func,
30740 onCurrentSelectPanelChange: _react.PropTypes.func 30758 onCurrentSelectPanelChange: _react.PropTypes.func,
30759 use12Hours: _react.PropTypes.bool
30741 }, 30760 },
30742 30761
30743 onItemChange: function onItemChange(type, itemValue) { 30762 onItemChange: function onItemChange(type, itemValue) {
30744 var _props = this.props, 30763 var _props = this.props,
30745 onChange = _props.onChange, 30764 onChange = _props.onChange,
30746 defaultOpenValue = _props.defaultOpenValue; 30765 defaultOpenValue = _props.defaultOpenValue,
30766 use12Hours = _props.use12Hours;
30747 30767
30748 var value = (this.props.value || defaultOpenValue).clone(); 30768 var value = (this.props.value || defaultOpenValue).clone();
30769
30749 if (type === 'hour') { 30770 if (type === 'hour') {
30750 value.hour(itemValue); 30771 if (use12Hours) {
30772 if (this.isAM()) {
30773 value.hour(+itemValue % 12);
30774 } else {
30775 value.hour(+itemValue % 12 + 12);
30776 }
30777 } else {
30778 value.hour(+itemValue);
30779 }
30751 } else if (type === 'minute') { 30780 } else if (type === 'minute') {
30752 value.minute(itemValue); 30781 value.minute(+itemValue);
30782 } else if (type === 'ampm') {
30783 var ampm = itemValue.toUpperCase();
30784 if (use12Hours) {
30785 if (ampm === 'PM' && value.hour() < 12) {
30786 value.hour(value.hour() % 12 + 12);
30787 }
30788
30789 if (ampm === 'AM') {
30790 if (value.hour() >= 12) {
30791 value.hour(value.hour() - 12);
30792 }
30793 }
30794 }
30753 } else { 30795 } else {
30754 value.second(itemValue); 30796 value.second(+itemValue);
30755 } 30797 }
30756 onChange(value); 30798 onChange(value);
30757 }, 30799 },
@@ -30763,19 +30805,31 @@
30763 prefixCls = _props2.prefixCls, 30805 prefixCls = _props2.prefixCls,
30764 hourOptions = _props2.hourOptions, 30806 hourOptions = _props2.hourOptions,
30765 disabledHours = _props2.disabledHours, 30807 disabledHours = _props2.disabledHours,
30766 showHour = _props2.showHour; 30808 showHour = _props2.showHour,
30809 use12Hours = _props2.use12Hours;
30767 30810
30768 if (!showHour) { 30811 if (!showHour) {
30769 return null; 30812 return null;
30770 } 30813 }
30771 var disabledOptions = disabledHours(); 30814 var disabledOptions = disabledHours();
30815 var hourOptionsAdj = void 0;
30816 var hourAdj = void 0;
30817 if (use12Hours) {
30818 hourOptionsAdj = [12].concat(hourOptions.filter(function (h) {
30819 return h < 12 && h > 0;
30820 }));
30821 hourAdj = hour % 12 || 12;
30822 } else {
30823 hourOptionsAdj = hourOptions;
30824 hourAdj = hour;
30825 }
30772 30826
30773 return _react2.default.createElement(_Select2.default, { 30827 return _react2.default.createElement(_Select2.default, {
30774 prefixCls: prefixCls, 30828 prefixCls: prefixCls,
30775 options: hourOptions.map(function (option) { 30829 options: hourOptionsAdj.map(function (option) {
30776 return formatOption(option, disabledOptions); 30830 return formatOption(option, disabledOptions);
30777 }), 30831 }),
30778 selectedIndex: hourOptions.indexOf(hour), 30832 selectedIndex: hourOptionsAdj.indexOf(hourAdj),
30779 type: 'hour', 30833 type: 'hour',
30780 onSelect: this.onItemChange, 30834 onSelect: this.onItemChange,
30781 onMouseEnter: this.onEnterSelectPanel.bind(this, 'hour') 30835 onMouseEnter: this.onEnterSelectPanel.bind(this, 'hour')
@@ -30831,10 +30885,43 @@
30831 onMouseEnter: this.onEnterSelectPanel.bind(this, 'second') 30885 onMouseEnter: this.onEnterSelectPanel.bind(this, 'second')
30832 }); 30886 });
30833 }, 30887 },
30834 render: function render() { 30888 getAMPMSelect: function getAMPMSelect() {
30835 var _props5 = this.props, 30889 var _props5 = this.props,
30836 prefixCls = _props5.prefixCls, 30890 prefixCls = _props5.prefixCls,
30837 defaultOpenValue = _props5.defaultOpenValue; 30891 use12Hours = _props5.use12Hours,
30892 format = _props5.format;
30893
30894 if (!use12Hours) {
30895 return null;
30896 }
30897
30898 var AMPMOptions = ['am', 'pm'] // If format has A char, then we should uppercase AM/PM
30899 .map(function (c) {
30900 return format.match(/\sA/) ? c.toUpperCase() : c;
30901 }).map(function (c) {
30902 return { value: c };
30903 });
30904
30905 var selected = this.isAM() ? 0 : 1;
30906
30907 return _react2.default.createElement(_Select2.default, {
30908 prefixCls: prefixCls,
30909 options: AMPMOptions,
30910 selectedIndex: selected,
30911 type: 'ampm',
30912 onSelect: this.onItemChange,
30913 onMouseEnter: this.onEnterSelectPanel.bind(this, 'ampm')
30914 });
30915 },
30916 isAM: function isAM() {
30917 var value = this.props.value;
30918
30919 return value.hour() >= 0 && value.hour() < 12;
30920 },
30921 render: function render() {
30922 var _props6 = this.props,
30923 prefixCls = _props6.prefixCls,
30924 defaultOpenValue = _props6.defaultOpenValue;
30838 30925
30839 var value = this.props.value || defaultOpenValue; 30926 var value = this.props.value || defaultOpenValue;
30840 return _react2.default.createElement( 30927 return _react2.default.createElement(
@@ -30842,7 +30929,8 @@
30842 { className: prefixCls + '-combobox' }, 30929 { className: prefixCls + '-combobox' },
30843 this.getHourSelect(value.hour()), 30930 this.getHourSelect(value.hour()),
30844 this.getMinuteSelect(value.minute()), 30931 this.getMinuteSelect(value.minute()),
30845 this.getSecondSelect(value.second()) 30932 this.getSecondSelect(value.second()),
30933 this.getAMPMSelect(value.hour())
30846 ); 30934 );
30847 } 30935 }
30848 }); 30936 });
@@ -30940,7 +31028,7 @@
30940 var cls = (0, _classnames3.default)((_classnames = {}, (0, _defineProperty3.default)(_classnames, prefixCls + '-select-option-selected', selectedIndex === index), (0, _defineProperty3.default)(_classnames, prefixCls + '-select-option-disabled', item.disabled), _classnames)); 31028 var cls = (0, _classnames3.default)((_classnames = {}, (0, _defineProperty3.default)(_classnames, prefixCls + '-select-option-selected', selectedIndex === index), (0, _defineProperty3.default)(_classnames, prefixCls + '-select-option-disabled', item.disabled), _classnames));
30941 var onclick = null; 31029 var onclick = null;
30942 if (!item.disabled) { 31030 if (!item.disabled) {
30943 onclick = _this.onSelect.bind(_this, +item.value); 31031 onclick = _this.onSelect.bind(_this, item.value);
30944 } 31032 }
30945 return _react2.default.createElement( 31033 return _react2.default.createElement(
30946 'li', 31034 'li',
@@ -31101,7 +31189,8 @@
31101/* 268 */, 31189/* 268 */,
31102/* 269 */, 31190/* 269 */,
31103/* 270 */, 31191/* 270 */,
31104/* 271 */ 31192/* 271 */,
31193/* 272 */
31105/***/ function(module, exports, __webpack_require__, __webpack_module_template_argument_0__) { 31194/***/ function(module, exports, __webpack_require__, __webpack_module_template_argument_0__) {
31106 31195
31107 /* WEBPACK VAR INJECTION */(function(process) {/** 31196 /* WEBPACK VAR INJECTION */(function(process) {/**