Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add carousel example #958

Merged
merged 66 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9e304a1
update button example
jongund Mar 18, 2017
4e59e79
fixed references to external file
jongund Mar 27, 2017
76ff0ed
added auto rebase
jongund Mar 27, 2017
75a87f2
Merge branch 'master' of https://github.com/jongund/aria-practices
jongund May 24, 2018
0df77d2
removed gitcongif file
jongund Jun 27, 2018
a311e7d
Issue 43: Initial draft of carousel pattern (pull #829)
jongund Aug 21, 2018
4de2a50
Issue 458: First cut of Auto rotating image carousel example (pull #828)
jongund Aug 21, 2018
9f3105e
Merge remote-tracking branch 'w3c/master'
jongund Oct 1, 2018
c05d0f4
Merge remote-tracking branch 'w3c/master'
jongund Oct 5, 2018
7b2abc0
Merge remote-tracking branch 'w3c/master'
jongund Oct 8, 2018
b1d7d89
added feature
jongund Oct 8, 2018
1fad2b3
Merge remote-tracking branch 'w3c/master'
jongund Oct 10, 2018
f685318
update design pattern for carousel
jongund Nov 15, 2018
cecadd5
updated examples
jongund Nov 15, 2018
b5c3f12
update carousel 1 example
jongund Nov 15, 2018
ec7922b
updated carousel example
jongund Nov 16, 2018
0326934
updated carousel example
jongund Nov 16, 2018
5503d5c
updated carousel 2 example
jongund Nov 16, 2018
7f80c53
updated carousel 2 example
jongund Nov 16, 2018
49699de
Merge branch 'master' into w3c/carousel
jongund Nov 26, 2018
21e43f6
Merge pull request #945 from jongund/w3c/carousel
mcking65 Dec 4, 2018
7d008e8
Updated from master
jongund Dec 6, 2018
852757b
fixed liter problems and added two initial regression tests for each …
jongund Dec 6, 2018
f5f6098
Merge branch 'master' into carousel-v2
mcking65 Dec 7, 2018
8c73bf2
Merge branch 'master' into carousel-v2
mcking65 Dec 12, 2018
8090c27
Revise first paragraph; define carousel; remove implementation details.
mcking65 Dec 12, 2018
086b7ed
revise para2 of description
mcking65 Dec 12, 2018
79577e6
Add placeholder folders and files
mcking65 Dec 12, 2018
cf9675a
Merge branch 'master' into carousel-v2
jongund Dec 17, 2018
2e0e351
Merge branch 'carousel-v2' of https://github.com/w3c/aria-practices i…
jongund Dec 17, 2018
04f01c5
caoursel example 1 intitial commit
jongund Dec 17, 2018
9f24087
fixed file conflict
jongund Dec 17, 2018
3f42c92
fixed conflicts with eafult files
jongund Dec 17, 2018
3fd5fb8
fixed css bug
jongund Dec 17, 2018
5944371
added issue that this example is tracked
jongund Dec 17, 2018
d1826d3
added issue that this example is tracked
jongund Dec 17, 2018
984f561
Remove carousel pattern from aria-practices. It will be provided by t…
mcking65 Dec 18, 2018
4f10d3f
updated example based on working group feedback
jongund Dec 19, 2018
d274063
Merge branch 'issue458-add-carousel-example' of https://github.com/w3…
jongund Dec 19, 2018
225ddd6
updated documentation
jongund Dec 19, 2018
6a8ca2d
Fix related issues link in top nav
mcking65 Dec 20, 2018
dcb5491
first testing
a11ydoer Dec 20, 2018
80bb7a9
add data test id
a11ydoer Dec 26, 2018
508c6e4
add/specify data test id
a11ydoer Dec 26, 2018
22f8a3c
Merge branch 'master' into issue458-add-carousel-example
jongund Jan 2, 2019
23b5e45
updated regression test to pass
jongund Jan 2, 2019
12ae431
added a few more tests for slide containers
jongund Jan 2, 2019
6849676
added roledescription to region and added tests for roledescription a…
jongund Jan 7, 2019
b075d92
removed unused functions from test file
jongund Jan 7, 2019
a8708cf
Editorial revisions to description and accessibility features
mcking65 Jan 10, 2019
895c392
updated pause button behavior
jongund Jan 10, 2019
4c02084
updated pause button behavior
jongund Jan 10, 2019
69b3c63
Revised accessibility features section
mcking65 Jan 10, 2019
dc8209f
updated pause button behavior
jongund Jan 10, 2019
b88e550
Merge branch 'issue458-add-carousel-example' of https://github.com/w3…
jongund Jan 10, 2019
454be99
fixed some bugs
jongund Jan 11, 2019
1c17596
updated pause button label
jongund Jan 11, 2019
b263172
updated h2s to h3s, changed from using disable dproperty to aria-disa…
jongund Jan 11, 2019
797dc9f
fixed code validation bug
jongund Jan 11, 2019
c72a34d
improved hover styling of previos and next slide buttons
jongund Jan 11, 2019
30b6ed8
Revisions to keyboard, role, state, and property documentation
mcking65 Jan 11, 2019
061dcb6
minor editorial/formatting changes
charmarkk Jan 11, 2019
3d920fc
Editorial revision to accessibility features
mcking65 Jan 12, 2019
c275dff
Apply suggestions from code review
jnurthen Jan 12, 2019
1379c52
removed aria-describedby from each slide
jongund Jan 14, 2019
7d36e09
Add link to review issue and minor editorial revision to aria-disable…
mcking65 Jan 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
533 changes: 533 additions & 0 deletions examples/carousel/carousel-1/carousel-1.html

Large diffs are not rendered by default.

178 changes: 178 additions & 0 deletions examples/carousel/carousel-1/css/carousel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@

/*.carousel*/
.carousel-item {
display: none;
max-height: 400px;
max-width: 900px;
position: relative;
overflow: hidden;
width: 100%;
}

.carousel .carousel-item.active {
display: block;
}

/* More like bootstrap, less accessible*/

.carousel .carousel-inner {
max-width: 900px;
position: relative;
}

.carousel button.pause {
display: block;
font-size: 20px;
width: auto;
left: -300em;
margin-bottom: 10px;
height: auto;
position: relative;
top: 5px;
right: -20px;
border: thin solid outset;
}

.carousel button[aria-disabled=true] {
color: #666;
}

.carousel button.pause:focus{
display: block;
position: relative;
font-size: 20px;
width: auto;
left: 0px;
margin-bottom: 10px;
height: auto;
position: relative;
top: 5px;
right: -20px;
}

.carousel .carousel-items {
border: solid 2px transparent;
}

.carousel .carousel-items.focus {
border-color: white;
outline: solid 3px #005A9C;
}

.carousel .carousel-inner .carousel-image a img {
height: 100%;
width: 100%;
}

.carousel .carousel-inner .carousel-caption a {
text-decoration: underline;
border: none;
}

.carousel .carousel-inner .carousel-caption a:focus,
.carousel .carousel-inner .carousel-caption a:hover {
outline: solid 2px #FFF;
outline-offset: 1px;
}

.carousel .carousel-inner .carousel-caption h3 a {
color: #fff;
font-weight: 600;
}

.carousel .carousel-inner .carousel-caption p {
font-size: 1em;
line-height: 1.5;
margin-bottom: 0;
}

.carousel .carousel-inner .carousel-caption {
bottom: 0;
left: 0;
padding: 3% 3% 50px;
right: 0;
text-shadow: none
}

.carousel:hover .carousel-inner .carousel-caption,
.carousel .carousel-item.focus .carousel-caption {
background-color: rgba(0, 0, 0, 0.4);
}

.carousel .carousel-caption {
position: absolute;
right: 15%;
bottom: 0px;
left: 15%;
padding-top: 20px;
padding-bottom: 20px;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.carousel .carousel-inner,
.carousel .carousel-item,
.carousel .carousel-slide {
max-height: 400px;
}

.carousel .carousel-control {
position: absolute;
top: 0;
z-index: 10;
font-size: 200%;
font-weight: bold;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.carousel a.carousel-control svg {
position: relative;
display: inline-block;
top: 45%;
}

.carousel a.carousel-control svg polygon {
opacity: 0.7;
}

.carousel a.carousel-control:focus {
border: 3px solid #FFF;
outline: 1px solid #005A9C;
}

.carousel a.carousel-control:focus svg polygon,
.carousel a.carousel-control:hover svg polygon {
opacity: 1.0;
}

.carousel a.carousel-control.previous {
bottom: 0;
width: 15%;
background-image: linear-gradient(to right,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);
}

.carousel a.carousel-control.previous:focus,
.carousel a.carousel-control.previous:hover {
bottom: 0;
width: 15%;
background-image: linear-gradient(to right,rgba(0,0,0,.7) 0,rgba(0,0,0,.0001) 100%);
}

.carousel a.carousel-control.next {
right: 0;
bottom: 0;
width: 15%;
background-image: linear-gradient(to right,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);
}

.carousel a.carousel-control.next:focus,
.carousel a.carousel-control.next:hover {
right: 0;
bottom: 0;
width: 15%;
background-image: linear-gradient(to right,rgba(0,0,0,.0001) 0,rgba(0,0,0,.7) 100%);
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
220 changes: 220 additions & 0 deletions examples/carousel/carousel-1/js/carousel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* File: Carousel.js
*
* Desc: Carousel widget that implements ARIA Authoring Practices
*
*/

/*
* @constructor CarouselTablist
*
*
*/
var Carousel = function (domNode) {
this.domNode = domNode;

this.items = [];

this.firstItem = null;
this.lastItem = null;
this.currentDomNode = null;
this.liveRegionNode = null;
this.currentItem = null;
this.pauseButton = null;

this.startLabel = 'Start automatic slide show';
this.stopLabel = 'Stop automatic slide show';

this.rotate = true;
this.hasFocus = false;
this.hasHover = false;
this.isStopped = false;
this.timeInterval = 5000;
};

Carousel.prototype.init = function () {

this.liveRegionNode = this.domNode.querySelector('.carousel-items');

var items = this.domNode.querySelectorAll('.carousel-item');

for (var i = 0; i < items.length; i++) {
var item = new CarouselItem(items[i], this);

item.init();
this.items.push(item);

if (!this.firstItem) {
this.firstItem = item;
this.currentDomNode = item.domNode;
}
this.lastItem = item;

var imageLinks = items[i].querySelectorAll('.carousel-image a');

if (imageLinks && imageLinks[0]) {
imageLinks[0].addEventListener('focus', this.handleImageLinkFocus.bind(this));
imageLinks[0].addEventListener('blur', this.handleImageLinkBlur.bind(this));
}

}

// Next Slide and Previous Slide Buttons

var elems = document.querySelectorAll('.carousel a.carousel-control');

for (var i = 0; i < elems.length; i++) {
if (elems[i].tagName.toLowerCase() == 'a') {
var button = new CarouselButton(elems[i], this);

button.init();
}
}

this.currentItem = this.firstItem;

this.pauseButton = this.domNode.parentNode.parentNode.querySelector('button.pause');
if (this.pauseButton) {
var button = new PauseButton(this.pauseButton, this);
button.init();
this.pauseButton.innerHTML = this.stopLabel;
}

this.domNode.addEventListener('mouseover', this.handleMouseOver.bind(this));
this.domNode.addEventListener('mouseout', this.handleMouseOut.bind(this));

// Start rotation
setTimeout(this.rotateSlides.bind(this), this.timeInterval);
};

Carousel.prototype.setSelected = function (newItem, moveFocus) {
if (typeof moveFocus != 'boolean') {
moveFocus = false;
}

for (var i = 0; i < this.items.length; i++) {
this.items[i].hide();
}

this.currentItem = newItem;
this.currentItem.show();

if (moveFocus) {
this.currentItem.domNode.focus();
}
};

Carousel.prototype.setSelectedToPreviousItem = function (currentItem, moveFocus) {
if (typeof moveFocus != 'boolean') {
moveFocus = false;
}

var index;

if (typeof currentItem !== 'object') {
currentItem = this.currentItem;
}

if (currentItem === this.firstItem) {
this.setSelected(this.lastItem, moveFocus);
}
else {
index = this.items.indexOf(currentItem);
this.setSelected(this.items[index - 1], moveFocus);
}
};

Carousel.prototype.setSelectedToNextItem = function (currentItem, moveFocus) {
if (typeof moveFocus != 'boolean') {
moveFocus = false;
}

var index;

if (typeof currentItem !== 'object') {
currentItem = this.currentItem;
}

if (currentItem === this.lastItem) {
this.setSelected(this.firstItem, moveFocus);
}
else {
index = this.items.indexOf(currentItem);
this.setSelected(this.items[index + 1], moveFocus);
}
};

Carousel.prototype.rotateSlides = function () {
if (this.rotate) {
this.setSelectedToNextItem();
}
setTimeout(this.rotateSlides.bind(this), this.timeInterval);
};

Carousel.prototype.startRotation = function () {
if (!this.hasHover && !this.hasFocus && !this.isStopped) {
this.rotate = true;
this.liveRegionNode.setAttribute('aria-live', 'off');
this.pauseButton.innerHTML = this.stopLabel;
}
this.disablePauseButton();
};

Carousel.prototype.stopRotation = function () {
this.rotate = false;
this.liveRegionNode.setAttribute('aria-live', 'polite');
this.pauseButton.innerHTML = this.startLabel;
mcking65 marked this conversation as resolved.
Show resolved Hide resolved
this.disablePauseButton();
};

Carousel.prototype.disablePauseButton = function () {
if (this.hasHover || this.hasFocus) {
this.pauseButton.setAttribute('aria-disabled', 'true');
}
else {
this.pauseButton.removeAttribute('aria-disabled');
}
};

Carousel.prototype.toggleRotation = function () {
if (this.isStopped) {
if (this.pauseButton.getAttribute('aria-disabled') !== 'true') {
this.isStopped = false;
this.startRotation();
}
}
else {
this.isStopped = true;
this.stopRotation();
}
};

Carousel.prototype.handleImageLinkFocus = function () {
this.liveRegionNode.classList.add('focus');
};

Carousel.prototype.handleImageLinkBlur = function () {
this.liveRegionNode.classList.remove('focus');
};

Carousel.prototype.handleMouseOver = function () {
this.hasHover = true;
this.stopRotation();
};

Carousel.prototype.handleMouseOut = function () {
this.hasHover = false;
this.startRotation();
};

/* Initialize Carousel Tablists */

window.addEventListener('load', function (event) {
var carousels = document.querySelectorAll('.carousel');

for (var i = 0; i < carousels.length; i++) {
var carousel = new Carousel(carousels[i]);
carousel.init();
}
}, false);

Loading