From 8239db58083aa228eae281a2954e3e893f369685 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 30 Nov 2009 16:45:24 +0000 Subject: [PATCH] some finetuning regarding the hack to influence the selectbox behaviorin MSIE (optgroups, positioning); --- etemplate/js/etemplate.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/etemplate/js/etemplate.js b/etemplate/js/etemplate.js index b1d84cd3fa..a14e202991 100644 --- a/etemplate/js/etemplate.js +++ b/etemplate/js/etemplate.js @@ -397,8 +397,8 @@ function dropdown_menu_hack(el) t = t.replace(/<\/option/gi,'/gi,''); + t = t.replace(/])*">/gi,'$1'); + t = t.replace(/<\/optgroup>/gi,'---'); mb.innerHTML = t; //mb.innerHTML = "
gfgfg
"; @@ -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 ="" + mb.options[i].innerHTML + ""; - mb.options[i].onmouseover = function() + if (mb.options[i].value == '') mb.options[i].innerHTML = ""+mb.options[i].innerHTML+""; + 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 ;