diff --git a/src/jquery.ime.selector.js b/src/jquery.ime.selector.js index 90ba9f2b..0c8104fc 100644 --- a/src/jquery.ime.selector.js +++ b/src/jquery.ime.selector.js @@ -156,12 +156,14 @@ imeselector.$menu.on( 'click.ime', 'li.ime-im', function () { imeselector.selectIM( $( this ).data( 'ime-inputmethod' ) ); + imeselector.$element.trigger( 'setim.ime', $( this ).data( 'ime-inputmethod' ) ); return false; } ); imeselector.$menu.on( 'click.ime', 'li.ime-lang', function () { - imeselector.selectLanguage( $( this ).attr( 'lang' ) ); + var im = imeselector.selectLanguage( $( this ).attr( 'lang' ) ); + imeselector.$element.trigger( 'setim.ime', im ); return false; } ); @@ -217,9 +219,11 @@ if ( isShortcutKey( e ) ) { if ( ime.isActive() ) { this.disableIM(); + this.$element.trigget( 'setim.ime', 'system' ); } else { if ( this.inputmethod !== null ) { this.selectIM( this.inputmethod.id ); + this.$element.trigget( 'setim.ime', this.inputmethod.id ); } else { languageCode = this.decideLanguage(); this.selectLanguage( languageCode ); @@ -317,7 +321,8 @@ /** * Select a language * - * @param languageCode + * @param {string} languageCode + * @return {string|bool} Selected input method id or false */ selectLanguage: function ( languageCode ) { var ime, @@ -337,7 +342,7 @@ this.selectIM( $.ime.preferences.getIM( languageCode ) ); } - return false; + return $.ime.preferences.getIM( languageCode ); } this.$menu.find( 'li.ime-lang' ).show(); @@ -350,6 +355,7 @@ ime.setLanguage( languageCode ); this.inputmethod = null; this.selectIM( $.ime.preferences.getIM( languageCode ) ); + return $.ime.preferences.getIM( languageCode ); }, /**