Skip to content

Commit

Permalink
#47, set aria-disabled on next/prev links
Browse files Browse the repository at this point in the history
  • Loading branch information
imakewebthings committed Dec 7, 2013
1 parent a3c87b1 commit 247a74c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion extensions/navigation/deck.navigation.js
@@ -1,6 +1,6 @@
/*!
Deck JS - deck.navigation
Copyright (c) 2011 Caleb Troughton
Copyright (c) 2011-2013 Caleb Troughton
Dual licensed under the MIT license.
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
*/
Expand All @@ -24,8 +24,10 @@ This module adds clickable previous and next links to the deck.
var $nextButton = $(options.selectors.nextLink);

$prevButton.toggleClass(options.classes.navDisabled, to === 0);
$prevButton.attr('aria-disabled', to === 0);
$prevButton.attr('href', hrefBase + '#' + (prevId ? prevId : ''));
$nextButton.toggleClass(options.classes.navDisabled, to === lastIndex);
$nextButton.attr('aria-disabled', to === lastIndex);
$nextButton.attr('href', hrefBase + '#' + (nextId ? nextId : ''));
};

Expand Down
12 changes: 11 additions & 1 deletion test/spec.navigation.js
Expand Up @@ -29,12 +29,22 @@ describe('Deck JS Navigation Buttons', function() {
expect($(defaults.selectors.previousLink)).toHaveClass(defaults.classes.navDisabled);
});

it('should add aria-disabled to previous link if on first slide', function() {
$.deck('go', 0);
expect($(defaults.selectors.previousLink)).toHaveAttr('aria-disabled', 'true');
});

it('should add the disabled class to the next link if on last slide', function() {
expect($(defaults.selectors.nextLink)).not.toHaveClass(defaults.classes.navDisabled);
$.deck('go', $.deck('getSlides').length - 1);
expect($(defaults.selectors.nextLink)).toHaveClass(defaults.classes.navDisabled);
});

it('should add aria-disabled to next link if on last slide', function() {
$.deck('go', $.deck('getSlides').length - 1);
expect($(defaults.selectors.nextLink)).toHaveAttr('aria-disabled', 'true');
});

it('should not start disabled if deck initialized in the middle', function() {
$.deck('go', 2);
$.deck('.slide');
Expand All @@ -50,4 +60,4 @@ describe('Deck JS Navigation Buttons', function() {
expect($(defaults.selectors.previousLink).attr('href')).toMatch('#custom-id');
expect($(defaults.selectors.nextLink).attr('href')).toMatch('#slide-3');
});
});
});

0 comments on commit 247a74c

Please sign in to comment.