includes/clientside/static/dropdown.js
changeset 1254 221d14331ebe
parent 1227 bdac73ed481e
child 1265 7091cff2ca01
--- a/includes/clientside/static/dropdown.js	Mon Jun 28 10:43:04 2010 -0400
+++ b/includes/clientside/static/dropdown.js	Mon Jun 28 13:31:21 2010 -0400
@@ -61,6 +61,9 @@
 	$dynano(obj).addClass('menu');
 	removeTextNodes(obj);
 	
+	var html = document.getElementsByTagName('html')[0];
+	var direction = typeof(html.dir) != 'undefined' ? html.dir : 'ltr';
+	
 	for ( var i = 0; i < obj.childNodes.length; i++ )
 	{
 		/* normally this would be done in about 2 lines of code, but javascript is so picky..... */
@@ -101,11 +104,18 @@
 									ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
 								jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
 								
-								if ( dim['w'] + $dynano(ul).Left() > getWidth() || $dynano(ul).hasClass('jbox_right') )
+								// this is a little bit of a hack
+								var should_be_right = ( direction == 'ltr' && $dynano(ul).hasClass('jbox_right') ) || ( direction == 'rtl' && !$dynano(ul).hasClass('jbox_right') );
+								
+								if ( ( direction == 'ltr' && dim['w'] + $dynano(ul).Left() > getWidth() ) || should_be_right )
 								{
 									$dynano(ul).addClass('jbox_right');
 									ul.jbox_width = $dynano(ul).Width();
 								}
+								else
+								{
+									$dynano(ul).rmClass('jbox_right');
+								}
 								
 								ul.style.display = 'none';
 								domObjChangeOpac(100, ul);
@@ -174,6 +184,7 @@
 		var dimh = parseInt(dim['h']);
 		var offtop = parseInt(off['top']);
 		var top = dimh + offtop;
+		
 		if ( $dynano(ul).hasClass('jbox_right') )
 		{
 			left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width