Skip to main content

Search and Top Navigation

Ticket #3482: progress-aria.2.diff
File progress-aria.2.diff, 2.0 KB (added by davidb, October 28, 2008 06:32PM UTC)

patch, with tests.

Index: tests/progressbar.js
===================================================================
--- tests/progressbar.js	(revision 846)
+++ tests/progressbar.js	(working copy)
@@ -52,5 +52,18 @@
 
 });
 
+test("accessibility", function() {
+	expect(6);
+	el = $("#progressbar").progressbar();
 
+	equals(el.ariaRole(), "progressbar", "aria role");
+	equals(el.ariaState("valuemin"), 0, "aria-valuemin");
+	equals(el.ariaState("valuemax"), 100, "aria-valuemax");
+	equals(el.ariaState("valuenow"), 0, "aria-valuenow");
+	el.progressbar("disable");
+	equals(el.ariaState("disabled"), "true", "aria-valuenow");
+	el.progressbar("enable");
+	equals(el.ariaState("disabled"), "false", "aria-valuenow");
+});
+
 })(jQuery);
Index: ui/ui.progressbar.js
===================================================================
--- ui/ui.progressbar.js	(revision 846)
+++ ui/ui.progressbar.js	(working copy)
@@ -23,7 +23,10 @@
 			text = options.text || '0%';
 		
 		this.element.addClass("ui-progressbar").width(options.width);
-		
+		this.element.ariaRole("progressbar");
+		this.element.ariaState("valuemin","0");
+		this.element.ariaState("valuemax","100");
+		this.element.ariaState("valuenow","0");
 		$.extend(this, {
 			active: false,
 			pixelState: 0,
@@ -97,11 +100,13 @@
 	disable: function() {
 		this.element.addClass("ui-progressbar-disabled");
 		this.disabled = true;
+		this.element.ariaState("disabled", true);
 	},
 	
 	enable: function() {
 		this.element.removeClass("ui-progressbar-disabled");
 		this.disabled = false;
+		this.element.ariaState("disabled", false);
 	},
 	
 	pause: function() {
@@ -120,9 +125,11 @@
 		this.bar.width(this.pixelState);
 		this.textElement.width(this.pixelState);
 		
+		var percent = Math.round(this.percentState);
 		if (this.options.range && !this.options.text) {
-			this.textElement.html(Math.round(this.percentState) + '%');
+			this.textElement.html(percent + '%');
 		}
+		this.element.ariaState("valuenow", percent);
 		this._propagate('progress', this.ui());
 	},

Download in other formats:

Original Format