From 95c23085ff77a149975d199ed864c2d0c5e27fdb Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 15 Jul 2013 15:59:29 +0300 Subject: [PATCH] Update jquery.ime from upstream Change-Id: I1eabfcda79be85c8c28c11472ddc17b2e90c061d --- lib/jquery.ime/css/jquery.ime.css | 39 +++-- lib/jquery.ime/jquery.ime.js | 110 ++++++++------ .../rules/de/{de.js => de-transliteration.js} | 2 +- .../rules/he/he-standard-2012-extonly.js | 2 + lib/jquery.ime/rules/he/he-standard-2012.js | 2 + lib/jquery.ime/rules/kn/kn-inscript2.js | 2 +- lib/jquery.ime/rules/mr/mr-phonetic.js | 4 +- lib/jquery.ime/rules/or/or-lekhani.js | 2 +- lib/jquery.ime/rules/or/or-transliteration.js | 4 +- lib/jquery.ime/rules/sk/sk-kbd.js | 140 +++++++----------- lib/jquery.ime/rules/ta/ta-inscript2.js | 2 +- 11 files changed, 154 insertions(+), 155 deletions(-) rename lib/jquery.ime/rules/de/{de.js => de-transliteration.js} (94%) diff --git a/lib/jquery.ime/css/jquery.ime.css b/lib/jquery.ime/css/jquery.ime.css index ac631068..c2b36323 100644 --- a/lib/jquery.ime/css/jquery.ime.css +++ b/lib/jquery.ime/css/jquery.ime.css @@ -7,7 +7,6 @@ background-image: linear-gradient(transparent, transparent), url('../images/ime-active.svg'); background-color: rgba(255,255,255,0.75); background-position: left 3px center; - cursor: pointer; height: 15px; font-size: small; padding: 2px 2px 1px 20px; @@ -19,13 +18,15 @@ z-index: 9999; } -div.imeselector:hover { +.imeselector:hover { box-shadow: 0 1px 3px 0 #565656; border-top: none; background-color: rgba(255,255,255,0.85); } -.imeselector a { +.imeselector a, +.ime-disable { + cursor: pointer; text-decoration: none; outline: none; color: #222222; @@ -49,11 +50,7 @@ div.imeselector:hover { } span.ime-disable-link { - color: #222222; - line-height: 1em; - padding-top: 4px; padding-left: 20px; - padding-bottom: 4px; white-space: nowrap; } @@ -110,7 +107,7 @@ span.ime-disable-shortcut { text-align: left; } -.imeselector-menu.right { +.imeselector-menu.ime-right { right: auto; } @@ -133,7 +130,7 @@ span.ime-disable-shortcut { top: -7px; } -.imeselector-menu.right:before { +.imeselector-menu.ime-right:before { right: auto; left: 9px; } @@ -150,26 +147,26 @@ span.ime-disable-shortcut { } -.imeselector-menu.right:after { +.imeselector-menu.ime-right:after { right: auto; left: 10px; } -.imeselector-menu.position-top:before { +.imeselector-menu.ime-position-top:before { border-bottom: 0 none; border-top: 7px solid #888; top: auto; bottom: -7px; } -.imeselector-menu.position-top:after { +.imeselector-menu.ime-position-top:after { border-bottom: 0 none; border-top: 6px solid #FFFFFF; top: auto; bottom: -6px; } -.imeselector-menu .checked { +.imeselector-menu .ime-checked { /* @embed */ background: url(../images/tick.png) left 4px center no-repeat; background-image: -webkit-linear-gradient(transparent, transparent), url('../images/tick.svg'); @@ -191,24 +188,26 @@ span.ime-disable-shortcut { color: #000; } -.imeselector-menu a { +.imeselector-menu .selectable-row-item { display: block; padding-left: 20px; padding-right: 20px; - clear: both; font-weight: normal; color: #333333; outline: none; white-space: nowrap; + position: relative; } -.imeselector-menu li > a:hover { - text-decoration: none; - color: #ffffff; - background-color: #5089e8; +.imeselector-menu .selectable-row { + cursor: pointer; } -.open { +.imeselector-menu .selectable-row:hover { + background-color: #f0f0f0; +} + +.ime-open { *z-index: 1000; display: block; } diff --git a/lib/jquery.ime/jquery.ime.js b/lib/jquery.ime/jquery.ime.js index 9bf7cc8a..51feb39b 100644 --- a/lib/jquery.ime/jquery.ime.js +++ b/lib/jquery.ime/jquery.ime.js @@ -1,9 +1,15 @@ -/*! jquery.ime - v0.1.0+20130708 +/*! jquery.ime - v0.1.0+20130715 * https://github.com/wikimedia/jquery.ime * Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */ ( function ( $ ) { 'use strict'; + /** + * @TODO: document + * @param {Function} [options.helpHandler] Called for each input method row in the selector + * @param {Object} options.helpHandler.imeSelector + * @param {String} options.helpHandler.ime Id of the input method + */ function IME( element, options ) { this.$element = $( element ); // This needs to be delayed here since extending language list happens at DOM ready @@ -99,9 +105,9 @@ altGr = true; } - // Don't process ASCII control characters (except linefeed), - // as well as anything involving - // Alt (except for extended keymaps), Ctrl and Meta + // Don't process ASCII control characters except linefeed, + // as well as anything involving Ctrl, Meta and Alt, + // but do process extended keymaps if ( ( e.which < 32 && e.which !== 13 && !altGr ) || e.ctrlKey || e.metaKey ) { // Blank the context this.context = ''; @@ -121,9 +127,11 @@ // Get the last few characters before the one the user just typed, // to provide context for the transliteration regexes. // We need to append c because it hasn't been added to $this.val() yet - input = this.lastNChars( this.$element.val() || this.$element.text(), startPos, - this.inputmethod.maxKeyLength ) - + c; + input = this.lastNChars( + this.$element.val() || this.$element.text(), + startPos, + this.inputmethod.maxKeyLength + ) + c; replacement = this.transliterate( input, this.context, altGr ); @@ -132,8 +140,9 @@ if ( this.context.length > this.inputmethod.contextLength ) { // The buffer is longer than needed, truncate it at the front - this.context = this.context.substring( this.context.length - - this.inputmethod.contextLength ); + this.context = this.context.substring( + this.context.length - this.inputmethod.contextLength + ); } // If replacement equals to input, no replacement is made, because @@ -310,7 +319,8 @@ // default options $.ime.defaults = { imePath: '../', // Relative/Absolute path for the rules folder of jquery.ime - languages: [] // Languages to be used- by default all languages + languages: [], // Languages to be used- by default all languages + helpHandler: null // Called for each ime option in the menu }; // private function for debugging @@ -472,7 +482,7 @@ } } - function arrayKeys ( obj ) { + function arrayKeys( obj ) { var rv = []; $.each( obj, function ( key ) { rv.push( key ); @@ -562,13 +572,13 @@ focus: function () { // Hide all other IME settings and collapse open menus $( 'div.imeselector' ).hide(); - $( 'div.imeselector-menu' ).removeClass( 'open' ); + $( 'div.imeselector-menu' ).removeClass( 'ime-open' ); this.$imeSetting.show(); this.resetTimer(); }, show: function () { - this.$menu.addClass( 'open' ); + this.$menu.addClass( 'ime-open' ); this.stopTimer(); this.$imeSetting.show(); @@ -576,14 +586,14 @@ }, hide: function () { - this.$menu.removeClass( 'open' ); + this.$menu.removeClass( 'ime-open' ); this.resetTimer(); return false; }, toggle: function () { - if ( this.$menu.hasClass( 'open' ) ) { + if ( this.$menu.hasClass( 'ime-open' ) ) { this.hide(); } else { this.show(); @@ -607,7 +617,7 @@ } ); imeselector.$element.on( 'blur.ime', function () { - if ( !imeselector.$imeSetting.hasClass( 'onfocus' ) ) { + if ( !imeselector.$imeSetting.hasClass( 'ime-onfocus' ) ) { imeselector.$imeSetting.hide(); imeselector.hide(); } @@ -617,10 +627,10 @@ // We don't want the selector to disappear // while the user is trying to click it imeselector.stopTimer(); - imeselector.$imeSetting.addClass( 'onfocus' ); + imeselector.$imeSetting.addClass( 'ime-onfocus' ); } ).mouseleave( function () { imeselector.resetTimer(); - imeselector.$imeSetting.removeClass( 'onfocus' ); + imeselector.$imeSetting.removeClass( 'ime-onfocus' ); } ); imeselector.$menu.on( 'click.ime', 'li', function() { @@ -757,7 +767,7 @@ // Flip the menu to the top only if it can fit in the space there if ( menutop < top ) { this.$menu - .addClass( 'position-top' ) + .addClass( 'ime-position-top' ) .css( 'top', -menutop ); } } @@ -780,11 +790,11 @@ if ( this.$element.css( 'direction' ) === 'rtl' ) { this.$menu .css( 'left', 0 ) - .addClass( 'left' ); + .addClass( 'ime-left' ); } else { this.$menu .css( 'left', position.left ) - .addClass( 'right' ); + .addClass( 'ime-right' ); } } }, @@ -861,10 +871,10 @@ return; } - this.$menu.find( '.checked' ).removeClass( 'checked' ); - this.$menu.find( 'li.ime-disable' ).removeClass( 'checked' ); + this.$menu.find( '.ime-checked' ).removeClass( 'ime-checked' ); + this.$menu.find( 'li.ime-disable' ).removeClass( 'ime-checked' ); this.$menu.find( 'li[data-ime-inputmethod=' + inputmethodId + ']' ) - .addClass( 'checked' ); + .addClass( 'ime-checked' ); ime = this.$element.data( 'ime' ); if ( inputmethodId === 'system' ) { @@ -893,8 +903,8 @@ * Disable the inputmethods (Use the system input method) */ disableIM: function () { - this.$menu.find( '.checked' ).removeClass( 'checked' ); - this.$menu.find( 'div.ime-disable' ).addClass( 'checked' ); + this.$menu.find( '.ime-checked' ).removeClass( 'ime-checked' ); + this.$menu.find( 'div.ime-disable' ).addClass( 'ime-checked' ); this.$element.data( 'ime' ).disable(); this.$imeSetting.find( 'a.ime-name' ).text( '' ); this.hide(); @@ -936,8 +946,11 @@ continue; } - $languageItem = $( '' ).attr( 'href', '#' ).text( language.autonym ); - $language = $( '
  • ' ).attr( 'lang', languageCode ); + $languageItem = $( '' ) + .attr( 'href', '#' ) + .text( language.autonym ) + .addClass( 'selectable-row-item' ); + $language = $( '
  • ' ).attr( 'lang', languageCode ); $language.append( $languageItem ); $languageList.append( $language ); } @@ -953,32 +966,41 @@ /** * Prepare input methods in menu for the given language code * - * @param languageCode + * @param {String} languageCode */ prepareInputMethods: function ( languageCode ) { var language = $.ime.languages[languageCode], - $imeList = this.$menu.find( '.ime-list' ); + $imeList = this.$menu.find( '.ime-list' ), + imeSelector = this; $imeList.empty(); $.each( language.inputmethods, function ( index, inputmethod ) { - var name = $.ime.sources[inputmethod].name, - $imeItem = $( '' ).attr( 'href', '#' ).text( name ), - $inputMethod = $( '
  • ' ); + var $imeItem, $inputMethod, + name = $.ime.sources[inputmethod].name; + + $imeItem = $( '' ) + .attr( 'href', '#' ) + .text( name ) + .addClass( 'selectable-row-item' ); + + $inputMethod = $( '
  • ' ) + .attr( 'data-ime-inputmethod', inputmethod ) + .addClass( 'ime-im selectable-row' ) + .append( '', $imeItem ); + + if ( imeSelector.options.helpHandler ) { + $inputMethod.append( imeSelector.options.helpHandler.call( imeSelector, inputmethod ) ); + } - $inputMethod - .append( - '', - $imeItem - ) - .addClass( 'ime-im' ); $imeList.append( $inputMethod ); } ); }, helpLink: function () { - return $( '