@@ -21,48 +21,29 @@ RED.text.bidi = (function() {
2121 PDF = "\u202C" ;
2222
2323 function isRTLValue ( stringValue ) {
24- for ( var ch in stringValue ) {
25- if ( isBidiChar ( stringValue . charCodeAt ( ch ) ) ) {
24+ var length = stringValue . length ;
25+ for ( var i = 0 ; i < length ; i ++ ) {
26+ if ( isBidiChar ( stringValue . charCodeAt ( i ) ) ) {
2627 return true ;
2728 }
28- else if ( isLatinChar ( stringValue . charCodeAt ( ch ) ) ) {
29+ else if ( isLatinChar ( stringValue . charCodeAt ( i ) ) ) {
2930 return false ;
3031 }
3132 }
3233 return false ;
3334 }
3435
3536 function isBidiChar ( c ) {
36- if ( c >= 0x05d0 && c <= 0x05ff ) {
37- return true ;
38- }
39- else if ( c >= 0x0600 && c <= 0x065f ) {
40- return true ;
41- }
42- else if ( c >= 0x066a && c <= 0x06ef ) {
43- return true ;
44- }
45- else if ( c >= 0x06fa && c <= 0x07ff ) {
46- return true ;
47- }
48- else if ( c >= 0xfb1d && c <= 0xfdff ) {
49- return true ;
50- }
51- else if ( c >= 0xfe70 && c <= 0xfefc ) {
52- return true ;
53- }
54- else {
55- return false ;
56- }
37+ return ( c >= 0x05d0 && c <= 0x05ff ) ||
38+ ( c >= 0x0600 && c <= 0x065f ) ||
39+ ( c >= 0x066a && c <= 0x06ef ) ||
40+ ( c >= 0x06fa && c <= 0x07ff ) ||
41+ ( c >= 0xfb1d && c <= 0xfdff ) ||
42+ ( c >= 0xfe70 && c <= 0xfefc ) ;
5743 }
5844
5945 function isLatinChar ( c ) {
60- if ( ( c > 64 && c < 91 ) || ( c > 96 && c < 123 ) ) {
61- return true ;
62- }
63- else {
64- return false ;
65- }
46+ return ( c > 64 && c < 91 ) || ( c > 96 && c < 123 )
6647 }
6748
6849 /**
@@ -87,15 +68,17 @@ RED.text.bidi = (function() {
8768 }
8869
8970 /**
90- * Listens to keyup, paste and cut events of a given input field. Upon one of these events the text direction is computed again
71+ * Listens to keyup, paste and cut events of a given input field. Upon one
72+ * of these events the text direction is computed again
9173 * @param input - the input field
9274 */
9375 function initInputEvents ( input ) {
9476 input . on ( "keyup" , onInputChange ) . on ( "paste" , onInputChange ) . on ( "cut" , onInputChange ) ;
9577 }
9678
9779 /**
98- * Enforces the text direction of a given string by adding UCC (Unicode Control Characters)
80+ * Enforces the text direction of a given string by adding
81+ * UCC (Unicode Control Characters)
9982 * @param value - the string
10083 */
10184 function enforceTextDirectionWithUCC ( value ) {
@@ -112,7 +95,8 @@ RED.text.bidi = (function() {
11295 }
11396
11497 /**
115- * Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div
98+ * Enforces the text direction for all the spans with style bidiAware under
99+ * workspace or sidebar div
116100 */
117101 function enforceTextDirectionOnPage ( ) {
118102 $ ( "#workspace" ) . find ( 'span.bidiAware' ) . each ( function ( ) {
0 commit comments