Update jquery.ime from upstream

* Fixes bug 44992
* Improvements to click event handling

Change-Id: I2146340051b937cb51e7f296fd947262c781d712
This commit is contained in:
Santhosh Thottingal
2013-03-08 14:53:40 +05:30
parent ba92cb5e08
commit 0fcd17ab88

View File

@@ -1,4 +1,4 @@
/*! jquery.ime - v0.1.0 - 2013-03-06 /*! jquery.ime - v0.1.0 - 2013-03-11
* 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 ( $ ) {
@@ -536,8 +536,9 @@
}, },
focus: function () { focus: function () {
// Hide all other IME settings // Hide all other IME settings and collapse open menus
$( 'div.imeselector' ).hide(); $( 'div.imeselector' ).hide();
$( 'div.imeselector-menu' ).removeClass( 'open' );
this.$imeSetting.show(); this.$imeSetting.show();
this.resetTimer(); this.resetTimer();
}, },
@@ -555,16 +556,24 @@
return false; return false;
}, },
toggle: function () {
if ( this.$menu.hasClass( 'open' ) ) {
this.hide();
} else {
this.show();
}
},
/** /**
* Bind the events and listen * Bind the events and listen
*/ */
listen: function () { listen: function () {
var imeselector = this; var imeselector = this;
$( 'html' ).on( 'click.ime', function () { imeselector.$imeSetting.on( 'click.ime', function ( e ) {
imeselector.hide(); var t = $( e.target );
if ( imeselector.$element.is( ':hidden' ) ) { if ( t.hasClass( 'imeselector-toggle' ) ) {
imeselector.$imeSetting.hide(); imeselector.toggle();
} }
} ); } );
@@ -605,8 +614,6 @@
e.preventDefault(); e.preventDefault();
} ); } );
imeselector.$imeSetting.on( 'click.ime', $.proxy( this.show, this ) );
imeselector.$element.on( 'focus.ime', function ( e ) { imeselector.$element.on( 'focus.ime', function ( e ) {
imeselector.selectLanguage( imeselector.decideLanguage() ); imeselector.selectLanguage( imeselector.decideLanguage() );
imeselector.focus(); imeselector.focus();
@@ -667,7 +674,7 @@
- this.$imeSetting.outerWidth(); - this.$imeSetting.outerWidth();
room = $( window ).height() - top; room = $( window ).height() - top;
if ( room < this.$imeSetting.outerHeight() ) { if ( room < this.$imeSetting.outerHeight() ) {
top = top - this.$imeSetting.outerHeight(); top = position.top - this.$imeSetting.outerHeight();
this.$menu.css( 'top', this.$menu.css( 'top',
- ( this.$menu.outerHeight() + - ( this.$menu.outerHeight() +
@@ -927,9 +934,9 @@
); );
} }
var selectorTemplate = '<div class="imeselector">' var selectorTemplate = '<div class="imeselector imeselector-toggle">'
+ '<a class="ime-name imeselector-toggle" href="#"></a>' + '<a class="ime-name imeselector-toggle" href="#"></a>'
+ '<b class="ime-setting-caret"></b></div>', + '<b class="ime-setting-caret imeselector-toggle"></b></div>',
MutationObserver = window.MutationObserver || window.WebKitMutationObserver MutationObserver = window.MutationObserver || window.WebKitMutationObserver
|| window.MozMutationObserver; || window.MozMutationObserver;