Update jquery.ime from upstream
* UI improvements, fixes * More input methods * Misc functionality fixes Change-Id: I1a516027e9654a498e4e87c83f8d72ad24eb5596
This commit is contained in:
committed by
Gerrit Code Review
parent
e3e0be19f2
commit
f8947b9686
@@ -8,6 +8,7 @@
|
||||
this.options = $.extend( {}, $.ime.defaults, options );
|
||||
this.active = false;
|
||||
this.inputmethod = null;
|
||||
this.language = null;
|
||||
this.context = '';
|
||||
this.selector = this.$element.imeselector( this.options );
|
||||
this.listen();
|
||||
@@ -170,10 +171,15 @@
|
||||
$.ime.preferences.setIM( inputmethodId );
|
||||
},
|
||||
|
||||
setLanguage: function( languageCode ) {
|
||||
setLanguage: function ( languageCode ) {
|
||||
this.language = languageCode;
|
||||
$.ime.preferences.setLanguage( languageCode );
|
||||
},
|
||||
|
||||
getLanguage: function () {
|
||||
return this.language;
|
||||
},
|
||||
|
||||
load: function ( name, callback ) {
|
||||
var ime = this,
|
||||
dependency;
|
||||
@@ -212,10 +218,12 @@
|
||||
data = $this.data( 'ime' ),
|
||||
options = typeof option === 'object' && option;
|
||||
|
||||
if( $this.prop( 'readonly' ) || $this.prop( 'disabled' ) ) {
|
||||
if ( $this.prop( 'readonly' ) || $this.prop( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
if ( $this.hasClass( 'noime' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !data ) {
|
||||
data = new IME( this, options );
|
||||
$this.data( 'ime', data );
|
||||
@@ -477,10 +485,18 @@
|
||||
name: 'Palochka',
|
||||
source: 'rules/cyrl/cyrl-palochka.js'
|
||||
},
|
||||
'da-normforms': {
|
||||
name: 'Normal forms',
|
||||
source: 'rules/da/da-normforms.js'
|
||||
},
|
||||
'eo-transliteration': {
|
||||
name: 'Transliteration',
|
||||
source: 'rules/eo/eo-transliteration.js'
|
||||
},
|
||||
'fo-normforms': {
|
||||
name: 'Føroyskt',
|
||||
source: 'rules/fo/fo-normforms.js'
|
||||
},
|
||||
'fi-transliteration': {
|
||||
name: 'translitterointi',
|
||||
source: 'rules/fi/fi-transliteration.js'
|
||||
@@ -493,6 +509,14 @@
|
||||
name: 'इनस्क्रिप्ट',
|
||||
source: 'rules/hi/hi-inscript.js'
|
||||
},
|
||||
'is-normforms': {
|
||||
name: 'Normal forms',
|
||||
source: 'rules/is/is-normforms.js'
|
||||
},
|
||||
'jv-transliteration': {
|
||||
name: 'Transliteration',
|
||||
source: 'rules/jv/jv-transliteration.js'
|
||||
},
|
||||
'mai-inscript': {
|
||||
name: 'इनस्क्रिप्ट',
|
||||
source: 'rules/mai/mai-inscript.js',
|
||||
@@ -510,6 +534,10 @@
|
||||
name: 'ഇൻസ്ക്രിപ്റ്റ്',
|
||||
source: 'rules/ml/ml-inscript.js'
|
||||
},
|
||||
'sv-normforms': {
|
||||
name: 'Normal forms',
|
||||
source: 'rules/sv/sv-normforms.js'
|
||||
},
|
||||
'ta-inscript': {
|
||||
name: 'இன்ஸ்கிரிப்ட்',
|
||||
source: 'rules/ta/ta-inscript.js'
|
||||
@@ -590,6 +618,14 @@
|
||||
name: 'Transliteration',
|
||||
source: 'rules/ne/ne-transliteration.js'
|
||||
},
|
||||
'no-normforms': {
|
||||
name: 'Normal transliterasjon',
|
||||
source: 'rules/no/no-normforms.js'
|
||||
},
|
||||
'no-tildeforms': {
|
||||
name: 'Tildemerket transliterasjon',
|
||||
source: 'rules/no/no-tildeforms.js'
|
||||
},
|
||||
'or-transliteration': {
|
||||
name: 'Transliteration',
|
||||
source: 'rules/or/or-transliteration.js'
|
||||
@@ -602,6 +638,10 @@
|
||||
name: 'ଲେଖନୀ',
|
||||
source: 'rules/or/or-lekhani.js'
|
||||
},
|
||||
'se-normforms': {
|
||||
name: 'Normal forms',
|
||||
source: 'rules/se/se-normforms.js'
|
||||
},
|
||||
'te-inscript': {
|
||||
name: 'ఇన్స్క్రిప్ట్',
|
||||
source: 'rules/te/te-inscript.js'
|
||||
@@ -701,6 +741,10 @@
|
||||
autonym: 'нохчийн',
|
||||
inputmethods: [ 'cyrl-palochka' ]
|
||||
},
|
||||
'da': {
|
||||
autonym: 'Dansk',
|
||||
inputmethods: [ 'da-normforms' ]
|
||||
},
|
||||
'de': {
|
||||
autonym: 'Deutsch',
|
||||
inputmethods: [ 'de' ]
|
||||
@@ -709,6 +753,10 @@
|
||||
autonym: 'Esperanto',
|
||||
inputmethods: [ 'eo-transliteration' ]
|
||||
},
|
||||
'fo': {
|
||||
autonym: 'Føroyskt',
|
||||
inputmethods: [ 'fo-normforms' ]
|
||||
},
|
||||
'fi': {
|
||||
autonym: 'Suomi',
|
||||
inputmethods: [ 'fi-transliteration' ]
|
||||
@@ -733,6 +781,14 @@
|
||||
autonym: 'छत्तीसगढ़ी',
|
||||
inputmethods: [ 'hi-transliteration' ]
|
||||
},
|
||||
'is': {
|
||||
autonym: 'Íslenska',
|
||||
inputmethods: [ 'is-normforms' ]
|
||||
},
|
||||
'jv': {
|
||||
autonym: 'ꦧꦱꦗꦮ',
|
||||
inputmethods: [ 'jv-transliteration' ]
|
||||
},
|
||||
'ka': {
|
||||
autonym: 'ქართული ენა',
|
||||
inputmethods: [ 'ka-transliteration' ]
|
||||
@@ -781,6 +837,18 @@
|
||||
autonym: 'नेपाल भाषा',
|
||||
inputmethods: [ 'hi-transliteration', 'hi-inscript' ]
|
||||
},
|
||||
'no': {
|
||||
autonym: 'Norsk',
|
||||
inputmethods: [ 'no-normforms', 'no-tildeforms' ]
|
||||
},
|
||||
'nb': {
|
||||
autonym: 'Norsk (bokmål)',
|
||||
inputmethods: [ 'no-normforms', 'no-tildeforms' ]
|
||||
},
|
||||
'nn': {
|
||||
autonym: 'Norsk (nynorsk)',
|
||||
inputmethods: [ 'no-normforms', 'no-tildeforms' ]
|
||||
},
|
||||
'or': {
|
||||
autonym: 'ଓଡ଼ିଆ',
|
||||
inputmethods: [ 'or-transliteration', 'or-lekhani', 'or-inscript' ]
|
||||
@@ -805,6 +873,10 @@
|
||||
autonym: 'संस्कृत',
|
||||
inputmethods: [ 'sa-transliteration', 'sa-inscript2', 'sa-inscript' ]
|
||||
},
|
||||
'se': {
|
||||
autonym: 'Davvisámegiella',
|
||||
inputmethods: [ 'se-normforms' ]
|
||||
},
|
||||
'shi': {
|
||||
autonym: 'ⵜⵉⴼⵉⵏⴰⵖ',
|
||||
inputmethods: [ 'ber-tfng' ]
|
||||
@@ -813,6 +885,10 @@
|
||||
autonym: 'සිංහල',
|
||||
inputmethods: [ 'si-singlish', 'si-wijesekara' ]
|
||||
},
|
||||
'sv': {
|
||||
autonym: 'Svenska',
|
||||
inputmethods: [ 'sv-normforms' ]
|
||||
},
|
||||
'ta': {
|
||||
autonym: 'தமிழ்',
|
||||
inputmethods: [ 'ta-transliteration', 'ta-99', 'ta-inscript', 'ta-bamini' ]
|
||||
@@ -860,13 +936,14 @@
|
||||
this.$imeSetting.hide();
|
||||
},
|
||||
|
||||
prepareSelectorMenu: function() {
|
||||
prepareSelectorMenu: function () {
|
||||
|
||||
// TODO: In this approach there is a menu for each editable area.
|
||||
// With correct event mapping we can probably reduce it to one menu.
|
||||
this.$imeSetting = $( selectorTemplate );
|
||||
this.$menu = $( '<div class="imeselector-menu" role="menu">' );
|
||||
this.$menu.append( imeList() )
|
||||
this.$menu.append( imeListTitle() )
|
||||
.append( imeList() )
|
||||
.append( toggleMenuItem() )
|
||||
.append( languageListTitle() );
|
||||
this.prepareLanguageList();
|
||||
@@ -878,19 +955,19 @@
|
||||
$( 'body' ).append( this.$imeSetting );
|
||||
},
|
||||
|
||||
focus: function ( ) {
|
||||
focus: function () {
|
||||
// Hide all other IME settings
|
||||
$( 'div.imeselector' ).hide();
|
||||
this.$imeSetting.show();
|
||||
},
|
||||
|
||||
toggle: function () {
|
||||
show: function () {
|
||||
this.$menu.addClass( 'open' );
|
||||
return false;
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
this.$menu.removeClass( 'open' );
|
||||
|
||||
if ( !this.$menu.hasClass( 'open' ) ) {
|
||||
this.$menu.toggleClass( 'open' );
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -901,7 +978,7 @@
|
||||
var imeselector = this;
|
||||
|
||||
$( 'html' ).on( 'click.ime', function () {
|
||||
imeselector.$menu.removeClass( 'open' );
|
||||
imeselector.hide();
|
||||
if ( imeselector.$element.is( ':hidden' ) ) {
|
||||
imeselector.$imeSetting.hide();
|
||||
}
|
||||
@@ -928,7 +1005,7 @@
|
||||
e.preventDefault();
|
||||
} );
|
||||
|
||||
imeselector.$imeSetting.on( 'click.ime', $.proxy( this.toggle, this ) );
|
||||
imeselector.$imeSetting.on( 'click.ime', $.proxy( this.show, this ) );
|
||||
|
||||
imeselector.$element.on( 'focus.ime', function ( e ) {
|
||||
imeselector.selectLanguage( $.ime.preferences.getLanguage() );
|
||||
@@ -993,21 +1070,28 @@
|
||||
* @param languageCode
|
||||
*/
|
||||
selectLanguage: function ( languageCode ) {
|
||||
var language;
|
||||
var language, ime;
|
||||
|
||||
ime = this.$element.data( 'ime' );
|
||||
language = $.ime.languages[languageCode];
|
||||
|
||||
if ( !language ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ime.getLanguage() === languageCode ) {
|
||||
// nothing to do. It is same as the current language
|
||||
return false;
|
||||
}
|
||||
|
||||
this.$menu.find( 'li.ime-lang' ).show();
|
||||
this.$menu.find( 'li[lang=' + languageCode + ']' ).hide();
|
||||
|
||||
this.$menu.find( '.ime-list-title' ).text( language.autonym );
|
||||
this.prepareInputMethods( languageCode );
|
||||
this.$menu.removeClass( 'open' );
|
||||
this.hide();
|
||||
// And select the default inputmethod
|
||||
this.$element.data( 'ime' ).setLanguage( languageCode );
|
||||
ime.setLanguage( languageCode );
|
||||
this.inputmethod = null;
|
||||
this.selectIM( $.ime.preferences.getIM( languageCode ) );
|
||||
},
|
||||
@@ -1040,7 +1124,7 @@
|
||||
var name;
|
||||
|
||||
imeselector.inputmethod = $.ime.inputmethods[inputmethodId];
|
||||
imeselector.$menu.removeClass( 'open' );
|
||||
imeselector.hide();
|
||||
ime.enable();
|
||||
name = imeselector.inputmethod.name;
|
||||
ime.setIM( inputmethodId );
|
||||
@@ -1062,7 +1146,7 @@
|
||||
this.$menu.find( 'div.ime-disable' ).addClass( 'checked' );
|
||||
this.$element.data( 'ime' ).disable();
|
||||
this.$imeSetting.find( 'a.ime-name' ).text( '' );
|
||||
this.$menu.removeClass( 'open' );
|
||||
this.hide();
|
||||
this.position();
|
||||
|
||||
// save this preference
|
||||
@@ -1174,13 +1258,18 @@
|
||||
$.fn.imeselector.Constructor = IMESelector;
|
||||
|
||||
function languageListTitle () {
|
||||
return $( '<h3 class="ime-lang-title"/>' )
|
||||
return $( '<h3>' )
|
||||
.addClass( 'ime-lang-title' )
|
||||
.attr( 'data-i18n', 'jquery-ime-other-languages' )
|
||||
.text( 'Other languages' );
|
||||
}
|
||||
|
||||
function imeList () {
|
||||
return $( '<h3 class="ime-list-title"></h3><ul class="ime-list"/>' );
|
||||
return $( '<ul>' ).addClass( 'ime-list' );
|
||||
}
|
||||
|
||||
function imeListTitle () {
|
||||
return $( '<h3>' ).addClass( 'ime-list-title' );
|
||||
}
|
||||
|
||||
function toggleMenuItem () {
|
||||
@@ -1199,7 +1288,7 @@
|
||||
|
||||
var selectorTemplate = '<div class="imeselector">'
|
||||
+ '<a class="ime-name imeselector-toggle" href="#"></a>'
|
||||
+ '<b class="caret"></b></div>';
|
||||
+ '<b class="ime-setting-caret"></b></div>';
|
||||
|
||||
/**
|
||||
* Check whether a keypress event corresponds to the shortcut key
|
||||
@@ -1224,13 +1313,11 @@
|
||||
p.addEventListener( 'DOMAttrModified', function () {
|
||||
flag = true;
|
||||
}, false );
|
||||
}
|
||||
else if ( p.attachEvent ) {
|
||||
} else if ( p.attachEvent ) {
|
||||
p.attachEvent( 'onDOMAttrModified', function () {
|
||||
flag = true;
|
||||
} );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1304,15 +1391,15 @@
|
||||
|
||||
// Set the given IM as the last used for the language
|
||||
setIM: function ( inputMethod ) {
|
||||
if( !this.registry.imes ){
|
||||
this.registry.imes= {};
|
||||
if ( !this.registry.imes ) {
|
||||
this.registry.imes = {};
|
||||
}
|
||||
this.registry.imes[this.getLanguage()] = inputMethod;
|
||||
},
|
||||
|
||||
// Return the last used or the default IM for language
|
||||
getIM: function ( language ) {
|
||||
if( !this.registry.imes ){
|
||||
if ( !this.registry.imes ) {
|
||||
this.registry.imes= {};
|
||||
}
|
||||
return this.registry.imes[language] || $.ime.languages[language].inputmethods[0];
|
||||
|
||||
Reference in New Issue
Block a user