Update jquery.ime from upstream

version: v0.1.0+20131019 (commit: 4ac70e0047)
upstream: https://github.com/wikimedia/jquery.ime

Changes:
* Language tags are case insensitive now
* Fixes to Hindi and Persian input methods
* Shift modifier key support
* Misc CSS fixes

Bug: 54117
Change-Id: I581a1006c34fd86372facdae85ea48b4ed1ffc2c
This commit is contained in:
Santhosh Thottingal
2013-10-19 17:22:22 +05:30
parent 6a08a6d216
commit cc413a3a4d
4 changed files with 43 additions and 8 deletions

View File

@@ -7,6 +7,7 @@
background-image: linear-gradient(transparent, transparent), url('../images/ime-active.svg'); background-image: linear-gradient(transparent, transparent), url('../images/ime-active.svg');
background-color: rgba(255,255,255,0.75); background-color: rgba(255,255,255,0.75);
background-position: left 3px center; background-position: left 3px center;
background-position-x: 3px;
height: 15px; height: 15px;
font-size: small; font-size: small;
padding: 2px 2px 1px 20px; padding: 2px 2px 1px 20px;
@@ -168,10 +169,12 @@ span.ime-disable-shortcut {
.imeselector-menu .ime-checked { .imeselector-menu .ime-checked {
/* @embed */ /* @embed */
background: url(../images/tick.png) no-repeat left 4px center; background: url(../images/tick.png) no-repeat left center;
background-image: -webkit-linear-gradient(transparent, transparent), url('../images/tick.svg'); background-image: -webkit-linear-gradient(transparent, transparent), url('../images/tick.svg');
background-image: -moz-linear-gradient(transparent, transparent), url('../images/tick.svg'); background-image: -moz-linear-gradient(transparent, transparent), url('../images/tick.svg');
background-image: linear-gradient(transparent, transparent), url('../images/tick.svg'); background-image: linear-gradient(transparent, transparent), url('../images/tick.svg');
background-position: left 4px center;
background-position-x: 4px;
} }
.imeselector-menu .ime-help-link { .imeselector-menu .ime-help-link {

View File

@@ -1,4 +1,4 @@
/*! jquery.ime - v0.1.0+20130914 /*! jquery.ime - v0.1.0+20131019
* https://github.com/wikimedia/jquery.ime * https://github.com/wikimedia/jquery.ime
* Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */ * Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */
( function ( $ ) { ( function ( $ ) {
@@ -19,6 +19,7 @@
$.ime.defaults.languages = arrayKeys( $.ime.languages ); $.ime.defaults.languages = arrayKeys( $.ime.languages );
this.options = $.extend( {}, $.ime.defaults, options ); this.options = $.extend( {}, $.ime.defaults, options );
this.active = false; this.active = false;
this.shifted = false;
this.inputmethod = null; this.inputmethod = null;
this.language = null; this.language = null;
this.context = ''; this.context = '';
@@ -34,6 +35,8 @@
*/ */
listen: function () { listen: function () {
this.$element.on( 'keypress.ime', $.proxy( this.keypress, this ) ); this.$element.on( 'keypress.ime', $.proxy( this.keypress, this ) );
this.$element.on( 'keyup.ime', $.proxy( this.keyup, this ) );
this.$element.on( 'keydown.ime', $.proxy( this.keydown, this ) );
this.$element.on( 'destroy.ime', $.proxy( this.destroy, this ) ); this.$element.on( 'destroy.ime', $.proxy( this.destroy, this ) );
this.$element.on( 'enable.ime', $.proxy( this.enable, this ) ); this.$element.on( 'enable.ime', $.proxy( this.enable, this ) );
this.$element.on( 'disable.ime', $.proxy( this.disable, this ) ); this.$element.on( 'disable.ime', $.proxy( this.disable, this ) );
@@ -57,6 +60,14 @@
patterns = this.inputmethod.patterns || []; patterns = this.inputmethod.patterns || [];
} }
if ( this.shifted ) {
// if shift is pressed give priority for the patterns_shift
// if exists.
// Example: Shift+space where shift does not alter the keycode
patterns = ( this.inputmethod.patterns_shift || [] )
.concat( patterns );
}
if ( $.isFunction( patterns ) ) { if ( $.isFunction( patterns ) ) {
return patterns.call( this, input, context ); return patterns.call( this, input, context );
} }
@@ -88,6 +99,18 @@
return input; return input;
}, },
keyup: function ( e ) {
if ( e.which === 16 ) { // shift key
this.shifted = false;
}
},
keydown: function ( e ) {
if ( e.which === 16 ) { // shift key
this.shifted = true;
}
},
/** /**
* Keypress handler * Keypress handler
* @param {jQuery.Event} e Event * @param {jQuery.Event} e Event
@@ -1066,8 +1089,13 @@
* @return {string|bool} Selected input method id or false * @return {string|bool} Selected input method id or false
*/ */
selectLanguage: function ( languageCode ) { selectLanguage: function ( languageCode ) {
var ime = this.$element.data( 'ime' ), var ime, imePref, language;
imePref = $.ime.preferences.getIM( languageCode ),
// consider language codes case insensitive
languageCode = languageCode && languageCode.toLowerCase();
ime = this.$element.data( 'ime' );
imePref = $.ime.preferences.getIM( languageCode );
language = $.ime.languages[languageCode]; language = $.ime.languages[languageCode];
this.setMenuTitle( this.getAutonym( languageCode ) ); this.setMenuTitle( this.getAutonym( languageCode ) );

View File

@@ -155,7 +155,11 @@
['m', '…'], ['m', '…'],
[',', ','], [',', ','],
['\\.', '\''], ['\\.', '\''],
['/', '?'] ['/', '?'],
[' ', '\xa0']
],
patterns_shift: [
[' ', '\u200c']
] ]
}; };

View File

@@ -12,14 +12,14 @@
patterns: [ patterns: [
['्f', '्\u200c'], ['्f', '्\u200c'],
['\\~', 'ऎ'], ['\\~', 'ऎ'],
['\\`","ॆ'], ['\\`','ॆ'],
['\\!', 'ऍ'], ['\\!', 'ऍ'],
['1', '१'], ['1', '१'],
['\\@', 'ॅ'], ['\\@', 'ॅ'],
['2', '२'], ['2', '२'],
['\\#', 'ऑ'], ['\\#', 'ऑ'],
['3', '३'], ['3', '३'],
['\\$","ॉ'], ['\\$','ॉ'],
['4', '४'], ['4', '४'],
['\\%', 'ञ'], ['\\%', 'ञ'],
['5', '५'], ['5', '५'],