]> source.dussan.org Git - jquery-ui.git/commitdiff
Support for non-Latin typeahead
authorOleg Shparber <trollixx@gmail.com>
Tue, 24 May 2011 21:57:23 +0000 (00:57 +0300)
committerOleg Shparber <trollixx@gmail.com>
Tue, 24 May 2011 21:57:23 +0000 (00:57 +0300)
ui/jquery.ui.selectmenu.js

index 2068535ec7e6ff4bcb95f2d2bfe3f2f8dc3b87ce..61c642f35230130bb02d858b796c967dbf69cbfe 100644 (file)
@@ -123,11 +123,13 @@ $.widget("ui.selectmenu", {
                                                break;
                                        default:
                                                ret = true;
-                                               self._typeAhead(event.keyCode, 'mouseup');
-                                               break;  
                                }
                                return ret;
                        })
+                       .bind('keypress.selectmenu', function(event) {
+                               self._typeAhead(event.which, 'mouseup');
+                               return true;
+                       })
                        .bind('mouseover.selectmenu focus.selectmenu', function() { 
                                if (!o.disabled) {
                                        $(this).addClass(self.widgetBaseClass + '-focus ui-state-hover');
@@ -223,10 +225,12 @@ $.widget("ui.selectmenu", {
                                                break;
                                        default:
                                                ret = true;     
-                                               self._typeAhead(event.keyCode,'focus');                                 
-                                               break;  
                                }
                                return ret;
+                       })
+                       .bind('keypress.selectmenu', function(event) {
+                               self._typeAhead(event.which, 'focus');
+                               return true;
                        });                     
                
                // needed when window is resized
@@ -420,7 +424,7 @@ $.widget("ui.selectmenu", {
        },
 
        _typeAhead: function(code, eventType){
-               var self = this, focusFound = false, C = String.fromCharCode(code);
+               var self = this, focusFound = false, C = String.fromCharCode(code).toUpperCase();
                c = C.toLowerCase();
 
                if (self.options.typeAhead == 'sequential') {
@@ -440,7 +444,7 @@ $.widget("ui.selectmenu", {
                                        // allow the typeahead attribute on the option tag for a more specific lookup
                                        var thisText = $(this).attr('typeahead') || $(this).text();
                                        if (thisText.indexOf(find+C) == 0) {
-                                               focusOptSeq(this,i, C)
+                                               focusOptSeq(this,i,C)
                                        } else if (thisText.indexOf(find+c) == 0) {
                                                focusOptSeq(this,i,c)
                                        }