From 566f58fc4edbf2d95d005c03338583c9b393f401 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Wed, 25 May 2011 00:57:23 +0300 Subject: [PATCH] Support for non-Latin typeahead --- ui/jquery.ui.selectmenu.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 2068535ec..61c642f35 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -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) } -- 2.39.5