summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMax Li2012-02-07 12:18:26 (EST)
committer sfranklin2012-02-07 12:18:26 (EST)
commit8009a84df25e0fb582834004f4d1140851f0590c (patch)
tree21b711567c5de5024c1845497751676cc0a10a69
parentec25662819c3c1af362376b7ba2cd0c867388562 (diff)
downloadorg.eclipse.orion.client-8009a84df25e0fb582834004f4d1140851f0590c.zip
org.eclipse.orion.client-8009a84df25e0fb582834004f4d1140851f0590c.tar.gz
org.eclipse.orion.client-8009a84df25e0fb582834004f4d1140851f0590c.tar.bz2
Bug 370760 - Command span buttons cannot be used via keyboard
Bug 370229 - Command image buttons cannot be used via keyboard
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/commands.js43
1 files changed, 27 insertions, 16 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/commands.js b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
index 80bd8d0..0c3f2ac 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/commands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
@@ -942,14 +942,7 @@ define(['require', 'dojo', 'dijit', 'orion/util', 'dijit/Menu', 'dijit/form/Drop
} else {
image = addImageToElement(this, element, name);
}
- dojo.connect(element, "onclick", this, function() {
- // collect parameters in advance if specified
- if (this.parameters && context.collectsParameters()) {
- context.commandService._collectParameters(context);
- } else if (this.callback) {
- this.callback.call(context.handler, context);
- }
- });
+ this._hookCallback(element, context);
var overClass = image ? "commandImageOver" : "commandButtonOver";
this._setupActivateVisuals(element, element, activeCommandClass, inactiveCommandClass, overClass);
@@ -990,14 +983,7 @@ define(['require', 'dojo', 'dijit', 'orion/util', 'dijit/Menu', 'dijit/form/Drop
}
} else {
element = dojo.create("span", {tabindex: "0", role: "button"});
- dojo.connect(element, "onclick", this, function() {
- // collect parameters in advance if specified
- if (this.parameters && context.collectsParameters()) {
- context.commandService._collectParameters(context);
- } else if (this.callback) {
- this.callback.call(context.handler, context);
- }
- });
+ this._hookCallback(element, context);
var overClass;
if (this.name) {
dojo.place(window.document.createTextNode(this.name), element, "last");
@@ -1080,6 +1066,31 @@ define(['require', 'dojo', 'dijit', 'orion/util', 'dijit/Menu', 'dijit/form/Drop
/*
* stateless helper
*/
+ _hookCallback: function(domNode, context) {
+ dojo.connect(domNode, "onclick", this, function() {
+ // collect parameters in advance if specified
+ if (this.parameters && context.collectsParameters()) {
+ context.commandService._collectParameters(context);
+ } else if (this.callback) {
+ this.callback.call(context.handler, context);
+ }
+ });
+ // onClick events do not register for spans when using the keyboard
+ dojo.connect(domNode, "onkeypress", this, function(e) {
+ if (e.keyCode === dojo.keys.ENTER || e.keyCode === dojo.keys.SPACE) {
+ // collect parameters in advance if specified
+ if (this.parameters && context.collectsParameters()) {
+ context.commandService._collectParameters(context);
+ } else if (this.callback) {
+ this.callback.call(context.handler, context);
+ }
+ }
+ });
+ },
+
+ /*
+ * stateless helper
+ */
_setupActivateVisuals: function(domNode, focusNode, activeCommandClass, inactiveCommandClass, overClass) {
if (inactiveCommandClass) {
dojo.addClass(domNode, inactiveCommandClass);