Permalink
Browse files

MDL-27429 Adding tabindex and on keypress to the blocks show/hide icon.

  • Loading branch information...
1 parent a938306 commit 5a062fcd8f867c753a46a7b67c1de478311b04fd John Beedell committed Jun 27, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/javascript-static.js
@@ -617,10 +617,12 @@ M.util.init_block_hider = function(Y, config) {
t = b.one('.title'),
a = null;
if (t && (a = t.one('.block_action'))) {
- var hide = Y.Node.create('<img class="block-hider-hide" alt="'+config.tooltipVisible+'" title="'+config.tooltipVisible+'" />');
+ var hide = Y.Node.create('<img class="block-hider-hide" tabindex="0" alt="'+config.tooltipVisible+'" title="'+config.tooltipVisible+'" />');
hide.setAttribute('src', this.get('iconVisible')).on('click', this.updateState, this, true);
- var show = Y.Node.create('<img class="block-hider-show" alt="'+config.tooltipHidden+'" title="'+config.tooltipHidden+'" />');
+ hide.on('keypress', this.updateStateKey, this, true);
+ var show = Y.Node.create('<img class="block-hider-show" tabindex="0" alt="'+config.tooltipHidden+'" title="'+config.tooltipHidden+'" />');
show.setAttribute('src', this.get('iconHidden')).on('click', this.updateState, this, false);
+ show.on('keypress', this.updateStateKey, this, false);
a.insert(show, 0).insert(hide, 0);
}
},
@@ -631,6 +633,11 @@ M.util.init_block_hider = function(Y, config) {
} else {
this.get('block').removeClass('hidden');
}
+ },
+ updateStateKey : function(e, hide) {
+ if (e.keyCode == 13) { //allow hide/show via enter key
+ this.updateState(this, hide);
+ }
}
};
Y.extend(blockhider, Y.Base, blockhider.prototype, {

0 comments on commit 5a062fc

Please sign in to comment.