aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
committerMG12 <wuzhao.mail@gmail.com>2015-12-14 00:50:41 +0800
commit71bd9bc11f2ca6068f7977ff3511b2798f73d0c6 (patch)
treee24404e929db29204fa008546377351d314f9480 /examples
parent0e62bf0b7bdc260e882fd185492939cbaed04d56 (diff)
downloadtime-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.gz
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.tar.zst
time-picker-71bd9bc11f2ca6068f7977ff3511b2798f73d0c6.zip
update disabled options
Diffstat (limited to 'examples')
-rw-r--r--examples/disabled.js34
-rw-r--r--examples/hidden.js6
2 files changed, 35 insertions, 5 deletions
diff --git a/examples/disabled.js b/examples/disabled.js
index 24d0068..633b8db 100644
--- a/examples/disabled.js
+++ b/examples/disabled.js
@@ -20,17 +20,47 @@ const formatter = new DateTimeFormat(str);
20const now = new GregorianCalendar(zhCn); 20const now = new GregorianCalendar(zhCn);
21now.setTime(Date.now()); 21now.setTime(Date.now());
22 22
23function generateOptions(length, excludedOptions) {
24 const arr = [];
25 for (let value = 0; value < length; value++) {
26 if (excludedOptions.indexOf(value) < 0) {
27 arr.push(value);
28 }
29 }
30 return arr;
31}
32
23function onChange(value) { 33function onChange(value) {
24 console.log(value && formatter.format(value)); 34 console.log(value && formatter.format(value));
25} 35}
26 36
37function disabledHours() {
38 return [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23];
39}
40
41function disabledMinutes(h) {
42 switch (h) {
43 case 9:
44 return generateOptions(60, [30]);
45 case 21:
46 return generateOptions(60, [0]);
47 default:
48 return generateOptions(60, [0, 30]);
49 }
50}
51
52function disabledSeconds(h, m) {
53 return [h + m % 60];
54}
55
27ReactDom.render( 56ReactDom.render(
28 <TimePicker formatter={formatter} locale={TimePickerLocale} 57 <TimePicker formatter={formatter} locale={TimePickerLocale}
29 showSecond={showSecond} 58 showSecond={showSecond}
30 defaultValue={now} 59 defaultValue={now}
31 className="xxx" 60 className="xxx"
32 onChange={onChange} 61 onChange={onChange}
33 disabledHours={[0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} 62 disabledHours={disabledHours}
34 disabledMinutes={[0, 2, 4, 6, 8]} />, 63 disabledMinutes={disabledMinutes}
64 disabledSeconds={disabledSeconds} />,
35 document.getElementById('__react-content') 65 document.getElementById('__react-content')
36); 66);
diff --git a/examples/hidden.js b/examples/hidden.js
index 1084236..da366cc 100644
--- a/examples/hidden.js
+++ b/examples/hidden.js
@@ -30,8 +30,8 @@ ReactDom.render(
30 defaultValue={now} 30 defaultValue={now}
31 className="xxx" 31 className="xxx"
32 onChange={onChange} 32 onChange={onChange}
33 disabledHours={[0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} 33 disabledHours={() => [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]}
34 disabledMinutes={[0, 2, 4, 6, 8]} 34 disabledMinutes={() => [0, 2, 4, 6, 8]}
35 hideDisabledOptions={true} />, 35 hideDisabledOptions />,
36 document.getElementById('__react-content') 36 document.getElementById('__react-content')
37); 37);