aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Select.jsx
diff options
context:
space:
mode:
authoryiminghe <yiminghe@gmail.com>2015-11-27 16:15:05 +0800
committeryiminghe <yiminghe@gmail.com>2015-11-27 16:15:05 +0800
commit8133e8cf3b37b2be764616493ade7c7a7678fce1 (patch)
tree4321352889ab62f18ff8703adac8756ddb506dc0 /src/module/Select.jsx
parent7702bb67968104a64fa85ba7e893bf2393eeb3c5 (diff)
downloadtime-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.tar.gz
time-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.tar.zst
time-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.zip
add gregorianCalendarLocale prop1.0.0-alpha1
Diffstat (limited to 'src/module/Select.jsx')
-rw-r--r--src/module/Select.jsx19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/module/Select.jsx b/src/module/Select.jsx
index 2b69623..be4c025 100644
--- a/src/module/Select.jsx
+++ b/src/module/Select.jsx
@@ -22,6 +22,7 @@ const Select = React.createClass({
22 propTypes: { 22 propTypes: {
23 prefixCls: PropTypes.string, 23 prefixCls: PropTypes.string,
24 options: PropTypes.array, 24 options: PropTypes.array,
25 gregorianCalendarLocale: PropTypes.object,
25 selectedIndex: PropTypes.number, 26 selectedIndex: PropTypes.number,
26 type: PropTypes.string, 27 type: PropTypes.string,
27 onSelect: PropTypes.func, 28 onSelect: PropTypes.func,
@@ -37,23 +38,19 @@ const Select = React.createClass({
37 this.scrollToSelected(200); 38 this.scrollToSelected(200);
38 }, 39 },
39 40
40 onSelect(event) { 41 onSelect(value) {
41 // do nothing when select selected option
42 if (event.target.getAttribute('class') === 'selected') {
43 return;
44 }
45 // change combobox selection
46 const { onSelect, type } = this.props; 42 const { onSelect, type } = this.props;
47 const value = parseInt(event.target.innerHTML, 10);
48 onSelect(type, value); 43 onSelect(type, value);
49 }, 44 },
50 45
51 getOptions() { 46 getOptions() {
52 const { options, selectedIndex } = this.props; 47 const { options, selectedIndex, prefixCls } = this.props;
53 return options.map((item, index) => { 48 return options.map((item, index) => {
54 const cls = classnames({ selected: selectedIndex === index}); 49 const selected = selectedIndex === index;
55 const ref = selectedIndex === index ? 'selected' : null; 50 const cls = classnames({
56 return <li ref={ref} className={cls} key={index} onClick={this.onSelect}>{item}</li>; 51 [`${prefixCls}-select-option-selected`]: selected,
52 });
53 return <li className={cls} key={index} onClick={this.onSelect.bind(this, +item)}>{item}</li>;
57 }); 54 });
58 }, 55 },
59 56