Update from upstream

Change-Id: I376b19a7c686de2769ee64f4fc8258c4b0ceec1f
This commit is contained in:
Amir E. Aharoni
2013-05-06 19:23:45 +03:00
parent 82233b95d9
commit 42fb994f0a

View File

@@ -1,4 +1,4 @@
/*! jquery.ime - v0.1.0 - 2013-04-23 /*! jquery.ime - v0.1.0 - 2013-05-06
* 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 ( $ ) {
@@ -329,6 +329,7 @@
range, range,
textInputRange, textInputRange,
len, len,
newLines,
endRange; endRange;
if ( typeof el.selectionStart === 'number' && typeof el.selectionEnd === 'number' ) { if ( typeof el.selectionStart === 'number' && typeof el.selectionEnd === 'number' ) {
@@ -341,6 +342,7 @@
if ( range && range.parentElement() === el ) { if ( range && range.parentElement() === el ) {
len = el.value.length; len = el.value.length;
normalizedValue = el.value.replace( /\r\n/g, '\n' ); normalizedValue = el.value.replace( /\r\n/g, '\n' );
newLines = normalizedValue.match( /\n/g );
// Create a working TextRange that lives only in the input // Create a working TextRange that lives only in the input
textInputRange = el.createTextRange(); textInputRange = el.createTextRange();
@@ -353,16 +355,18 @@
endRange.collapse( false ); endRange.collapse( false );
if ( textInputRange.compareEndPoints( 'StartToEnd', endRange ) > -1 ) { if ( textInputRange.compareEndPoints( 'StartToEnd', endRange ) > -1 ) {
if ( newLines ) {
start = end = len - newLines.length;
} else {
start = end = len; start = end = len;
}
} else { } else {
start = -textInputRange.moveStart( 'character', -len ); start = -textInputRange.moveStart( 'character', -len );
start += normalizedValue.slice( 0, start ).split( '\n' ).length - 1;
if ( textInputRange.compareEndPoints( 'EndToEnd', endRange ) > -1 ) { if ( textInputRange.compareEndPoints( 'EndToEnd', endRange ) > -1 ) {
end = len; end = len;
} else { } else {
end = -textInputRange.moveEnd( 'character', -len ); end = -textInputRange.moveEnd( 'character', -len );
end += normalizedValue.slice( 0, end ).split( '\n' ).length - 1;
} }
} }
} }
@@ -641,6 +645,12 @@
// 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 ) );
// Update IM selector position when window is resized
// or browser window is zoomed in or zoomed out
$( window ).resize( function () {
imeselector.position();
});
}, },
/** /**
@@ -682,8 +692,12 @@
position = this.$element.offset(); position = this.$element.offset();
top = position.top + this.$element.outerHeight(); top = position.top + this.$element.outerHeight();
left = position.left + this.$element.outerWidth() left = position.left;
- this.$imeSetting.outerWidth(); // RTL element position fix:
if ( this.$element.css( 'direction' ) === 'ltr' ) {
left = position.left + this.$element.outerWidth() -
this.$imeSetting.outerWidth();
}
room = $( window ).height() - top; room = $( window ).height() - top;
if ( room < this.$imeSetting.outerHeight() ) { if ( room < this.$imeSetting.outerHeight() ) {
@@ -709,10 +723,17 @@
} ); } );
if ( parseInt( this.$menu.css( 'min-width' ) ) > left ) { if ( parseInt( this.$menu.css( 'min-width' ) ) > left ) {
// RTL element position fix
if ( this.$element.css( 'direction' ) === 'rtl' ) {
this.$menu
.css( { left: 0 } )
.addClass( 'left' );
} else {
this.$menu this.$menu
.css( { left: position.left } ) .css( { left: position.left } )
.addClass( 'right' ); .addClass( 'right' );
} }
}
}, },
/** /**
@@ -1025,6 +1046,7 @@
}( jQuery ) ); }( jQuery ) );
( function ( $ ) { ( function ( $ ) {
'use strict'; 'use strict';