r3332 committed - autocomplete: improved cursor up/down handling when no menu is present...
Revision: 3332
Author: joern.zaefferer
Date: Tue Sep 29 15:36:34 2009
Log: autocomplete: improved cursor up/down handling when no menu is present
and when first/last item is reached
http://code.google.com/p/jquery-ui/source/detail?r=3332
Modified:
/branches/dev/ui/jquery.ui.autocomplete.js
/branches/dev/ui/jquery.ui.menu.js
=======================================
--- /branches/dev/ui/jquery.ui.autocomplete.js Tue Sep 29 15:30:13 2009
+++ /branches/dev/ui/jquery.ui.autocomplete.js Tue Sep 29 15:36:34 2009
@@ -158,12 +158,18 @@
},
focusUp: function() {
- if (!this.menu)
+ if (!this.menu) {
+ this.search();
return;
+ }
this.menu.menu("previous");
},
focusDown: function() {
+ if (!this.menu) {
+ this.search();
+ return;
+ }
this.menu.menu("next");
},
=======================================
--- /branches/dev/ui/jquery.ui.menu.js Tue Sep 29 12:30:10 2009
+++ /branches/dev/ui/jquery.ui.menu.js Tue Sep 29 15:36:34 2009
@@ -47,7 +47,12 @@
return;
}
this.deactivate(this.activeitem);
- this.activate(this.activeitem.parent().next().children("a"));
+ var next = this.activeitem.parent().next();
+ if (next.length) {
+ this.activate(next.children("a"));
+ } else {
+ this.activate(this.element.children("li:first").children("a"));
+ }
},
previous: function() {
@@ -56,7 +61,12 @@
return;
}
this.deactivate(this.activeitem);
- this.activate(this.activeitem.parent().prev().children("a"));
+ var prev = this.activeitem.parent().prev();
+ if (prev.length) {
+ this.activate(prev.children("a"));
+ } else {
+ this.activate(this.element.children("li:last").children("a"));
+ }
},
select: function() {