1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix some more tabs/spaces in bidi work

This commit is contained in:
Nick O'Leary 2016-08-26 00:28:22 +01:00
parent 6ad71bd222
commit b17c34402d
6 changed files with 27 additions and 43 deletions

View File

@ -21,11 +21,12 @@ RED.text.bidi = (function() {
PDF = "\u202C"; PDF = "\u202C";
function isRTLValue(stringValue) { function isRTLValue(stringValue) {
for (var ch in stringValue) { var length = stringValue.length;
if (isBidiChar(stringValue.charCodeAt(ch))) { for (var i=0;i<length;i++) {
if (isBidiChar(stringValue.charCodeAt(i))) {
return true; return true;
} }
else if(isLatinChar(stringValue.charCodeAt(ch))) { else if(isLatinChar(stringValue.charCodeAt(i))) {
return false; return false;
} }
} }
@ -33,36 +34,16 @@ RED.text.bidi = (function() {
} }
function isBidiChar(c) { function isBidiChar(c) {
if (c >= 0x05d0 && c <= 0x05ff) { return (c >= 0x05d0 && c <= 0x05ff)||
return true; (c >= 0x0600 && c <= 0x065f)||
} (c >= 0x066a && c <= 0x06ef)||
else if (c >= 0x0600 && c <= 0x065f) { (c >= 0x06fa && c <= 0x07ff)||
return true; (c >= 0xfb1d && c <= 0xfdff)||
} (c >= 0xfe70 && c <= 0xfefc);
else if (c >= 0x066a && c <= 0x06ef) {
return true;
}
else if (c >= 0x06fa && c <= 0x07ff) {
return true;
}
else if (c >= 0xfb1d && c <= 0xfdff) {
return true;
}
else if (c >= 0xfe70 && c <= 0xfefc) {
return true;
}
else {
return false;
}
} }
function isLatinChar(c){ function isLatinChar(c){
if((c > 64 && c < 91)||(c > 96 && c < 123)) { return (c > 64 && c < 91)||(c > 96 && c < 123)
return true;
}
else {
return false;
}
} }
/** /**
@ -87,7 +68,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Listens to keyup, paste and cut events of a given input field. Upon one of these events the text direction is computed again * Listens to keyup, paste and cut events of a given input field. Upon one
* of these events the text direction is computed again
* @param input - the input field * @param input - the input field
*/ */
function initInputEvents(input) { function initInputEvents(input) {
@ -95,7 +77,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Enforces the text direction of a given string by adding UCC (Unicode Control Characters) * Enforces the text direction of a given string by adding
* UCC (Unicode Control Characters)
* @param value - the string * @param value - the string
*/ */
function enforceTextDirectionWithUCC(value) { function enforceTextDirectionWithUCC(value) {
@ -112,7 +95,8 @@ RED.text.bidi = (function() {
} }
/** /**
* Enforces the text direction for all the spans with style bidiAware under workpsace or sidebar div * Enforces the text direction for all the spans with style bidiAware under
* workspace or sidebar div
*/ */
function enforceTextDirectionOnPage() { function enforceTextDirectionOnPage() {
$("#workspace").find('span.bidiAware').each(function() { $("#workspace").find('span.bidiAware').each(function() {