some finetuning regarding the hack to influence the selectbox behaviorin MSIE (optgroups, positioning);

This commit is contained in:
Klaus Leithoff 2009-11-30 16:45:24 +00:00
parent 488d34d820
commit 8239db5808

View File

@ -397,8 +397,8 @@ function dropdown_menu_hack(el)
t = t.replace(/<\/option/gi,'</span');
//alert("4"+t);
t = t.replace(/<\/select/gi,'</div');
//t = t.replace(/<optgroup label/gi,'<span value');
//t = t.replace(/<\/optgroup>/gi,'</span>');
t = t.replace(/<optgroup label=\"([\w\s\wäöüßÄÖÜ]*[^>])*">/gi,'<span value="">$1</span>');
t = t.replace(/<\/optgroup>/gi,'<span value="">---</span>');
mb.innerHTML = t;
//mb.innerHTML = "<div><span value='dd:ff'>gfgfg</span></div>";
@ -410,10 +410,12 @@ function dropdown_menu_hack(el)
{
//alert('Value:'+mb.options[i].value + ', Text:'+ mb.options[i].innerHTML);
mb.options[i].selectedIndex = i;
mb.options[i].style.cssText = "list-style:none;margin:0;padding:1px 2px;width/**/:100%;cursor:hand;cursor:pointer;white-space:nowrap;"
mb.options[i].style.cssText = "list-style:none;margin:0;padding:1px 2px;width/**/:100%;white-space:nowrap;"
if (mb.options[i].value != '') mb.options[i].style.cssText = mb.options[i].style.cssText + "cursor:hand;cursor:pointer;";
mb.options[i].title =mb.options[i].innerHTML;
mb.options[i].innerHTML ="<nobr>" + mb.options[i].innerHTML + "</nobr>";
mb.options[i].onmouseover = function()
if (mb.options[i].value == '') mb.options[i].innerHTML = "<b><i>"+mb.options[i].innerHTML+"</b></i>";
if (mb.options[i].value != '') mb.options[i].onmouseover = function()
{
if( mb.options.selected )
{mb.options.selected.style.background="white";mb.options.selected.style.color="black";}
@ -421,8 +423,11 @@ function dropdown_menu_hack(el)
this.style.background="#333366";this.style.color="white";
}
mb.options[i].onmouseout = function(){this.style.background="white";this.style.color="black";}
mb.options[i].onmousedown = function(){selectMenu(this); }
mb.options[i].onkeydown = function(){selectMenu(this); }
if (mb.options[i].value != '')
{
mb.options[i].onmousedown = function(){selectMenu(this); }
mb.options[i].onkeydown = function(){selectMenu(this); }
}
if(i == el.contentIndex)
{
mb.options[i].style.background="#333366";
@ -434,6 +439,14 @@ function dropdown_menu_hack(el)
mw = Math.max( mw, ( mb.scrollWidth+22) );
var mh = mb.options.length * 15 + 8 ;
var mx = (ie5)?-3:0;
var docW = document.documentElement.offsetWidth ;
var sideW = docW - el.getBoundingClientRect().left ;
if (sideW < mw)
{
//alert(el.getBoundingClientRect().left+' Avail: '+docW+' Mx:'+mx+' My:'+my);
// if it does not fit into the window on the right side, move it to the left
mx = mx -mw + sideW-5;
}
var my = el.offsetHeight -2;
my=my+5;
var docH = document.documentElement.offsetHeight ;