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
* Copyright (c) 2013 Santhosh Thottingal; Licensed GPL, MIT */
( function ( $ ) {
@@ -329,6 +329,7 @@
range,
textInputRange,
len,
newLines,
endRange;
if ( typeof el.selectionStart === 'number' && typeof el.selectionEnd === 'number' ) {
@@ -341,6 +342,7 @@
if ( range && range.parentElement() === el ) {
len = el.value.length;
normalizedValue = el.value.replace( /\r\n/g, '\n' );
newLines = normalizedValue.match( /\n/g );
// Create a working TextRange that lives only in the input
textInputRange = el.createTextRange();
@@ -353,16 +355,18 @@
endRange.collapse( false );
if ( textInputRange.compareEndPoints( 'StartToEnd', endRange ) > -1 ) {
start = end = len;
if ( newLines ) {
start = end = len - newLines.length;
} else {
start = end = len;
}
} else {
start = -textInputRange.moveStart( 'character', -len );
start += normalizedValue.slice( 0, start ).split( '\n' ).length - 1;
if ( textInputRange.compareEndPoints( 'EndToEnd', endRange ) > -1 ) {
end = len;
} else {
end = -textInputRange.moveEnd( 'character', -len );
end += normalizedValue.slice( 0, end ).split( '\n' ).length - 1;
}
}
}
@@ -641,6 +645,12 @@
// Possible resize of textarea
imeselector.$element.on( 'mouseup.ime', $.proxy( this.position, 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();
top = position.top + this.$element.outerHeight();
left = position.left + this.$element.outerWidth()
- this.$imeSetting.outerWidth();
left = position.left;
// RTL element position fix:
if ( this.$element.css( 'direction' ) === 'ltr' ) {
left = position.left + this.$element.outerWidth() -
this.$imeSetting.outerWidth();
}
room = $( window ).height() - top;
if ( room < this.$imeSetting.outerHeight() ) {
@@ -709,9 +723,16 @@
} );
if ( parseInt( this.$menu.css( 'min-width' ) ) > left ) {
this.$menu
// RTL element position fix
if ( this.$element.css( 'direction' ) === 'rtl' ) {
this.$menu
.css( { left: 0 } )
.addClass( 'left' );
} else {
this.$menu
.css( { left: position.left } )
.addClass( 'right' );
}
}
},
@@ -1025,6 +1046,7 @@
}( jQuery ) );
( function ( $ ) {
'use strict';