Update jquery.ime from upstream
Update to:
35c7df6049
jquery.uls was updated in I245b4dd68151d9d680368d0cc5750cee4a167f50
Bug: T355104
Change-Id: I49d806c8fbfbede0e8071d31eec39099ed63d1d2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*! jquery.ime - v0.2.0+20231025
|
/*! jquery.ime - v0.2.0+20240122
|
||||||
* https://github.com/wikimedia/jquery.ime
|
* https://github.com/wikimedia/jquery.ime
|
||||||
* Copyright (c) 2023 Santhosh Thottingal; License: (GPL-2.0-or-later OR MIT) */
|
* Copyright (c) 2024 Santhosh Thottingal; License: (GPL-2.0-or-later OR MIT) */
|
||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -163,12 +163,12 @@
|
|||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {string} context
|
* @param {string} context
|
||||||
* @param {boolean} altGr whether altGr key is pressed or not
|
* @param {boolean} altGr whether altGr key is pressed or not
|
||||||
* @return {Object} Transliteration object
|
* @return {Object} Transliteration object, with the following fields:
|
||||||
* @return {boolean} return.noop Whether to consider input processed or passed through.
|
* "noop": boolean, whether to consider input processed or passed through;
|
||||||
* @return {string} return.output The transliterated input or input unmodified.
|
* "output": string, the transliterated input or input unmodified.
|
||||||
*/
|
*/
|
||||||
transliterate: function ( input, context, altGr ) {
|
transliterate: function ( input, context, altGr ) {
|
||||||
var patterns, regex, rule, replacement, i, retval;
|
var patterns, regex, contextRegex, rule, replacement, i, retval;
|
||||||
|
|
||||||
if ( altGr ) {
|
if ( altGr ) {
|
||||||
patterns = this.inputmethod.patterns_x || [];
|
patterns = this.inputmethod.patterns_x || [];
|
||||||
@@ -198,6 +198,7 @@
|
|||||||
|
|
||||||
for ( i = 0; i < patterns.length; i++ ) {
|
for ( i = 0; i < patterns.length; i++ ) {
|
||||||
rule = patterns[ i ];
|
rule = patterns[ i ];
|
||||||
|
// eslint-disable-next-line security/detect-non-literal-regexp
|
||||||
regex = new RegExp( rule[ 0 ] + '$' );
|
regex = new RegExp( rule[ 0 ] + '$' );
|
||||||
|
|
||||||
// Last item in the rules.
|
// Last item in the rules.
|
||||||
@@ -209,7 +210,9 @@
|
|||||||
if ( regex.test( input ) ) {
|
if ( regex.test( input ) ) {
|
||||||
// Context test required?
|
// Context test required?
|
||||||
if ( rule.length === 3 ) {
|
if ( rule.length === 3 ) {
|
||||||
if ( new RegExp( rule[ 1 ] + '$' ).test( context ) ) {
|
// eslint-disable-next-line security/detect-non-literal-regexp
|
||||||
|
contextRegex = new RegExp( rule[ 1 ] + '$' );
|
||||||
|
if ( contextRegex.test( context ) ) {
|
||||||
return { noop: false, output: input.replace( regex, replacement ) };
|
return { noop: false, output: input.replace( regex, replacement ) };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -285,7 +288,7 @@
|
|||||||
|
|
||||||
if ( this.context.length > this.inputmethod.contextLength ) {
|
if ( this.context.length > this.inputmethod.contextLength ) {
|
||||||
// The buffer is longer than needed, truncate it at the front
|
// The buffer is longer than needed, truncate it at the front
|
||||||
this.context = this.context.substring(
|
this.context = this.context.slice(
|
||||||
this.context.length - this.inputmethod.contextLength
|
this.context.length - this.inputmethod.contextLength
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -358,7 +361,6 @@
|
|||||||
* Set the current input method
|
* Set the current input method
|
||||||
*
|
*
|
||||||
* @param {string} inputmethodId
|
* @param {string} inputmethodId
|
||||||
* @fires imeLanguageChange
|
|
||||||
*/
|
*/
|
||||||
setIM: function ( inputmethodId ) {
|
setIM: function ( inputmethodId ) {
|
||||||
this.inputmethod = $.ime.inputmethods[ inputmethodId ];
|
this.inputmethod = $.ime.inputmethods[ inputmethodId ];
|
||||||
@@ -370,7 +372,6 @@
|
|||||||
* Set the current Language
|
* Set the current Language
|
||||||
*
|
*
|
||||||
* @param {string} languageCode
|
* @param {string} languageCode
|
||||||
* @fires imeLanguageChange
|
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
setLanguage: function ( languageCode ) {
|
setLanguage: function ( languageCode ) {
|
||||||
@@ -534,7 +535,7 @@
|
|||||||
*/
|
*/
|
||||||
FormWidgetEntry.prototype.getTextBeforeSelection = function ( maxLength ) {
|
FormWidgetEntry.prototype.getTextBeforeSelection = function ( maxLength ) {
|
||||||
var element = this.$element.get( 0 );
|
var element = this.$element.get( 0 );
|
||||||
return this.$element.val().substring(
|
return this.$element.val().slice(
|
||||||
Math.max( 0, element.selectionStart - maxLength ),
|
Math.max( 0, element.selectionStart - maxLength ),
|
||||||
element.selectionStart
|
element.selectionStart
|
||||||
);
|
);
|
||||||
@@ -554,9 +555,9 @@
|
|||||||
// But for complex scripts, browsers place cursor in unexpected places
|
// But for complex scripts, browsers place cursor in unexpected places
|
||||||
// and it's not possible to fix cursor programmatically.
|
// and it's not possible to fix cursor programmatically.
|
||||||
// Ref Bug https://bugs.webkit.org/show_bug.cgi?id=66630
|
// Ref Bug https://bugs.webkit.org/show_bug.cgi?id=66630
|
||||||
element.value = element.value.substring( 0, start - precedingCharCount ) +
|
element.value = element.value.slice( 0, start - precedingCharCount ) +
|
||||||
newText +
|
newText +
|
||||||
element.value.substring( element.selectionEnd, element.value.length );
|
element.value.slice( element.selectionEnd, element.value.length );
|
||||||
|
|
||||||
// Emit an event so that input fields that rely on events
|
// Emit an event so that input fields that rely on events
|
||||||
// work properly
|
// work properly
|
||||||
@@ -604,7 +605,7 @@
|
|||||||
if ( !range || !range.collapsed || range.startContainer.nodeType !== Node.TEXT_NODE ) {
|
if ( !range || !range.collapsed || range.startContainer.nodeType !== Node.TEXT_NODE ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return range.startContainer.nodeValue.substring(
|
return range.startContainer.nodeValue.slice(
|
||||||
Math.max( 0, range.startOffset - maxLength ),
|
Math.max( 0, range.startOffset - maxLength ),
|
||||||
range.startOffset
|
range.startOffset
|
||||||
);
|
);
|
||||||
@@ -641,9 +642,9 @@
|
|||||||
textNode = range.startContainer;
|
textNode = range.startContainer;
|
||||||
textOffset = range.startOffset;
|
textOffset = range.startOffset;
|
||||||
textNode.nodeValue =
|
textNode.nodeValue =
|
||||||
textNode.nodeValue.substr( 0, textOffset - precedingCharCount ) +
|
textNode.nodeValue.slice( 0, Math.max( 0, textOffset - precedingCharCount ) ) +
|
||||||
newText +
|
newText +
|
||||||
textNode.nodeValue.substr( textOffset );
|
textNode.nodeValue.slice( textOffset );
|
||||||
newOffset = textOffset - precedingCharCount + newText.length;
|
newOffset = textOffset - precedingCharCount + newText.length;
|
||||||
newRange.setStart( range.startContainer, newOffset );
|
newRange.setStart( range.startContainer, newOffset );
|
||||||
newRange.setEnd( range.startContainer, newOffset );
|
newRange.setEnd( range.startContainer, newOffset );
|
||||||
@@ -1068,7 +1069,6 @@
|
|||||||
/**
|
/**
|
||||||
* Keydown event handler. Handles shortcut key presses
|
* Keydown event handler. Handles shortcut key presses
|
||||||
*
|
*
|
||||||
* @this HTMLElement
|
|
||||||
* @param {jQuery.Event} e
|
* @param {jQuery.Event} e
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ Any valid regular expression is possible as first element of each array item.
|
|||||||
ex: `[ '([ക-ഹ])a', '$1ാ' ]`
|
ex: `[ '([ക-ഹ])a', '$1ാ' ]`
|
||||||
ex: `[ '(([ൺ-ൿം])\u200c+)?I', '$2ഐ' ]`
|
ex: `[ '(([ൺ-ൿം])\u200c+)?I', '$2ഐ' ]`
|
||||||
|
|
||||||
In the above example, $1, $1 etc are according to the normal regular expression
|
In the above example, $1, $2 etc are according to the normal regular expression
|
||||||
replace syntax.
|
replace syntax.
|
||||||
|
|
||||||
The second member of the pattern can be a function as well.
|
The second member of the pattern can be a function as well.
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
[ 'V', '᯦' ],
|
[ 'V', '᯦' ],
|
||||||
[ 'B', 'ᯆ' ],
|
[ 'B', 'ᯆ' ],
|
||||||
[ 'N', 'ᯊ' ],
|
[ 'N', 'ᯊ' ],
|
||||||
[ 'M', 'ᯕ' ],
|
[ 'M', 'ᯕ' ]
|
||||||
],
|
],
|
||||||
patterns_x: [
|
patterns_x: [
|
||||||
[ '4', '᯼' ],
|
[ '4', '᯼' ],
|
||||||
@@ -77,4 +77,4 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.ime.register( tobaKbd );
|
$.ime.register( tobaKbd );
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
maxKeyLength: 5,
|
maxKeyLength: 5,
|
||||||
patterns: [
|
patterns: [
|
||||||
/* eslint-disable max-statements-per-line */
|
/* eslint-disable max-statements-per-line */
|
||||||
|
/* eslint-disable brace-style */
|
||||||
[ ' ', function () { reinit(); return '་'; } ],
|
[ ' ', function () { reinit(); return '་'; } ],
|
||||||
[ '\\.', function () { reinit(); return ' '; } ],
|
[ '\\.', function () { reinit(); return ' '; } ],
|
||||||
[ ',', function () { reinit(); return '།'; } ],
|
[ ',', function () { reinit(); return '།'; } ],
|
||||||
@@ -183,6 +184,7 @@
|
|||||||
[ '8', function () { reinit(); return '༨'; } ],
|
[ '8', function () { reinit(); return '༨'; } ],
|
||||||
[ '9', function () { reinit(); return '༩'; } ]
|
[ '9', function () { reinit(); return '༩'; } ]
|
||||||
/* eslint-enable max-statements-per-line */
|
/* eslint-enable max-statements-per-line */
|
||||||
|
/* eslint-enable brace-style */
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var mandailingTransliteration = {
|
var mandailingTransliteration = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var jvKeyboard = {
|
var jvKeyboard = {
|
||||||
@@ -33,4 +33,4 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.ime.register( jvKeyboard );
|
$.ime.register( jvKeyboard );
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var suKeyboard = {
|
var suKeyboard = {
|
||||||
@@ -17,4 +17,4 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.ime.register( suKeyboard );
|
$.ime.register( suKeyboard );
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user