jenkins-bot has submitted this change and it was merged.

Change subject: Update jquery.ime from upstream
......................................................................


Update jquery.ime from upstream

This should fix bug 54646.

Change-Id: Ibda702d1b92f160de426ebdb05b00d38a1ff5c0d
---
M lib/jquery.ime/jquery.ime.js
1 file changed, 33 insertions(+), 19 deletions(-)

Approvals:
  Siebrand: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/jquery.ime/jquery.ime.js b/lib/jquery.ime/jquery.ime.js
index 9eff994..7663347 100644
--- a/lib/jquery.ime/jquery.ime.js
+++ b/lib/jquery.ime/jquery.ime.js
@@ -1,4 +1,4 @@
-/*! jquery.ime - v0.1.0+20131111
+/*! jquery.ime - v0.1.0+20131123
 * https://github.com/wikimedia/jquery.ime
 * Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */
 ( function ( $ ) {
@@ -49,10 +49,12 @@
                 * @param {string} input
                 * @param {string} context
                 * @param {boolean} altGr whether altGr key is pressed or not
-                * @returns {string} transliterated string
+                * @returns {object} transliteration object
+                * @returns {bool} return.noop Whether to consider input 
processed or passed through.
+                * @returns {string} return.output the transliterated input or 
input unmodified.
                 */
                transliterate: function ( input, context, altGr ) {
-                       var patterns, regex, rule, replacement, i;
+                       var patterns, regex, rule, replacement, i, retval;
 
                        if ( altGr ) {
                                patterns = this.inputmethod.patterns_x || [];
@@ -69,7 +71,15 @@
                        }
 
                        if ( $.isFunction( patterns ) ) {
-                               return patterns.call( this, input, context );
+                               // For backwards compatibility, allow the rule 
functions to return plain
+                               // string. Determine noop by checking whether 
input is different from
+                               // output. If the rule function returns object, 
just return it as-is.
+                               retval = patterns.call( this, input, context );
+                               if ( typeof retval === 'string' ) {
+                                       return { noop: input === retval, 
output: retval };
+                               }
+
+                               return retval;
                        }
 
                        for ( i = 0; i < patterns.length; i++ ) {
@@ -86,17 +96,16 @@
                                        // Context test required?
                                        if ( rule.length === 3 ) {
                                                if ( new RegExp( rule[1] + '$' 
).test( context ) ) {
-                                                       return input.replace( 
regex, replacement );
+                                                       return { noop: false, 
output: input.replace( regex, replacement ) };
                                                }
                                        } else {
-                                               // No context test required. 
Just replace.
-                                               return input.replace( regex, 
replacement );
+                                               return { noop: false, output: 
input.replace( regex, replacement ) };
                                        }
                                }
                        }
 
                        // No matches, return the input
-                       return input;
+                       return { noop: true, output: input };
                },
 
                keyup: function ( e ) {
@@ -180,20 +189,20 @@
                                );
                        }
 
-                       // If replacement equals to input, no replacement is 
made, because
-                       // there's apparently nothing to do. However, there may 
be something
-                       // to do if AltGr was pressed. For example, if a layout 
is built in
-                       // a way that allows typing the original character 
instead of
-                       // the replacement by pressing it with AltGr.
-                       if ( !altGr && replacement === input ) {
+                       // Allow rules to explicitly define whether we match 
something.
+                       // Otherwise we cannot distinguish between no matching 
rule and
+                       // rule that provides identical output but consumes the 
event
+                       // to prevent normal behavior. See Udmurt layout which 
uses
+                       // altgr rules to allow typing the original character.
+                       if ( replacement.noop ) {
                                return true;
                        }
 
                        // Drop a common prefix, if any
-                       divergingPos = this.firstDivergence( input, replacement 
);
+                       divergingPos = this.firstDivergence( input, 
replacement.output );
                        input = input.substring( divergingPos );
-                       replacement = replacement.substring( divergingPos );
-                       replaceText( this.$element, replacement, startPos - 
input.length + 1, endPos );
+                       replacement.output = replacement.output.substring( 
divergingPos );
+                       replaceText( this.$element, replacement.output, 
startPos - input.length + 1, endPos );
 
                        e.stopPropagation();
 
@@ -1284,8 +1293,13 @@
                        $imeList.empty();
 
                        $.each( language.inputmethods, function ( index, 
inputmethod ) {
-                               var $imeItem, $inputMethod,
-                                       name = $.ime.sources[inputmethod].name;
+                               var $imeItem, $inputMethod, source, name;
+
+                               source = $.ime.sources[inputmethod];
+                               if ( !source ) {
+                                       return;
+                               }
+                               name = source.name;
 
                                $imeItem = $( '<a>' )
                                        .attr( 'href', '#' )

-- 
To view, visit https://gerrit.wikimedia.org/r/97068
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibda702d1b92f160de426ebdb05b00d38a1ff5c0d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to