summaryrefslogtreecommitdiff
path: root/lib/scripts/ajax.js
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-01-14 13:59:23 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-01-14 13:59:23 +0100
commit301971b3769a2d1a440cf58fd84f2c100a1348e3 (patch)
treeebada80e25f6e6578d601d4ab2c04fdd95bf3cd1 /lib/scripts/ajax.js
parent5ba8d196ffe346ef6fbd8e6ffc11f0c849537ed3 (diff)
downloadrpg-301971b3769a2d1a440cf58fd84f2c100a1348e3.tar.gz
rpg-301971b3769a2d1a440cf58fd84f2c100a1348e3.tar.bz2
correctly(?) shorten namespaces for RTL langunages in quicksearch
Diffstat (limited to 'lib/scripts/ajax.js')
-rw-r--r--lib/scripts/ajax.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js
index 761329f0f..d752edb38 100644
--- a/lib/scripts/ajax.js
+++ b/lib/scripts/ajax.js
@@ -38,15 +38,23 @@ addInitEvent(function () {
var links = outObj.getElementsByTagName('a');
for(var i=0; i<links.length; i++){
// maximum allowed width:
- var max = width - links[i].offsetLeft; //FIXME use offsetRight for RTL!
- if(links[i].offsetWidth < max) continue;
+ var max = width - links[i].offsetLeft;
+ var isRTL = (document.documentElement.dir == 'rtl');
+
+ if(!isRTL && links[i].offsetWidth < max) continue;
+ if(isRTL && links[i].offsetLeft > 0) continue;
var nsL = links[i].innerText.indexOf('(');
var nsR = links[i].innerText.indexOf(')');
var eli = 0;
var runaway = 0;
- while( (nsR - nsL > 3) && links[i].offsetWidth > max ){
+ while( (nsR - nsL > 3) &&
+ (
+ (!isRTL && links[i].offsetWidth > max) ||
+ (isRTL && links[i].offsetLeft < 0)
+ )
+ ){
if(runaway++ > 500) return; // just in case something went wrong
if(eli){