Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75077


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

Update jquery.ime from upstream

Change-Id: Ieb29f2cb90862a9ffb61309dc5cbc351e79074f1
Version: v0.1.0+20130722
Upstream: http://github.com/wikimedia/jquery.ime
Bug: 50939
---
M lib/jquery.ime/css/jquery.ime.css
M lib/jquery.ime/jquery.ime.js
2 files changed, 84 insertions(+), 33 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/77/75077/1

diff --git a/lib/jquery.ime/css/jquery.ime.css 
b/lib/jquery.ime/css/jquery.ime.css
index c2b3632..5894f0f 100644
--- a/lib/jquery.ime/css/jquery.ime.css
+++ b/lib/jquery.ime/css/jquery.ime.css
@@ -168,7 +168,7 @@
 
 .imeselector-menu .ime-checked {
        /* @embed */
-       background: url(../images/tick.png) left 4px center no-repeat;
+       background: url(../images/tick.png) no-repeat left 4px center;
        background-image: -webkit-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');
diff --git a/lib/jquery.ime/jquery.ime.js b/lib/jquery.ime/jquery.ime.js
index 51feb39..8bb1ff9 100644
--- a/lib/jquery.ime/jquery.ime.js
+++ b/lib/jquery.ime/jquery.ime.js
@@ -1,11 +1,11 @@
-/*! jquery.ime - v0.1.0+20130715
+/*! jquery.ime - v0.1.0+20130722
 * https://github.com/wikimedia/jquery.ime
 * Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */
 ( function ( $ ) {
        'use strict';
 
        /**
-        * @TODO: document
+        * IME Class
         * @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
@@ -26,6 +26,9 @@
        IME.prototype = {
                constructor: IME,
 
+               /**
+                * Listen for events and bind to handlers
+                */
                listen: function () {
                        this.$element.on( 'keypress.ime', $.proxy( 
this.keypress, this ) );
                        this.$element.on( 'destroy.ime', $.proxy( this.destroy, 
this ) );
@@ -37,10 +40,10 @@
                 * Transliterate a given string input based on context and 
input method definition.
                 * If there are no matching rules defined, returns the original 
string.
                 *
-                * @param input
-                * @param context
-                * @param altGr bool whether altGr key is pressed or not
-                * @returns String transliterated string
+                * @param {string} input
+                * @param {string} context
+                * @param {boolean} altGr whether altGr key is pressed or not
+                * @returns {string} transliterated string
                 */
                transliterate: function ( input, context, altGr ) {
                        var patterns, regex, rule, replacement, i;
@@ -82,6 +85,11 @@
                        return input;
                },
 
+               /**
+                * Keypress handler
+                * @param {jQuery.Event} e Event
+                * @returns {Boolean}
+                */
                keypress: function ( e ) {
                        var altGr = false,
                                c, startPos, pos, endPos, divergingPos, input, 
replacement;
@@ -164,37 +172,66 @@
                        return false;
                },
 
+               /**
+                * Check whether the input method is active or not
+                * @returns {Boolean}
+                */
                isActive: function () {
                        return this.active;
                },
 
+               /**
+                * Disable the input method
+                */
                disable: function () {
                        this.active = false;
                        $.ime.preferences.setIM( 'system' );
                },
 
+               /**
+                * Enable the input method
+                */
                enable: function () {
                        this.active = true;
                },
 
+               /**
+                * Toggle the active state of input method
+                */
                toggle: function () {
                        this.active = !this.active;
                },
 
+               /**
+                * Destroy the binding of ime to the editable element
+                */
                destroy: function () {
                        $( 'body' ).off( '.ime' );
                        this.$element.off( '.ime' ).removeData( 'ime' 
).removeData( 'imeselector' );
                },
 
+               /**
+                * Get the current input method
+                * @returns {string} Current input method id
+                */
                getIM: function () {
                        return this.inputmethod;
                },
 
+               /**
+                * Set the current input method
+                * @param {string} inputmethodId
+                */
                setIM: function ( inputmethodId ) {
                        this.inputmethod = $.ime.inputmethods[inputmethodId];
                        $.ime.preferences.setIM( inputmethodId );
                },
 
+               /**
+                * Set the current Language
+                * @param {string} languageCode
+                * @returns {Boolean}
+                */
                setLanguage: function ( languageCode ) {
                        if ( !$.ime.languages[languageCode] ) {
                                debug( 'Language ' + languageCode + ' is not 
known to jquery.ime.' );
@@ -207,43 +244,49 @@
                        return true;
                },
 
+               /**
+                * Get current language
+                * @returns {string}
+                */
                getLanguage: function () {
                        return this.language;
                },
 
-               load: function ( name, callback ) {
+               /**
+                * load an input method by given id
+                * @param {string} inputmethodId
+                * @return {jQuery.Promise}
+                */
+               load: function ( inputmethodId ) {
                        var ime = this,
+                               deferred = $.Deferred(),
                                dependency;
 
-                       if ( $.ime.inputmethods[name] ) {
-                               if ( callback ) {
-                                       callback.call( ime );
-                               }
-
-                               return true;
+                       if ( $.ime.inputmethods[inputmethodId] ) {
+                               return deferred.resolve();
                        }
 
-                       dependency = $.ime.sources[name].depends;
+                       dependency = $.ime.sources[inputmethodId].depends;
                        if ( dependency ) {
-                               this.load( dependency ) ;
+                               return $.when( this.load( dependency ), 
this.load( inputmethodId ) );
                        }
 
-                       $.ajax( {
-                               url: ime.options.imePath + 
$.ime.sources[name].source,
-                               dataType: 'script'
-                       } ).done( function () {
-                               debug( name + ' loaded' );
-
-                               if ( callback ) {
-                                       callback.call( ime );
-                               }
+                       deferred = $.getScript(
+                               ime.options.imePath + 
$.ime.sources[inputmethodId].source
+                       ).done( function () {
+                               debug( inputmethodId + ' loaded' );
                        } ).fail( function ( jqxhr, settings, exception ) {
-                               debug( 'Error in loading inputmethod ' + name + 
' Exception: ' + exception );
+                               debug( 'Error in loading inputmethod ' + 
inputmethodId + ' Exception: ' + exception );
                        } );
+
+                       return deferred.promise();
                },
 
-               // Returns an array [start, end] of the beginning
-               // and the end of the current selection in $element
+               /**
+                * Returns an array [start, end] of the beginning
+                * and the end of the current selection in $element
+                * @returns {Array}
+                */
                getCaretPosition: function ( $element ) {
                        return getCaretPosition( $element );
                },
@@ -274,6 +317,10 @@
                }
        };
 
+       /**
+        * jQuery plugin ime
+        * @param {Object} option
+        */
        $.fn.ime = function ( option ) {
                return this.each( function () {
                        var data,
@@ -323,15 +370,19 @@
                helpHandler: null // Called for each ime option in the menu
        };
 
-       // private function for debugging
+       /**
+        * private function for debugging
+        */
        function debug( $obj ) {
                if ( window.console && window.console.log ) {
                        window.console.log( $obj );
                }
        }
 
-       // Returns an array [start, end] of the beginning
-       // and the end of the current selection in $element
+       /**
+        * Returns an array [start, end] of the beginning
+        * and the end of the current selection in $element
+        */
        function getCaretPosition( $element ) {
                var el = $element.get( 0 ),
                        start = 0,
@@ -883,13 +934,13 @@
                                return;
                        }
 
-                       ime.load( inputmethodId, function () {
+                       ime.load( inputmethodId ).done( function () {
                                imeselector.inputmethod = 
$.ime.inputmethods[inputmethodId];
                                imeselector.hide();
                                ime.enable();
                                ime.setIM( inputmethodId );
                                imeselector.$imeSetting.find( 'a.ime-name' 
).text(
-                                       imeselector.inputmethod.name
+                                       $.ime.sources[inputmethodId].name
                                );
 
                                imeselector.position();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb29f2cb90862a9ffb61309dc5cbc351e79074f1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to