includes/clientside/static/dropdown.js
changeset 1254 221d14331ebe
parent 1227 bdac73ed481e
child 1265 7091cff2ca01
equal deleted inserted replaced
1253:13f8d373da67 1254:221d14331ebe
    58 // Initializes a div with a jBox menu in it.
    58 // Initializes a div with a jBox menu in it.
    59 function jBoxSetup(obj)
    59 function jBoxSetup(obj)
    60 {
    60 {
    61 	$dynano(obj).addClass('menu');
    61 	$dynano(obj).addClass('menu');
    62 	removeTextNodes(obj);
    62 	removeTextNodes(obj);
       
    63 	
       
    64 	var html = document.getElementsByTagName('html')[0];
       
    65 	var direction = typeof(html.dir) != 'undefined' ? html.dir : 'ltr';
    63 	
    66 	
    64 	for ( var i = 0; i < obj.childNodes.length; i++ )
    67 	for ( var i = 0; i < obj.childNodes.length; i++ )
    65 	{
    68 	{
    66 		/* normally this would be done in about 2 lines of code, but javascript is so picky..... */
    69 		/* normally this would be done in about 2 lines of code, but javascript is so picky..... */
    67 		if ( obj.childNodes[i] )
    70 		if ( obj.childNodes[i] )
    99 								var dim = fetch_dimensions(ul);
   102 								var dim = fetch_dimensions(ul);
   100 								if ( !ul.id )
   103 								if ( !ul.id )
   101 									ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
   104 									ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
   102 								jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
   105 								jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
   103 								
   106 								
   104 								if ( dim['w'] + $dynano(ul).Left() > getWidth() || $dynano(ul).hasClass('jbox_right') )
   107 								// this is a little bit of a hack
       
   108 								var should_be_right = ( direction == 'ltr' && $dynano(ul).hasClass('jbox_right') ) || ( direction == 'rtl' && !$dynano(ul).hasClass('jbox_right') );
       
   109 								
       
   110 								if ( ( direction == 'ltr' && dim['w'] + $dynano(ul).Left() > getWidth() ) || should_be_right )
   105 								{
   111 								{
   106 									$dynano(ul).addClass('jbox_right');
   112 									$dynano(ul).addClass('jbox_right');
   107 									ul.jbox_width = $dynano(ul).Width();
   113 									ul.jbox_width = $dynano(ul).Width();
       
   114 								}
       
   115 								else
       
   116 								{
       
   117 									$dynano(ul).rmClass('jbox_right');
   108 								}
   118 								}
   109 								
   119 								
   110 								ul.style.display = 'none';
   120 								ul.style.display = 'none';
   111 								domObjChangeOpac(100, ul);
   121 								domObjChangeOpac(100, ul);
   112 								
   122 								
   172 		var dim = fetch_dimensions(obj);
   182 		var dim = fetch_dimensions(obj);
   173 		var off = fetch_offset(obj);
   183 		var off = fetch_offset(obj);
   174 		var dimh = parseInt(dim['h']);
   184 		var dimh = parseInt(dim['h']);
   175 		var offtop = parseInt(off['top']);
   185 		var offtop = parseInt(off['top']);
   176 		var top = dimh + offtop;
   186 		var top = dimh + offtop;
       
   187 		
   177 		if ( $dynano(ul).hasClass('jbox_right') )
   188 		if ( $dynano(ul).hasClass('jbox_right') )
   178 		{
   189 		{
   179 			left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width
   190 			left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width
   180 		}
   191 		}
   181 		else
   192 		else