afterEach(function() {
plugin.destroy();
+ document.activeElement.blur();
$html.remove();
});
$html.find('.accordion-content').eq(0).should.have.attr('aria-hidden', 'false');
});
});
-
+
describe('keyboard events', function() {
it('opens next panel on ARROW_DOWN', function() {
$html = $(template).appendTo('body');
$html.find('.accordion-content').eq(1).should.have.attr('aria-hidden', 'false');
});
});
-});
\ No newline at end of file
+});
afterEach(function() {
plugin.destroy();
+ document.activeElement.blur();
$html.remove();
});
// Open one first
plugin._show($html.find('li.is-drilldown-submenu-parent').eq(2));
-
+
$html.one('closed.zf.drilldown', function() {
$html.find('ul[data-submenu].is-active').each(function() {
// Checking with .be.hidden is not possible because they don't have display: block but z-index: -1
$html.find('> li:nth-child(1) > a').focus()
.trigger(window.mockKeyboardEvent('ARROW_RIGHT'));
-
+
setTimeout(function() { // Timeout to make sure transition has ended
$html.find('> li:nth-child(1) > ul > li[data-is-parent-link] a')[0].should.be.equal(document.activeElement);
done();
$html.find('> li:nth-child(1) > ul').should.have.class('is-closing');
});
});
-});
\ No newline at end of file
+});
afterEach(function() {
plugin.destroy();
+ document.activeElement.blur();
$dropdownController.remove();
$dropdownContainer.remove();
});
afterEach(function () {
plugin.destroy();
+ document.activeElement.blur();
$html.remove();
});
$html.find('> li:nth-child(1)').should.have.class('is-active');
$html.find('> li:nth-child(1) > ul').should.have.class('js-dropdown-active');
- document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
+ document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
});
it('moves focus to previous sub element on ARROW_UP', function () {
// Open it first
$html.find('> li:nth-child(1) > ul > li:nth-child(2)').should.have.class('is-active');
$html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul').should.have.class('js-dropdown-active');
- document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
+ document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
});
});
describe('vertical', function() {
$html.find('> li:nth-child(1)').should.have.class('is-active');
$html.find('> li:nth-child(1) > ul').should.have.class('js-dropdown-active');
- document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
+ document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
});
it('moves focus to previous sub element on ARROW_UP', function () {
- $html = $(template).appendTo('body');
- plugin = new Foundation.DropdownMenu($html, {});
-
// Open it first
plugin._show($html.find('> li:nth-child(1) > ul'));
document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
});
it('opens child element of sub menu on ARROW_RIGHT', function() {
- $html = $(template).appendTo('body');
- plugin = new Foundation.DropdownMenu($html, {});
-
// Open it first
plugin._show($html.find('> li:nth-child(1) > ul'));
$html.find('> li:nth-child(1) > ul > li:nth-child(2)').should.have.class('is-active');
$html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul').should.have.class('js-dropdown-active');
- document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
+ document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
});
});
});
-});
\ No newline at end of file
+});
afterEach(function() {
plugin.destroy();
+ document.activeElement.blur();
$html.remove();
});
plugin.toggle();
});
});
-
+
describe('keyboard events', function() {
it('closes Off Canvas on ESCAPE', function(done) {
$html = $(template).appendTo('body');
afterEach(function() {
plugin.destroy();
+ document.activeElement.blur();
$html.remove();
});
plugin = new Foundation.Toggler($html, {});
$triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-controls', 'toggler');
-
$triggers.remove();
});
plugin = new Foundation.Toggler($html, {});
$triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'true');
+ $triggers.remove();
});
it('sets aria-expanded to false if the element is invisible', function() {
plugin = new Foundation.Toggler($html, {});
$triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'false');
+ $triggers.remove();
$css.remove();
});
});
plugin._toggleClass();
$triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'false');
+
+ $triggers.remove();
});
});
'ARROW_DOWN': 40
};
+ afterEach(function() {
+ document.activeElement.blur();
+ });
+
it('exists on the Foundation API', function() {
(window.Foundation.Keyboard).should.be.an('object');
});