Skip to content

Commit

Permalink
FLUID-5276: Set aria-label on the overview panel controls
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbates committed Apr 1, 2014
1 parent 27689be commit 510c3c8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
32 changes: 18 additions & 14 deletions src/components/overviewPanel/js/OverviewPanel.js
Expand Up @@ -10,16 +10,12 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/

// Declare dependencies
/*global fluid, jQuery*/

// JSLint options
/*jslint white: true, funcinvoke: true, undef: true, newcap: true, nomen: true, regexp: true, bitwise: true, browser: true, forin: true, maxerr: 100, indent: 4 */

var fluid_1_5 = fluid_1_5 || {};

(function ($, fluid) {

"use strict";

fluid.registerNamespace("fluid.overviewPanel");
fluid.overviewPanel.preventDefault = function (event) {
event.preventDefault();
Expand Down Expand Up @@ -88,6 +84,7 @@ var fluid_1_5 = fluid_1_5 || {};
"method": "attr",
"args": {
"role": "button",
"aria-label": "{that}.options.strings.closePanelLabel",
"aria-controls": { expander: { "this": "{that}.container", "method": "attr", args: "id" } }
}
},
Expand Down Expand Up @@ -162,6 +159,8 @@ var fluid_1_5 = fluid_1_5 || {};
hidden: "fl-overviewPanel-hidden"
},
strings: {
openPanelLabel: "Open demo instructions",
closePanelLabel: "Close demo instructions",
titleBegin: "A",
titleLinkText: "fluid project",
titleEnd: "component demo",
Expand All @@ -186,8 +185,8 @@ var fluid_1_5 = fluid_1_5 || {};
}
});

fluid.overviewPanel.setVisibility = function (that, value) {
that.container.toggleClass(that.options.styles.hidden, !value);
fluid.overviewPanel.setVisibility = function (that, showPanel) {
that.container.toggleClass(that.options.styles.hidden, !showPanel);
};

fluid.overviewPanel.showTemplate = function (that) {
Expand All @@ -196,18 +195,23 @@ var fluid_1_5 = fluid_1_5 || {};
});
};

fluid.overviewPanel.togglePanel = function (that, value) {
that.applier.requestChange("showPanel", !value);
fluid.overviewPanel.togglePanel = function (that, showPanel) {
that.applier.requestChange("showPanel", !showPanel);
};

fluid.overviewPanel.closePanel = function (that) {
that.applier.requestChange("showPanel", false);
};

fluid.overviewPanel.setAriaStates = function (that, value) {
that.locate("toggleControl").attr("aria-pressed", !value);
that.locate("toggleControl").attr("aria-expanded", value);
that.locate("closeControl").attr("aria-expanded", value);
fluid.overviewPanel.setAriaStates = function (that, showPanel) {
that.locate("toggleControl").attr("aria-pressed", !showPanel);
that.locate("toggleControl").attr("aria-expanded", showPanel);
that.locate("closeControl").attr("aria-expanded", showPanel);
if (showPanel) {
that.locate("toggleControl").attr("aria-label", that.options.strings.closePanelLabel);
} else {
that.locate("toggleControl").attr("aria-label", that.options.strings.openPanelLabel);
}
};

})(jQuery, fluid_1_5);
27 changes: 16 additions & 11 deletions src/tests/component-tests/overviewPanel/js/OverviewPanelTests.js
Expand Up @@ -10,13 +10,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/

// Declare dependencies
/*global fluid, jqUnit, jQuery*/
(function ($) {

// JSLint options
/*jslint white: true, funcinvoke: true, undef: true, newcap: true, nomen: true, regexp: true, bitwise: true, browser: true, forin: true, maxerr: 100, indent: 4 */
"use strict";

(function ($) {
$(document).ready(function () {

jqUnit.module("OverviewPanel Tests");
Expand Down Expand Up @@ -65,6 +62,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
"false", that.locate("toggleControl").attr("aria-expanded"));
jqUnit.assertEquals("Check that closeControl aria-expanded is false",
"false", that.locate("closeControl").attr("aria-expanded"));
jqUnit.assertEquals("Check toggleControl aria-label",
that.options.strings.openPanelLabel, that.locate("toggleControl").attr("aria-label"));
jqUnit.assertEquals("Check closeControl aria-label",
that.options.strings.closePanelLabel, that.locate("closeControl").attr("aria-label"));
};

var assertPanelIsClosed = function (that) {
Expand All @@ -82,6 +83,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
"true", that.locate("toggleControl").attr("aria-expanded"));
jqUnit.assertEquals("Check that closeControl aria-expanded is true",
"true", that.locate("closeControl").attr("aria-expanded"));
jqUnit.assertEquals("Check toggleControl aria-label",
that.options.strings.closePanelLabel, that.locate("toggleControl").attr("aria-label"));
jqUnit.assertEquals("Check closeControl aria-label",
that.options.strings.closePanelLabel, that.locate("closeControl").attr("aria-label"));
};

var verifyRendering = function (that, strings) {
Expand Down Expand Up @@ -138,7 +143,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify when initially hidden", function () {
jqUnit.expect(5);
jqUnit.expect(7);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand All @@ -164,7 +169,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify when initially visible", function () {
jqUnit.expect(5);
jqUnit.expect(7);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand All @@ -187,7 +192,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify close control", function () {
jqUnit.expect(10);
jqUnit.expect(14);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand All @@ -210,7 +215,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify closePanel invoker", function () {
jqUnit.expect(10);
jqUnit.expect(14);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand Down Expand Up @@ -239,7 +244,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify toggle control", function () {
jqUnit.expect(25);
jqUnit.expect(35);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand Down Expand Up @@ -268,7 +273,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.asyncTest("Verify togglePanel invoker", function () {
jqUnit.expect(25);
jqUnit.expect(35);
fluid.overviewPanel(".flc-overviewPanel", {
resources: resources,
listeners: {
Expand Down

0 comments on commit 510c3c8

Please sign in to comment.