aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.menu.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-09-12 23:19:19 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-09-12 23:19:19 +0200
commit609e1f87f4b242b1f30ccff75d72a863cb1fdb8e (patch)
tree68aa9589b4603cd0a62a1600d3bdc8d01b0a4b69 /ui/jquery.ui.menu.js
parent7216c08b2fd9ad5e3cb90500f2b13bed6339f2ba (diff)
downloadjquery-ui-609e1f87f4b242b1f30ccff75d72a863cb1fdb8e.tar.gz
jquery-ui-609e1f87f4b242b1f30ccff75d72a863cb1fdb8e.zip
Menu: Replace regular bind call with _bind
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r--ui/jquery.ui.menu.js188
1 files changed, 94 insertions, 94 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 27e76d909..c900f4218 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -71,111 +71,111 @@ $.widget( "ui.menu", {
this.refresh();
- this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) {
- if ( self.options.disabled ) {
- return;
- }
- switch ( event.keyCode ) {
- case $.ui.keyCode.PAGE_UP:
- self.previousPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.PAGE_DOWN:
- self.nextPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.HOME:
- self._move( "first", "first", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.END:
- self._move( "last", "last", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.UP:
- self.previous( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.DOWN:
- self.next( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.LEFT:
- if (self.collapse( event )) {
+ this.element.attr( "tabIndex", 0 );
+ this._bind({
+ "keydown": function( event ) {
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ self.previousPage( event );
+ event.preventDefault();
event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.RIGHT:
- if (self.expand( event )) {
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ self.nextPage( event );
+ event.preventDefault();
event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ENTER:
- if ( self.active.children( "a[aria-haspopup='true']" ).length ) {
- if ( self.expand( event ) ) {
- event.stopImmediatePropagation();
- }
- }
- else {
- self.select( event );
+ break;
+ case $.ui.keyCode.HOME:
+ self._move( "first", "first", event );
+ event.preventDefault();
event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ESCAPE:
- if ( self.collapse( event ) ) {
+ break;
+ case $.ui.keyCode.END:
+ self._move( "last", "last", event );
+ event.preventDefault();
event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- default:
- event.stopPropagation();
- clearTimeout( self.filterTimer );
- var match,
- prev = self.previousFilter || "",
- character = String.fromCharCode( event.keyCode ),
- skip = false;
-
- if (character == prev) {
- skip = true;
- } else {
- character = prev + character;
- }
- function escape( value ) {
- return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
- }
- match = self.activeMenu.children( ".ui-menu-item" ).filter( function() {
- return new RegExp("^" + escape(character), "i")
- .test( $( this ).children( "a" ).text() );
- });
- match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match;
- if ( !match.length ) {
- character = String.fromCharCode(event.keyCode);
- match = self.activeMenu.children(".ui-menu-item").filter( function() {
+ break;
+ case $.ui.keyCode.UP:
+ self.previous( event );
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ break;
+ case $.ui.keyCode.DOWN:
+ self.next( event );
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ break;
+ case $.ui.keyCode.LEFT:
+ if (self.collapse( event )) {
+ event.stopImmediatePropagation();
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.RIGHT:
+ if (self.expand( event )) {
+ event.stopImmediatePropagation();
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ENTER:
+ if ( self.active.children( "a[aria-haspopup='true']" ).length ) {
+ if ( self.expand( event ) ) {
+ event.stopImmediatePropagation();
+ }
+ }
+ else {
+ self.select( event );
+ event.stopImmediatePropagation();
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ESCAPE:
+ if ( self.collapse( event ) ) {
+ event.stopImmediatePropagation();
+ }
+ event.preventDefault();
+ break;
+ default:
+ event.stopPropagation();
+ clearTimeout( self.filterTimer );
+ var match,
+ prev = self.previousFilter || "",
+ character = String.fromCharCode( event.keyCode ),
+ skip = false;
+
+ if (character == prev) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+ function escape( value ) {
+ return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
+ }
+ match = self.activeMenu.children( ".ui-menu-item" ).filter( function() {
return new RegExp("^" + escape(character), "i")
.test( $( this ).children( "a" ).text() );
});
- }
- if ( match.length ) {
- self.focus( event, match );
- if (match.length > 1) {
- self.previousFilter = character;
- self.filterTimer = setTimeout( function() {
+ match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match;
+ if ( !match.length ) {
+ character = String.fromCharCode(event.keyCode);
+ match = self.activeMenu.children(".ui-menu-item").filter( function() {
+ return new RegExp("^" + escape(character), "i")
+ .test( $( this ).children( "a" ).text() );
+ });
+ }
+ if ( match.length ) {
+ self.focus( event, match );
+ if (match.length > 1) {
+ self.previousFilter = character;
+ self.filterTimer = setTimeout( function() {
+ delete self.previousFilter;
+ }, 1000 );
+ } else {
delete self.previousFilter;
- }, 1000 );
+ }
} else {
delete self.previousFilter;
}
- } else {
- delete self.previousFilter;
}
}
});