forked from roy-tian/learning-area
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,095 changed files
with
57,288 additions
and
1,699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 社区参与准则 | ||
|
||
本代码仓库遵守「Mozilla 行为守则和道德规范」。更多信息请阅读 [Mozilla 社区参与准则](https://www.mozilla.org/about/governance/policies/participation/) 。 | ||
|
||
## 如何举报 | ||
|
||
请举报违反社区参与准则的行为,更多信息请参考 [如何举报](https://www.mozilla.org/about/governance/policies/participation/reporting/) 页面。 | ||
|
||
<!-- | ||
## 特定项目规范 | ||
某些项目需要额外规范约束。如 (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html)。 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>ARIA div buttons</title> | ||
<style> | ||
div { | ||
background-color: rgb(240, 240, 240); | ||
font-size: 11px; | ||
font-family: sans-serif; | ||
border: 1px outset rgb(218, 218, 218); | ||
line-height: 20px; | ||
padding: 0 6px; | ||
width: 120px; | ||
text-align: center; | ||
border-radius: 5px; | ||
margin-right: 10px; | ||
cursor: pointer; | ||
display: inline-block; | ||
} | ||
|
||
div:hover, div:focus { | ||
font-weight: bold; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h2>ARIA div buttons</h2> | ||
|
||
<div data-message="This is from the first button" tabindex="0" role="button">Click me!</div> | ||
<div data-message="This is from the second button" tabindex="0" role="button">Click me too!</div> | ||
<div data-message="This is from the third button" tabindex="0" role="button">And me!</div> | ||
|
||
<script> | ||
const buttons = document.querySelectorAll('div'); | ||
|
||
for(let i = 0; i < buttons.length; i++) { | ||
addHandler(buttons[i]); | ||
} | ||
|
||
function addHandler(button) { | ||
button.onclick = function(e) { | ||
let message = e.target.getAttribute('data-message'); | ||
alert(message); | ||
} | ||
} | ||
|
||
document.onkeydown = function(e) { | ||
if(e.keyCode === 13) { // The Enter/Return key | ||
document.activeElement.onclick(e); | ||
} | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>Random quotes</title> | ||
|
||
<style> | ||
html { | ||
font-family: sans-serif; | ||
} | ||
|
||
h1 { | ||
letter-spacing: 2px; | ||
} | ||
|
||
p { | ||
line-height: 1.6; | ||
} | ||
|
||
section { | ||
padding: 10px; | ||
width: 400px; | ||
background: #666; | ||
text-shadow: 1px 1px 1px black; | ||
color: white; | ||
min-height: 150px; | ||
} | ||
|
||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<section aria-live="assertive" aria-atomic="true"> | ||
<h1>Random quote</h1> | ||
<blockquote> | ||
<p></p> | ||
</blockquote> | ||
</section> | ||
<script> | ||
const quotePara = document.querySelector('section p'); | ||
|
||
let quoteJson; | ||
|
||
getQuotes('quotes.json', populateJson); | ||
|
||
let intervalID = window.setInterval(showQuote, 10000); | ||
|
||
function getQuotes(url, callback) { | ||
let request = new XMLHttpRequest(); | ||
request.open('GET', url); | ||
request.responseType = 'json'; | ||
request.send(); | ||
|
||
request.onreadystatechange = function() { | ||
if (request.readyState === 4 && request.status === 200) { | ||
callback(request.response); | ||
} | ||
}; | ||
} | ||
|
||
function populateJson(response) { | ||
quoteJson = response; | ||
} | ||
|
||
function showQuote() { | ||
let random = Math.floor((Math.random()*25)); | ||
quotePara.textContent = quoteJson[random].quote + ' -- ' + quoteJson[random].author; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>Random quotes</title> | ||
|
||
<style> | ||
html { | ||
font-family: sans-serif; | ||
} | ||
|
||
h1 { | ||
letter-spacing: 2px; | ||
} | ||
|
||
p { | ||
line-height: 1.6; | ||
} | ||
|
||
section { | ||
padding: 10px; | ||
width: 400px; | ||
background: #666; | ||
text-shadow: 1px 1px 1px black; | ||
color: white; | ||
min-height: 150px; | ||
} | ||
|
||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<section> | ||
<h1>Random quote</h1> | ||
<blockquote> | ||
<p></p> | ||
</blockquote> | ||
</section> | ||
<script> | ||
const quotePara = document.querySelector('section p'); | ||
|
||
let quoteJson; | ||
|
||
getQuotes('quotes.json', populateJson); | ||
|
||
let intervalID = window.setInterval(showQuote, 10000); | ||
|
||
function getQuotes(url, callback) { | ||
let request = new XMLHttpRequest(); | ||
request.open('GET', url); | ||
request.responseType = 'json'; | ||
request.send(); | ||
|
||
request.onreadystatechange = function() { | ||
if (request.readyState === 4 && request.status === 200) { | ||
callback(request.response); | ||
} | ||
}; | ||
} | ||
|
||
function populateJson(response) { | ||
quoteJson = response; | ||
} | ||
|
||
function showQuote() { | ||
var random = Math.floor((Math.random()*25)); | ||
quotePara.textContent = quoteJson[random].quote + ' -- ' + quoteJson[random].author; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>ARIA tabbed info box</title> | ||
<style> | ||
|
||
/* General setup */ | ||
|
||
html { | ||
font-family: sans-serif; | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
/* info-box setup */ | ||
|
||
.info-box { | ||
width: 450px; | ||
height: 400px; | ||
margin: 0 auto; | ||
} | ||
|
||
/* styling info-box tabs */ | ||
|
||
ul[role="tablist"] { | ||
padding-left: 0; | ||
margin-top: 0; | ||
} | ||
|
||
li[role="tab"] { | ||
float: left; | ||
list-style-type: none; | ||
width: 150px; | ||
display: inline-block; | ||
line-height: 3; | ||
background-color: red; | ||
color: black; | ||
text-align: center; | ||
} | ||
|
||
li[role="tab"]:focus, li[role="tab"]:hover { | ||
background-color: #a60000; | ||
color: white; | ||
} | ||
|
||
li[role="tab"].active { | ||
background-color: #a60000; | ||
color: white; | ||
} | ||
|
||
/* styling info-box panels */ | ||
|
||
.info-box .panels { | ||
clear: both; | ||
position: relative; | ||
height: 352px; | ||
} | ||
|
||
.info-box article { | ||
background-color: #a60000; | ||
color: white; | ||
position: absolute; | ||
padding: 10px; | ||
height: 352px; | ||
top: 0; | ||
left: 0; | ||
} | ||
|
||
.info-box .active-panel { | ||
z-index: 1; | ||
} | ||
|
||
|
||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<section class="info-box"> | ||
<ul role="tablist"> | ||
<li class="active" role="tab" aria-selected="true" aria-setsize="3" aria-posinset="1" tabindex="0">Tab 1</li> | ||
<li role="tab" aria-selected="false" aria-setsize="3" aria-posinset="2" tabindex="0">Tab 2</li> | ||
<li role="tab" aria-selected="false" aria-setsize="3" aria-posinset="3" tabindex="0">Tab 3</li> | ||
</ul> | ||
<div class="panels"> | ||
<article class="active-panel" role="tabpanel" aria-hidden="false"> | ||
<h2>The first tab</h2> | ||
|
||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in augue. Vestibulum et orci scelerisque, vulputate tellus quis, lobortis dui. Vivamus varius libero at ipsum mattis efficitur ut nec nisl. Nullam eget tincidunt metus. Donec ultrices, urna maximus consequat aliquet, dui neque eleifend lorem, a auctor libero turpis at sem. Aliquam ut porttitor urna. Nulla facilisi.</p> | ||
</article> | ||
<article role="tabpanel" aria-hidden="true"> | ||
<h2>The second tab</h2> | ||
|
||
<p>This tab hasn't got any Lorem Ipsum in it. But the content isn't very exciting all the same.</p> | ||
</article> | ||
<article role="tabpanel" aria-hidden="true"> | ||
<h2>The third tab</h2> | ||
|
||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in augue. And now an ordered list: how exciting!</p> | ||
|
||
<ol> | ||
<li>dui neque eleifend lorem, a auctor libero turpis at sem.</li> | ||
<li>Aliquam ut porttitor urna.</li> | ||
<li>Nulla facilisi</li> | ||
</ol> | ||
</article> | ||
</div> | ||
</section> | ||
|
||
<script> | ||
|
||
let tabs = document.querySelectorAll('.info-box li'); | ||
let panels = document.querySelectorAll('.info-box article'); | ||
|
||
for(let i = 0; i < tabs.length; i++) { | ||
let tab = tabs[i]; | ||
setTabHandler(tab, i); | ||
} | ||
|
||
function setTab(e) { | ||
if(e.type === 'keypress' && e.keyCode !== 13) { | ||
return; | ||
} | ||
|
||
let tabPos = Number(this.getAttribute('aria-posinset'))-1; | ||
for(let i = 0; i < tabs.length; i++) { | ||
if(tabs[i].getAttribute('class')) { | ||
tabs[i].removeAttribute('class'); | ||
} | ||
|
||
tabs[i].setAttribute('aria-selected', 'false'); | ||
} | ||
|
||
this.setAttribute('class', 'active'); | ||
this.setAttribute('aria-selected', 'true'); | ||
|
||
for(let i = 0; i < panels.length; i++) { | ||
if(panels[i].getAttribute('class')) { | ||
panels[i].removeAttribute('class'); | ||
} | ||
|
||
panels[i].setAttribute('aria-hidden', 'true'); | ||
} | ||
|
||
panels[tabPos].setAttribute('class', 'active-panel'); | ||
panels[tabPos].setAttribute('aria-hidden', 'false'); | ||
} | ||
|
||
function setTabHandler(tab) { | ||
tab.addEventListener('click', setTab); | ||
tab.addEventListener('keypress', setTab); | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.