Merge "Update jquery.ime from upstream"
This commit is contained in:
@@ -788,8 +788,8 @@
|
|||||||
this.$element = $( element );
|
this.$element = $( element );
|
||||||
this.options = $.extend( {}, IMESelector.defaults, options );
|
this.options = $.extend( {}, IMESelector.defaults, options );
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.$imeSetting = $( selectorTemplate );
|
this.$imeSetting = null;
|
||||||
this.$menu = $( '<ul class="imeselector-menu" role="menu">' );
|
this.$menu = null;
|
||||||
this.inputmethod = null;
|
this.inputmethod = null;
|
||||||
this.init();
|
this.init();
|
||||||
this.listen();
|
this.listen();
|
||||||
@@ -800,13 +800,16 @@
|
|||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
this.prepareSelectorMenu();
|
this.prepareSelectorMenu();
|
||||||
this.$imeSetting.append( this.$menu );
|
|
||||||
this.$element.after( this.$imeSetting );
|
|
||||||
this.position();
|
this.position();
|
||||||
this.$imeSetting.hide();
|
this.$imeSetting.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
prepareSelectorMenu: function() {
|
prepareSelectorMenu: function() {
|
||||||
|
|
||||||
|
// TODO: In this approach there is a menu for each editable area.
|
||||||
|
// With correct event mapping we can probably reduce it to one menu.
|
||||||
|
this.$imeSetting = $( selectorTemplate );
|
||||||
|
this.$menu = $( '<ul class="imeselector-menu" role="menu">' );
|
||||||
this.$menu.append( imeList() );
|
this.$menu.append( imeList() );
|
||||||
this.$menu.append( toggleMenuItem() );
|
this.$menu.append( toggleMenuItem() );
|
||||||
this.$menu.append( languageListTitle() );
|
this.$menu.append( languageListTitle() );
|
||||||
@@ -815,6 +818,8 @@
|
|||||||
if ( $.i18n ) {
|
if ( $.i18n ) {
|
||||||
this.$menu.i18n();
|
this.$menu.i18n();
|
||||||
}
|
}
|
||||||
|
this.$imeSetting.append( this.$menu );
|
||||||
|
$( 'body' ).append( this.$imeSetting );
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function ( ) {
|
focus: function ( ) {
|
||||||
@@ -846,28 +851,35 @@
|
|||||||
imeselector.$menu.on( 'click.ime', 'li.ime-im', function ( e ) {
|
imeselector.$menu.on( 'click.ime', 'li.ime-im', function ( e ) {
|
||||||
imeselector.selectIM( $( this ).data( 'ime-inputmethod' ) );
|
imeselector.selectIM( $( this ).data( 'ime-inputmethod' ) );
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
imeselector.$menu.on( 'click.ime', 'li.ime-lang', function ( e ) {
|
imeselector.$menu.on( 'click.ime', 'li.ime-lang', function ( e ) {
|
||||||
imeselector.selectLanguage( $( this ).attr( 'lang' ) );
|
imeselector.selectLanguage( $( this ).attr( 'lang' ) );
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
imeselector.$menu.on( 'click.ime', 'li.ime-disable-link', function ( e ) {
|
imeselector.$menu.on( 'click.ime', 'li.ime-disable-link', function ( e ) {
|
||||||
imeselector.disableIM();
|
imeselector.disableIM();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
imeselector.$element.on( 'focus.ime', function() {
|
imeselector.$imeSetting.on( 'click.ime', $.proxy( this.toggle, this ) );
|
||||||
|
|
||||||
|
imeselector.$element.on( 'focus.ime', function ( e ) {
|
||||||
imeselector.selectLanguage( $.ime.preferences.getLanguage() );
|
imeselector.selectLanguage( $.ime.preferences.getLanguage() );
|
||||||
imeselector.focus();
|
imeselector.focus();
|
||||||
|
e.stopPropagation();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// Possible resize of textarea
|
// Possible resize of textarea
|
||||||
imeselector.$element.on( 'mouseup.ime', $.proxy( this.position, this ) );
|
imeselector.$element.on( 'mouseup.ime', $.proxy( this.position, this ) );
|
||||||
imeselector.$element.on( 'keydown.ime', $.proxy( this.keydown, this ) );
|
imeselector.$element.on( 'keydown.ime', $.proxy( this.keydown, this ) );
|
||||||
|
|
||||||
imeselector.$imeSetting.on( 'click.ime', $.proxy( this.toggle, this ) );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -903,7 +915,7 @@
|
|||||||
* Position the im selector relative to the edit area
|
* Position the im selector relative to the edit area
|
||||||
*/
|
*/
|
||||||
position: function () {
|
position: function () {
|
||||||
var position = this.$element.position();
|
var position = this.$element.offset();
|
||||||
|
|
||||||
this.$imeSetting.css( 'top', position.top + this.$element.outerHeight() );
|
this.$imeSetting.css( 'top', position.top + this.$element.outerHeight() );
|
||||||
this.$imeSetting.css( 'left', position.left + this.$element.outerWidth()
|
this.$imeSetting.css( 'left', position.left + this.$element.outerWidth()
|
||||||
|
|||||||
Reference in New Issue
Block a user