aboutsummaryrefslogtreecommitdiffstats
path: root/tests/visual
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-05-07 15:18:50 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-05-07 15:18:50 +0200
commit5973b4fa3f7a7de6e9b8f1aba6c9a4ebd9a412b0 (patch)
treefb6f79764f066c7b471a1c488faff018bc8f0c95 /tests/visual
parenta2674a2c6b93667ce0c1f5891c2566690fb59c97 (diff)
downloadjquery-ui-5973b4fa3f7a7de6e9b8f1aba6c9a4ebd9a412b0.tar.gz
jquery-ui-5973b4fa3f7a7de6e9b8f1aba6c9a4ebd9a412b0.zip
Popup: Better key handling on trigger, along with a few more TODO comments
Diffstat (limited to 'tests/visual')
-rw-r--r--tests/visual/menu/popup.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js
index 97f12c053..87a480741 100644
--- a/tests/visual/menu/popup.js
+++ b/tests/visual/menu/popup.js
@@ -39,12 +39,18 @@ $.widget( "ui.popup", {
this._bind(this.options.trigger, {
keydown: function( event ) {
// prevent space-to-open to scroll the page, only hapens for anchor ui.button
- if ($( event.currentTarget ).is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE) {
+ if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE) {
event.preventDefault()
}
- // TODO handle keydown to open popup? only when not handled by ui.button
- //if (event.keyCode == $.ui.keyCode.SPACE) {
- //}
+ // TODO handle SPACE to open popup? only when not handled by ui.button
+ if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is("a:not(:ui-button)") ) {
+ this.options.trigger.trigger( "click", event );
+ }
+ // translate keydown to click
+ // opens popup and let's tooltip hide itself
+ if ( event.keyCode == $.ui.keyCode.DOWN ) {
+ this.options.trigger.trigger( "click", event );
+ }
},
click: function( event ) {
event.preventDefault();
@@ -61,6 +67,7 @@ $.widget( "ui.popup", {
});
this._bind(this.element, {
+ // TODO use focusout so that element itself doesn't need to be focussable
blur: function( event ) {
var that = this;
// use a timer to allow click to clear it and letting that
@@ -74,9 +81,11 @@ $.widget( "ui.popup", {
this._bind({
// TODO only triggerd on element if it can receive focus
// bind to document instead?
+ // either element itself or a child should be focusable
keyup: function( event ) {
if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) {
this.close( event );
+ // TODO move this to close()? would allow menu.select to call popup.close, and get focus back to trigger
this.options.trigger.focus();
}
}
@@ -120,6 +129,7 @@ $.widget( "ui.popup", {
.attr( "aria-hidden", false )
.attr( "aria-expanded", true )
.position( position )
+ // TODO find a focussable child, otherwise put focus on element, add tabIndex=0 if not focussable
.focus();
if (this.element.is(":ui-menu")) {