1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Change the PDFJS.bidi function calls slightly to avoid creating a seperate object to pass to PDF.JS bidi and just pass in a string

This commit is contained in:
Julian Viereck 2012-09-11 16:42:24 -07:00
parent 3db4e7266e
commit 83c499595c
2 changed files with 21 additions and 12 deletions

View file

@ -138,11 +138,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
}
}
function bidi(text, startLevel) {
var str = text.str;
function bidiResult(content, direction) {
this.content = content;
this.direction = direction;
}
function bidi(str, startLevel) {
var direction = '';
var strLength = str.length;
if (strLength == 0)
return str;
return new bidiResult(str, direction);
// get types, fill arrays
@ -176,16 +181,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
// if less than 30% chars are rtl then string is primarily ltr
// if more than 30% chars are rtl then string is primarily rtl
if (numBidi == 0) {
text.direction = 'ltr';
return str;
direction = 'ltr';
return new bidiResult(str, direction);
}
if (startLevel == -1) {
if ((strLength / numBidi) < 0.3) {
text.direction = 'ltr';
direction = 'ltr';
startLevel = 0;
} else {
text.direction = 'rtl';
direction = 'rtl';
startLevel = 1;
}
}
@ -438,7 +443,8 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
if (ch != '<' && ch != '>')
result += ch;
}
return result;
return new bidiResult(str, direction);
}
return bidi;