Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 247a74c

Browse files
imakewebthings#47, set aria-disabled on next/prev links
1 parent a3c87b1 commit 247a74c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

extensions/navigation/deck.navigation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
Deck JS - deck.navigation
3-
Copyright (c) 2011 Caleb Troughton
3+
Copyright (c) 2011-2013 Caleb Troughton
44
Dual licensed under the MIT license.
55
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
66
*/
@@ -24,8 +24,10 @@ This module adds clickable previous and next links to the deck.
2424
var $nextButton = $(options.selectors.nextLink);
2525

2626
$prevButton.toggleClass(options.classes.navDisabled, to === 0);
27+
$prevButton.attr('aria-disabled', to === 0);
2728
$prevButton.attr('href', hrefBase + '#' + (prevId ? prevId : ''));
2829
$nextButton.toggleClass(options.classes.navDisabled, to === lastIndex);
30+
$nextButton.attr('aria-disabled', to === lastIndex);
2931
$nextButton.attr('href', hrefBase + '#' + (nextId ? nextId : ''));
3032
};
3133

test/spec.navigation.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,22 @@ describe('Deck JS Navigation Buttons', function() {
2929
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
3030
});
3131

32+
it('should add aria-disabled to previous link if on first slide', function() {
33+
$.deck('go', 0);
34+
expect($(defaults.selectors.previousLink)).toHaveAttr('aria-disabled', 'true');
35+
});
36+
3237
it('should add the disabled class to the next link if on last slide', function() {
3338
expect($(defaults.selectors.nextLink)).not.toHaveClass(defaults.classes.navDisabled);
3439
$.deck('go', $.deck('getSlides').length - 1);
3540
expect($(defaults.selectors.nextLink)).toHaveClass(defaults.classes.navDisabled);
3641
});
3742

43+
it('should add aria-disabled to next link if on last slide', function() {
44+
$.deck('go', $.deck('getSlides').length - 1);
45+
expect($(defaults.selectors.nextLink)).toHaveAttr('aria-disabled', 'true');
46+
});
47+
3848
it('should not start disabled if deck initialized in the middle', function() {
3949
$.deck('go', 2);
4050
$.deck('.slide');
@@ -50,4 +60,4 @@ describe('Deck JS Navigation Buttons', function() {
5060
expect($(defaults.selectors.previousLink).attr('href')).toMatch('#custom-id');
5161
expect($(defaults.selectors.nextLink).attr('href')).toMatch('#slide-3');
5262
});
53-
});
63+
});

0 commit comments

Comments
 (0)