-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
2870 lines (2605 loc) · 147 KB
/
index.html
File metadata and controls
2870 lines (2605 loc) · 147 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta name="description" content="{페이지디스크립션내용}">
<meta name="keywords" content="{키워드내용}">
<meta property="og:url" content="{SNS 공유URL}">
<meta property="og:type" content="website">
<meta property="og:title" content="{SNS 공유제목}">
<meta property="og:description" content="{SNS 공유내용}">
<meta property="og:image" content="{SNS 공유이미지}">
<meta property="og:site_name" content="{SNS공유 사이트제목}">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:site" content="사이트명">
<meta property="twitter:title" content="{트위터공유제목}">
<meta property="twitter:description" content="{트위터공유내용}">
<meta property="twitter:image:src" content="{트위터공유이미지}">
<meta property="twitter:creator" content="{작성자}">
<!-- 오픈 그래프 종류? basic, optional, structured -->
<title>learn repository, 착한마크업- AOA11Y, VueTest.. my연습장 G:랑 합치는 중</title>
<link rel="canonical" href="{페이지대표URL}">
<script src="https://kit.fontawesome.com/30836814ad.js"></script>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
<!-- <script src="./jsontxt.js"></script> -->
<style>
/* 공통으로 사용할 클래스*/
.blind{
overflow:hidden;
position: absolute;
top:0; left:0;
width: 1px;
height:1px;
clip-path: rect(0 0 0 0);
margin:-1px;
border:0;
clip-path:inset(50%);
}
/* font-size test */
html {
font-size: 62.5%
}
body {
font-size: 16px
}
.section {
font-size: 200%;
}
.section > .article {
font-size: 4.44444vw
}
.article {
font-size: 1.8rem
}
ul {
margin-top: 2.8rem;
}
li:not(:last-child) {
background: coral;
margin-bottom: 2.8rem;
}
/* slide_acco */
.slide_acco .slide_dl button::after{
content:'';
position:absolute;
top:50%;
right:15px;
border: 10px solid #000;
border-right-color:transparent;
border-bottom-color:transparent;
border-left-color:transparent;
transform: translateY(-20%);
}
.slide_acco .slide_dl.open button::after{
content:'';
position:absolute;
top:50%;
right:15px;
border: 10px solid #000;
border-top-color:transparent;
border-right-color:transparent;
border-left-color:transparent;
transform: translateY(-80%);
}
.slide_acco .slide_dl{
border:1px solid #ddd;
}
.slide_acco dt button{
display:block;
position: relative;
width:100%;
padding:20px 15px;
background: #e4decf;
border:0;
text-align: left;
font-size:1.6rem;
text-decoration: none;
}
.slide_acco .slide_dl.open dd{display:block;}
.slide_acco .slide_dl dd{display: none; margin:0;}
.slide_acco dd ul{
margin:0;
padding:0;
list-style:none;
}
/* trigger 다시이해하기 */
.testEle {
width: 100px;
height: 100px;
background: #f80;
text-align: center;
color: #fff;
display: table-cell;
vertical-align: middle;
cursor: pointer;
}
#testEle2.testEle {
height: 24px;
background: #333;
}
/* size: cover, contain 반응형 test */
.rego1{ padding:10rem; background:url(https://www.shinhancard.com/pconts/images/dx/event/2022/220405_thepreview_evt_info_02.png) no-repeat left top / cover}
.rego2{ padding:10rem; background:url(https://www.shinhancard.com/pconts/images/dx/event/2022/220405_thepreview_evt_info_02.png) no-repeat left top / contain}
/* 이미지 반응형(배경) */
.lloggo_cover {
width: 70%;
}
.lloggo {
position: relative;
width: 100%;
height: 0;
padding-top: 16.9%;
background: url(https://www.shinhancard.com/pconts/images/common/shinhancard_logo.png) no-repeat left top / 100% auto;
}
/* 이미지 반응형(이미지) */
.item {
width: 50%
}
.item .logo {
overflow: hidden;
position: relative;
padding-top: 19.6%; /* 이미지 비율% */
border: 1px solid red;
}
.item .logo .img {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translate(50%, 50%);
border: 1px solid red;
}
.item .logo .img img {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
max-width: 100%;
height: 100%;
transform: translate(-50%, -50%);
border: 1px solid red;
}
#text-box{border:1px solid #f80}
/* 프린트모드에서 로고 히든처리 */
@media print {
.content_print {
display: none;
}
}
/* 키보드이벤트 key, code, keyCode 차이 */
#out {
border: 1px solid #333;
}
.clamp{width: clamp(280px, 70%, 800px); background: #f80;}
/* card */
.card{
display:flex;
flex-wrap:wrap;
border: 1px solid rgb(245, 201, 8);
}
.card .img{
flex:1 1 210px;
/* aspect-ratio: 1 / 1; ie 지원안함ㅋ*/
}
.card .img img{
max-width: 100%;
}
.card .content{
flex: 1 1 200px;
}
/* Alert Box */
.alert_box{display:none}
.alert_box.bg1{background-color:#f80}
.alert_box.bg2{background-color:#f09}
/* flex-container */
.flex-container {
display: flex;
flex-wrap: wrap;
}
.flex-item {
width: 33.33333%;
/* flex: 0 33.33333%; */
box-sizing: border-box;
padding: 5px;
color: white;
background: mediumseagreen;
}
.box {
width: 50vw;
background: red;
}
#menubar_wrapper{
height:200px;
text-align:center;
}
</style>
</head>
<body>
<header><h1>Javascript learn</h1></header>
<main>
<!-- <section>
<h2>scrollTo, scrollHeight test</h2>
<div id="menubar_wrapper">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate beatae dolorum facilis ducimus velit, molestias iure? Dolore, ducimus iure ut hic harum incidunt blanditiis autem sapiente ratione fugiat nulla
</div>
<script>
// location을 변수명으로 사용해서 파일이 자꾸 삭제 되었다고 오류남ㅠ
var loca = document.querySelector('#menubar_wrapper');
// window.scrollTo(0, document.body.scrollHeight); 스크롤과 요소 사이즈
loca.addEventListener('click', function(){
window.scrollBy(0, 100);
})
</script>
</section> -->
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<!-- <section>
<h2>load CORS error test</h2>
<div class="call"></div>
<script>
// $('.call').load('./focus_blur_effect.html') // live server로 열면 작동하고 로컬로 열면 CORS 에러남
</script>
</section> -->
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>active test</h2>
<div class="flex-container">
<div class="flex-item">Lorem, ipsum.</div>
<div class="flex-item">BOX
<!-- <div class="box">BOX</div> -->
</div>
<div class="flex-item">Lorem, ipsum dolor.</div>
<div class="flex-item">Lorem, ipsum.</div>
<div class="flex-item">B</div>
<div class="flex-item">Lorem, ipsum document color.</div>
</div>
<script>
/* Node list와 HTMLCollection의 차이 */
// * Node list는 .childesNodes *
// const container = document.querySelctor('.flex-container');
// container.childsNodes;
// const list = document.querySelectorAll('.flex-item')
// for(var i = 0; i < list.length; i++){
// // console.log(list[i].innerText);
// list[4].innerText="Change!";
// list[2].style.backgroundColor="black";
// list[2].style.color="White";
// list[0].classList.remove('flex-item'); // 0번 클래스 제거
// }
// * HTML Collection은 .children; *
// const list2 = document.getElementsByClassName('flex-item');
// for(var i = 0; i < list2.length; i++){
// // console.log(list2[i].innerText);
// list2[1].classList.remove('flex-item'); // 0~2번 클래스제거됨?
// list2[3].style.backgroundColor="darkblue"; //3~4번 배경색바뀜?
// }
// remove()노드를 없애는것-제거, hide() 보이지 않게 숨기는 것 -숨기기
</script>
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<!-- <section>
<h2>arccodion test</h2>
<div class="slide_acco">
<dl class="slide_dl open">
<dt><button type="button" aria-expanded="true" aria-controls="note1" id="acco1">유의사항</button><span class="blind">열기</span></dt>
<dd id="accNote1" aria-labelledby="acc1">
<ul>
<li>조아조아조아 완전 재미있엉</li>
<li>제이쿼리 다시하고</li>
<li>자스가자 고고고고</li>
<li>commodi officiis quia delectus nesciunt consequatur reprehenderit</li>
<li>sequi aliquid soluta pariatur, veritatis sint? Dolor, facere vero!</li>
</ul>
</dd>
</dl>
</div>
<script>
function slide(){
let accBtn = $('#acco1'),
accParent = accBtn.parents('.slide_dl'),
accBlind = accParent.find('.blind'),
accNote = $('#accNote1');
// $(document).off('click keydown', accBtn).on('click keydown', accBtn, (e)=>{
// e.preventDefault();
// $(accParent).toggleClass('open');
// $(accNote).slideToggle();
// if(accParent.hasClass('open')){
// // console.log('close')
// $(accBtn).attr('aria-expanded','false')
// $(accBlind).text('열기')
// }else{
// // console.log('open')
// $(accBtn).attr('aria-expanded','true')
// $(accBlind).text('닫기')
// }
// if(e.keyCode === 32){
// $(accParent).toggleClass('open');
// }else{
// $(accParent).removeClass('open');
// }
// });
}
slide();
(function(){
var accParent = document.querySelector('.slide_dl');
var accBtn = document.querySelector('#acco1');
var accBody = document.getElementById('accNote1');
var onAccParent = accParent.classList.contains('open');
// if(onAccParent == true){
// console.log('있다')
// accParent.classList.remove('open');
// } else {
// console.log('없다')
// accBtn.addEventListener('click', classAdd)
// accParent.classList.add('open');
// }
// function classAdd(){
// }
// function classRemove (){
// }
})();
// 1. dt안에 버튼을 누르면 dd가 보였다 안보였다 한다.(마우스&키보드spacebar) .slideToggle구현하기
// 2. 보이면 aria-expanded="true" 안보이면 "false"
// 3. 키보드로 (엔터+스페이스)키로 동작하게 함
// 4. 열기, 닫기 텍스트 변경
</script>
</section> -->
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>Alert</h2>
<!--(S) Alert Box -->
<div class="alert_box">
<p></p>
<button type="button" onclick="toggle('none')">Close</button>
</div>
<button type="button" onclick="toggle('block', '아이디를 입력하세요', 'bg1')">아이디</button>
<button type="button" onclick="toggle('block', '패스워드를 입력하세요', 'bg2')">패스워드</button>
<!-- 코딩애플 -->
<script>
// JavaScript를 사용하는 이유: html 조작과 변경을 위해서
// 길게 작성해야하는 이유: 컴퓨터에게 명확히 일을 시키기 위해서
// 파라미터를 사용하는 이유: 파라미터에 주는 값에 따라 다르게 보여줄 수 있다
function toggle(stat, txt, bg) {
document.querySelector('.alert_box').style.display = stat;
document.querySelector('.alert_box p').innerHTML = txt;
document.querySelector('.alert_box').className = `alert_box ${bg}`;
}
</script>
<!--(E) Alert Box -->
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<!-- <section>
<h2>font-size test</h2>
<div>body font size casading 16px</div>
<section class="section">
font size test 200% === 32px
<article class="article">
font size test 4.44444vw === 16px(viewport 360기준)
</article>
</section>
<article class="article">font size test 1.8rem === 18px (root font-size: 62.5%)</article>
</section> -->
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>textContent, innerHTML, innerText</h2>
<div class="list_wrap">
<ul>
<li class="item"><a href="javascript:;" class="list">nventore aspernatur consectetur.</a></li>
<li><a href="javascript:;" class="list">Lorem ipsum dolor sit amet elit.</a></li>
<li><a href="javascript:;" class="list">Facere autem assumenda beatae culpa cupiditate iusto.</a></li>
</ul>
<!-- href="javascript:output();" -->
<script>
const target = document.querySelectorAll('.list');
// console.log(target)// NodeList
const ele = [];
for (let i = 0; i < target.length; i++) {
ele.push({
title: target[i],
content: target[i].innerHTML = target[i],
})
}
ele[1].title.style.color = 'green';
let ele0 = ele[0].content.textContent = `<div>one(textContent)</div>`;
let ele1 = ele[1].content.innerHTML = `<div>two(innerHTML)</div>`;
let ele2 = ele[2].content.innerText = `<div>tree(innerText)</div>`;
</script>
</div>
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<!-- <section>
<h2>배경 또는 이미지 반응형</h2>
<div class="rego1">bg cover: 가로값 기준으로 채우기</div>
<div class="rego2">bg contain: 세로값 기준으로 채우기</div>
<div class="lloggo_cover">
<div class="lloggo"></div>
</div>
<div class="item">
<div class="logo">
<div class="img">
<img src="https://www.shinhancard.com/pconts/images/common/shinhancard_logo.png" alt="">
</div>
</div>
</div>
</section> -->
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>키보드이벤트 key, code, keyCode</h2>
<div id="text-box">
<p>키보드의 키를 눌러 키보드 이벤트의 키와 코드 값이 각각 무엇인지 확인합니다.</p>
<div id="out"></div>
</div>
<!--
KeyboardEvent.code속성은 키보드의 물리적 키를 나타냅니다
Browser compatibility - IE는 지원하지 않습니다
value - OS마다 나오는 코드
keyboardEvent.key 속성은 키 이벤트에 해당하는 문자를 나타냅니다
Browser compatibility - FF안드로이드, FF, IE Dead key는 지원하지 않습니다
value - 문자열
KeyboardEvent.keyCode
웹 표준에서 이미 제거되었거나 삭제 과정에 있거나 호환성 목적으로만 유지
.key, .code가 일부브라우저 지원이 되지 않으므로 조건문으로 .key또는 .code가 인식되지 않는 경우에 같이 사용하도록함
-->
<script>
// 키보드이벤트 key, code, keyCode 차이
// window.addEventListener("keydown", function (event) {
// const p = document.createElement("p");
// event.preventDefault();
// p.textContent = `KeyboardEvent: key='${event.key}' | code='${event.code}' | keyCode='${event.keyCode}'`;
// document.getElementById("out").appendChild(p);
// }, true);
// window.addEventListener("keydown", function (event) {
// if (event.defaultPrevented) {
// return; // Should do nothing if the default action has been cancelled
// }
// var handled = false;
// if (event.key !== undefined) {
// // Handle the event with KeyboardEvent.key and set handled true.
// } else if (event.keyCode !== undefined) {
// // Handle the event with KeyboardEvent.keyCode and set handled true.
// }
// if (handled) {
// // Suppress "double action" if event handled
// event.preventDefault();
// }}, true);
</script>
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>프린트모드에서 로고 히든처리</h2>
<img class="img content_print" src="https://www.shinhancard.com/pconts/images/common/shinhancard_logo.png" alt="">
<button class="btn1" type="button">btn1</button>
<!-- @media print를 사용하는게 더 효율적 -->
<script>
// 프린트모드에서 로고 히든처리
window.addEventListener('load', function () {
const printLogo = document.querySelector('.content_print');// print모드에만 있는 클래스 선택
const printBody = document.body;
const btn1 = document.querySelector('.btn1');
btn1.addEventListener('click', function () {
printBody.removeChild(printLogo);
})
});
</script>
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<h2>접근성시작 1</h2>
<header>
<!-- header대신 div로 작업하는 경우에는 role="banner"속성을 활용한다 -->
<button title="메뉴오픈" aria-label="메뉴 열기">
<!-- aria-label속성이 있으면 보조기기는 내부텍스트, title 속성을 안읽어줌 -->
완전메뉴<span>></span>
</button>
<nav>
<h2>메인 메뉴</h2>
<ul>
<li></li>
</ul>
<button title="메뉴클로즈" aria-label="메뉴 닫기">
<span aria-hidden="true">X<!-- 읽어 주지 않음 --></span>
</button>
</nav>
</header>
<main>
<!-- main 대신 div로 작업하는 경우에는 role="main"속성을 활용한다 -->
<ul>
<li>
<a role="button" aria-haspopup="dialog" aria-pressed="false">
<!-- 의미상 버튼이 맞지만 표준에 맞지 않아 a태그로 수정 후 role="button" -->
<!--
aria-haspopup="dialog" - 버튼을 누르면 다이어로그팝업이 나오는 것을 알림
aria-pressed="false" - 버튼이 눌렸는지에 대한 상태를 알림
-->
<figure>
<img src="http://placehold.it/200x200" alt="임시이미지">
<figcaption>제품에 대한 자세한 설명글</figcaption>
</figure>
</a>
<div role="dialog" aria-modal="true" aria-labelledby="dialog1Title">
<h3 id="dialog1Title">제품<span lang="en">Product</span></h3>
<p style=" width:50%; word-break: break-all">제품설명 신한카드 공식쇼핑몰 올댓쇼핑 상품권부터 사무용품, 골프용품 까지 법인카드로, 법인포인트로 전 상품 구매가 가능합니다.blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah</p>
<dl>
<dt>포화지방</dt>
<dd>(1.8g)</dd>
</dl>
<button type="button" aria-label="정보 패널 닫기" title="닫기"><span aria-hidden="true">X</span></button>
</div>
</li>
</ul>
</main>
<footer>
<!-- footer 대신 div로 작업하는 경우에는 role="contentinfo"속성을 활용한다 -->
</footer>
<h2>필수입력안내 aria-required</h2>
<div class=“id-area”>
<label for=“user-email”>아이디</label>
<input type=“email” id=“user-email” aria-required=“true”>
<!--
보이스오버:
NVDA: 아이디 편집창 필요함 빈줄
-->
</div>
<h2>초점접근테스트</h2>
<p>aria-hidden은 보조기기 접근여부를 컨트롤 하는 속성이고 tabindex는 초점접근 컨트롤 요소이기에 aria-hidden이 있어도 초점 접근이 가능함</p>
<div id="skipNavi" aria-hidden="true">
<a href="javascript:;">본문바로가기</a>
</div>
</section>
<hr style="margin-top:1rem; margin-bottom:1rem; border-color:#f09;">
<section>
<div class="ly_inner">
<style>
.listbox-area {
display: grid;
grid-gap: 2em;
grid-template-columns: repeat(2, 1fr);
padding: 20px;
border: 1px solid #aaa;
border-radius: 4px;
background: #eee;
}
[role="listbox"] {
margin: 1em 0 0;
padding: 0;
min-height: 18em;
border: 1px solid #aaa;
background: white;
}
[role="listbox"]#ss_elem_list {
position: relative;
max-height: 18em;
overflow-y: auto;
}
[role="listbox"] + *,
.listbox-label + * {
margin-top: 1em;
}
[role="group"] {
margin: 0;
padding: 0;
}
[role="group"] > [role="presentation"] {
display: block;
margin: 0;
padding: 0 0.5em;
font-weight: bold;
line-height: 2;
background-color: #ccc;
}
[role="option"] {
position: relative;
display: block;
margin: 2px;
padding: 2px 1em 2px 1.5em;
line-height: 1.8em;
cursor: pointer;
}
[role="listbox"]:focus [role="option"].focused {
background: #bde4ff;
}
[role="listbox"]:focus [role="option"].focused,
[role="option"]:hover {
outline: 2px solid currentcolor;
}
.move-right-btn span.checkmark::after {
content: " →";
}
.move-left-btn span.checkmark::before {
content: "← ";
}
[role="option"][aria-selected="true"] span.checkmark::before {
position: absolute;
left: 0.5em;
content: "✓";
}
button[aria-haspopup="listbox"] {
position: relative;
padding: 5px 10px;
width: 150px;
border-radius: 0;
text-align: left;
}
button[aria-haspopup="listbox"]::after {
position: absolute;
right: 5px;
top: 10px;
width: 0;
height: 0;
border: 8px solid transparent;
border-top-color: currentcolor;
border-bottom: 0;
content: "";
}
button[aria-haspopup="listbox"][aria-expanded="true"]::after {
position: absolute;
right: 5px;
top: 10px;
width: 0;
height: 0;
border: 8px solid transparent;
border-top: 0;
border-bottom-color: currentcolor;
content: "";
}
button[aria-haspopup="listbox"] + [role="listbox"] {
position: absolute;
margin: 0;
width: 9.5em;
max-height: 10em;
border-top: 0;
overflow-y: auto;
}
[role="toolbar"] {
display: flex;
}
[role="toolbar"] > * {
border: 1px solid #aaa;
background: #ccc;
}
[role="toolbar"] > [aria-disabled="false"]:focus {
background-color: #eee;
}
button {
font-size: inherit;
}
button[aria-disabled="true"] {
opacity: 0.5;
}
.annotate {
color: #366ed4;
font-style: italic;
}
.hidden {
display: none;
}
.offscreen {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(1px 1px 1px 1px);
clip: rect(1px, 1px, 1px, 1px);
font-size: 14px;
white-space: nowrap;
}
</style>
<h2>리스트박스확인중</h2>
<div class="listbox-area">
<div>
<span id="ss_elem" class="listbox-label">Transuranium elements:</span>
<ul id="ss_elem_list" tabindex="0" role="listbox" aria-labelledby="ss_elem">
<li id="ss_elem_Cf" role="option" aria-selected="true">
<a href="javascript:;" role="button">
<span class="checkmark" aria-hidden="true"></span>
Californium</a>
</li>
<li id="ss_elem_Es" role="option" aria-selected="false">
<a href="javascript:;" role="button">
<span class="checkmark" aria-hidden="true"></span>
Einsteinium</a>
</li>
<li id="ss_elem_Hs" role="option" aria-selected="false">
<a href="javascript:;" role="button">
<span class="checkmark" aria-hidden="true"></span>
Hassium</a>
</li>
<li id="ss_elem_Mt" role="option" aria-selected="false">
<a href="javascript:;" role="button">
<span class="checkmark" aria-hidden="true"></span>
Meitnerium</a>
</li>
</ul>
</div>
</div>
<!-- <script>
/*
* This content is licensed according to the W3C Software License at
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/
'use strict';
/**
* @namespace aria
* @description
* The aria namespace is used to support sharing class definitions between example files
* without causing eslint errors for undefined classes
*/
var aria = aria || {};
/**
* @class
* @description
* Listbox object representing the state and interactions for a listbox widget
* @param listboxNode
* The DOM node pointing to the listbox
*/
aria.Listbox = class Listbox {
constructor(listboxNode) {
this.listboxNode = listboxNode;
this.activeDescendant = this.listboxNode.getAttribute(
'aria-activedescendant'
);
this.multiselectable = this.listboxNode.hasAttribute(
'aria-multiselectable'
);
this.moveUpDownEnabled = false;
this.siblingList = null;
this.startRangeIndex = 0;
this.upButton = null;
this.downButton = null;
this.moveButton = null;
this.keysSoFar = '';
this.handleFocusChange = function () { };
this.handleItemChange = function () { };
this.registerEvents();
}
registerEvents() {
this.listboxNode.addEventListener('focus', this.setupFocus.bind(this));
this.listboxNode.addEventListener('keydown', this.checkKeyPress.bind(this));
this.listboxNode.addEventListener('click', this.checkClickItem.bind(this));
if (this.multiselectable) {
this.listboxNode.addEventListener(
'mousedown',
this.checkMouseDown.bind(this)
);
}
}
setupFocus() {
if (this.activeDescendant) {
const listitem = document.getElementById(this.activeDescendant);
listitem.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
}
focusFirstItem() {
var firstItem = this.listboxNode.querySelector('[role="option"]');
if (firstItem) {
this.focusItem(firstItem);
}
}
focusLastItem() {
const itemList = this.listboxNode.querySelectorAll('[role="option"]');
if (itemList.length) {
this.focusItem(itemList[itemList.length - 1]);
}
}
checkKeyPress(evt) {
const lastActiveId = this.activeDescendant;
const allOptions = this.listboxNode.querySelectorAll('[role="option"]');
const currentItem =
document.getElementById(this.activeDescendant) || allOptions[0];
let nextItem = currentItem;
if (!currentItem) {
return;
}
switch (evt.key) {
case 'PageUp':
case 'PageDown':
evt.preventDefault();
if (this.moveUpDownEnabled) {
if (evt.key === 'PageUp') {
this.moveUpItems();
} else {
this.moveDownItems();
}
}
break;
case 'ArrowUp':
case 'ArrowDown':
evt.preventDefault();
if (!this.activeDescendant) {
// focus first option if no option was previously focused, and perform no other actions
this.focusItem(currentItem);
break;
}
if (this.moveUpDownEnabled && evt.altKey) {
evt.preventDefault();
if (evt.key === 'ArrowUp') {
this.moveUpItems();
} else {
this.moveDownItems();
}
this.updateScroll();
return;
}
if (evt.key === 'ArrowUp') {
nextItem = this.findPreviousOption(currentItem);
} else {
nextItem = this.findNextOption(currentItem);
}
if (nextItem && this.multiselectable && event.shiftKey) {
this.selectRange(this.startRangeIndex, nextItem);
}
if (nextItem) {
this.focusItem(nextItem);
}
break;
case 'Home':
evt.preventDefault();
this.focusFirstItem();
if (this.multiselectable && evt.shiftKey && evt.ctrlKey) {
this.selectRange(this.startRangeIndex, 0);
}
break;
case 'End':
evt.preventDefault();
this.focusLastItem();
if (this.multiselectable && evt.shiftKey && evt.ctrlKey) {
this.selectRange(this.startRangeIndex, allOptions.length - 1);
}
break;
case 'Shift':
this.startRangeIndex = this.getElementIndex(currentItem, allOptions);
break;
case ' ':
evt.preventDefault();
this.toggleSelectItem(nextItem);
break;
case 'Backspace':
case 'Delete':
case 'Enter':
if (!this.moveButton) {
return;
}
var keyshortcuts = this.moveButton.getAttribute('aria-keyshortcuts');
if (evt.key === 'Enter' && keyshortcuts.indexOf('Enter') === -1) {
return;
}
if (
(evt.key === 'Backspace' || evt.key === 'Delete') &&
keyshortcuts.indexOf('Delete') === -1
) {
return;
}
evt.preventDefault();
var nextUnselected = nextItem.nextElementSibling;
while (nextUnselected) {
if (nextUnselected.getAttribute('aria-selected') != 'true') {
break;
}
nextUnselected = nextUnselected.nextElementSibling;
}
if (!nextUnselected) {
nextUnselected = nextItem.previousElementSibling;
while (nextUnselected) {
if (nextUnselected.getAttribute('aria-selected') != 'true') {
break;
}