From 0c2c273c93e0b5e188d9889d4830a92f871493bd Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Tue, 6 Feb 2018 15:52:32 +0530 Subject: [PATCH] Update jquery.uls to 54a466e * Change the language icon color to gray and optimize * Simplify key press event handlers Bug: T175769 Change-Id: I05cfaf699ed5ddccc781344143886831929cbb72 --- lib/jquery.uls/images/language.png | Bin 402 -> 721 bytes lib/jquery.uls/images/language.svg | 5 ++- lib/jquery.uls/src/jquery.uls.core.js | 30 +----------------- .../src/jquery.uls.languagefilter.js | 29 ++++------------- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/lib/jquery.uls/images/language.png b/lib/jquery.uls/images/language.png index c8fcbc66c78a6bf0a37ad4329f71028628790a13..332f20dcaf5b2aef3c9f1f8f110d8f3d059e9a58 100644 GIT binary patch delta 698 zcmV;r0!96j1JMPLBYyw{b3#c}2nYxWdlTj4K zfA{sXv|{3)7!w_JGCBz{lIUQfvKnc%-v?i@3`Zh?AS5 zQ3Ez$9{iWp;`&_?*MIakdrfUnW`X7w z&)d6EL5aA&Ze+u7E+gyl4#HUgl%T^HYJYfept*{j@#4n~_OQjg8W~JKSuVJkp@Y*0gl!;{tYT3&-UKv?HN7ib zsP>?8)2QBA(;+}h%)cul5h-&3=02+v8V7N{e40EoHa1rNd6Hv@JX3flu-_VUbR^sV zVwFPx8V*;m4D=NjTM5U>GW3>I)DaI&H=Ya zvf1$}?|I&KQ6j+8d@lW5;4vc6(}~2krRb`8MKA8KPU)&Bmw+i?2I!2q{!Ybo7jpe? zOX{?Nh7r9FprQ{@IT0vUT7ez_CmM@;h{lxCDFH#~k%eFve4Eois1xC`h>iKaziX~c z5|{}Gq<;V~KeKtXZcB06h$gFo67l?Ql$b)FDN8D!Pfsq7A(2RgzR%l6prYtYU;^RR zVuNx8Xj0`!VJI^pi9{k43V!Us z@IF77X;?kXe*^5RGj>nS&tcVcC)^6uTT5>(UNevZpnl#4+&>ZoZ3p>iD#ctaHlU>} g$TVoO7XNS64+5^;%=w{k_y7O^07*qoM6N<$g1oUgRsaA1 delta 376 zcmV-;0f+w41(E}hBYy!|Nkl~y77^E|J0PFiMuSIX zEN;UTftr(Jv~eB1vP$oB61*;>mksD9p;qGA_hl&0jjtgyr$Ck7yWY$ZXvR8sLvx#E z46QeF#{O+gsw_vPj!?oK8~Z&U3;fsop3l>t$zm+f3N)gcQJHDjax8Gw|KQKs+JQf= Wh)Y!HS`zU90000language \ No newline at end of file + + + + diff --git a/lib/jquery.uls/src/jquery.uls.core.js b/lib/jquery.uls/src/jquery.uls.core.js index 986c8ab1..27ba36b0 100644 --- a/lib/jquery.uls/src/jquery.uls.core.js +++ b/lib/jquery.uls/src/jquery.uls.core.js @@ -218,12 +218,7 @@ } ); // Handle key press events on the menu - this.$menu.on( 'keypress', $.proxy( this.keypress, this ) ) - .on( 'keyup', $.proxy( this.keyup, this ) ); - - if ( this.eventSupported( 'keydown' ) ) { - this.$menu.on( 'keydown', $.proxy( this.keypress, this ) ); - } + this.$menu.on( 'keydown', $.proxy( this.keypress, this ) ); languagesCount = Object.keys( this.options.languages ).length; lcd = this.$resultsView.lcd( { @@ -275,18 +270,6 @@ this.hide(); }, - keyup: function ( e ) { - if ( !this.shown ) { - return; - } - - if ( e.keyCode === 27 ) { // escape - this.cancel(); - e.preventDefault(); - e.stopPropagation(); - } - }, - keypress: function ( e ) { if ( !this.shown ) { return; @@ -307,17 +290,6 @@ } }, - eventSupported: function ( eventName ) { - var isSupported = eventName in this.$menu; - - if ( !isSupported ) { - this.$element.setAttribute( eventName, 'return;' ); - isSupported = typeof this.$element[ eventName ] === 'function'; - } - - return isSupported; - }, - /** * Get the panel menu width parameter * @return {string} diff --git a/lib/jquery.uls/src/jquery.uls.languagefilter.js b/lib/jquery.uls/src/jquery.uls.languagefilter.js index 6352c80b..9f48d727 100644 --- a/lib/jquery.uls/src/jquery.uls.languagefilter.js +++ b/lib/jquery.uls/src/jquery.uls.languagefilter.js @@ -67,12 +67,8 @@ }, listen: function () { - this.$element.on( 'keypress', $.proxy( this.keyup, this ) ) - .on( 'keyup', $.proxy( this.keyup, this ) ); - if ( this.eventSupported( 'keydown' ) ) { - this.$element.on( 'keydown', $.proxy( this.keyup, this ) ); - } + this.$element.on( 'keydown', $.proxy( this.keypress, this ) ); if ( this.$clear.length ) { this.$clear.on( 'click', $.proxy( this.clear, this ) ); @@ -81,7 +77,7 @@ this.toggleClear(); }, - keyup: function ( e ) { + keypress: function ( e ) { var suggestion, query, languageFilter; switch ( e.keyCode ) { @@ -106,11 +102,11 @@ query = $.trim( this.$element.val() ).toLowerCase(); if ( this.selectedLanguage ) { - // this.selectLanguage will be populated from a matching search + // this.selectLanguage will be populated from a matching search this.options.onSelect( this.selectedLanguage ); } else if ( this.options.languages[ query ] ) { - // Search is yet to happen (in timeout delay), - // but we have a matching language code. + // Search is yet to happen (in timeout delay), + // but we have a matching language code. this.options.onSelect( query ); } @@ -119,9 +115,9 @@ languageFilter = this; if ( e.which < 32 && - e.which !== 8 // Backspace + e.which !== 8 // Backspace ) { - // ignore any ASCII control characters + // ignore any ASCII control characters break; } @@ -314,17 +310,6 @@ matcher.test( $.uls.data.getAutonym( langCode ) ) || matcher.test( langCode ) || matcher.test( $.uls.data.getScript( langCode ) ); - }, - - eventSupported: function ( eventName ) { - var isSupported = eventName in this.$element; - - if ( !isSupported ) { - this.$element.setAttribute( eventName, 'return;' ); - isSupported = typeof this.$element[ eventName ] === 'function'; - } - - return isSupported; } };