X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=bubble.js;h=1d715b10cd3147733b12c6e2ae654c4558ce47c4;hp=39ae03e407bf9d3c3a9c5008f77f3aa90582f104;hb=98981ed7be1109d8e6f3b0f4a3a18e875e28b652;hpb=fb15deeef32d80ef922a578d742ff49633d5f94e diff --git a/bubble.js b/bubble.js index 39ae03e..1d715b1 100644 --- a/bubble.js +++ b/bubble.js @@ -6,7 +6,8 @@ */ // Point this variable to the correct location of the bg.png file -var bubbleImagePath = 'resources/bubble_bg.png'; +var bubbleImageUp = 'resources/bubble_up.png'; +var bubbleImageDown = 'resources/bubble_down.png'; if(typeof Array.prototype.push!="function"){ Array.prototype.push=ArrayPush; @@ -38,9 +39,11 @@ function bindBubbles(e){ if(window.addEventListener){ lbActions[i].addEventListener("mouseover",attachBubble,false); lbActions[i].addEventListener("mouseout",detachBubble,false); + lbActions[i].addEventListener("click",detachBubble,false); }else{ lbActions[i].attachEvent("onmouseover",attachBubble); lbActions[i].attachEvent("onmouseout",detachBubble); + lbActions[i].attachEvent("onclick",detachBubble); } } } @@ -57,20 +60,35 @@ function attachBubble(_b){ } var _d=_c.href; - var _e=findPos(_c)[0]+5; - var _f=findPos(_c)[1]+17; var _10=document.createElement("div"); document.getElementsByTagName("body")[0].appendChild(_10); _10.className="bubble"; + var _e=findPos(_c)[0]+5; + var cur_height = findPos(_c)[1]-get_scroll_position() + 283; + + // should the bubble be displayed above or below the object + if(cur_height >= get_page_height()) { + var _f=findPos(_c)[1]-363; + var _mL=2; + var _mT=39; + bubbleImage = bubbleImageUp; + } + else { + var _f=findPos(_c)[1]+17; + var _mL=2; + var _mT=34; + bubbleImage = bubbleImageDown; + } + if (BrowserDetect.browser == 'Explorer') { - _10.style.width="240px"; + _10.style.width="275px"; _10.style.position="absolute"; _10.style.top=_f; _10.style.zIndex=99999; _10.style.left=_e; _10.style.textAlign="left"; - _10.style.height="190px"; + _10.style.height="275px"; _10.style.paddingTop="0"; _10.style.paddingLeft="0"; _10.style.paddingBottom="0"; @@ -79,19 +97,26 @@ function attachBubble(_b){ _10.style.marginLeft="0"; _10.style.marginBottom="0"; _10.style.marginRight="0"; - _10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImagePath + "',sizingMethod='image')"; + _10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImage + "',sizingMethod='image')"; } else { - _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+_f+"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;"); + _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+_f+"px ; left: "+_e+"px ; background: url("+ bubbleImage +") no-repeat; width: 275px; height: 275px; padding: 0; margin: 0;"); } if (BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Konqueror' ) { var _height = _f; - _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+ _height +"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;"); + _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+ _height +"px ; left: "+_e+"px ; background: url("+ bubbleImage +") no-repeat; width: 275px; height: 275px; padding: 0; margin: 0;"); } + if(cur_height >= get_page_height()) + showBubbleDetails(_10, _c.id, 'up'); + else + showBubbleDetails(_10, _c.id, 'down'); + + return; + var img=document.createElement("img"); _10.appendChild(img); @@ -101,8 +126,8 @@ function attachBubble(_b){ img.style.paddingBottom="0"; img.style.paddingRight="0"; img.style.margin="auto"; - img.style.marginTop="27px"; - img.style.marginLeft="25px"; + img.style.marginTop=_mT; + img.style.marginLeft=_mL; img.style.marginBottom="0"; img.style.marginRight="0"; img.style.borderTop="0"; @@ -110,7 +135,7 @@ function attachBubble(_b){ img.style.borderBottom="0"; img.style.borderRight="0"; } else { - img.setAttribute("style","padding-top: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; margin-top: 27px; margin-left: 12px; margin-bottom: 0; margin-right: 0; border: 0"); + img.setAttribute("style","padding-top: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; margin-top: " + _mT +"px; margin-left: " + _mL +"px; margin-bottom: 0; margin-right: 0; border: 0"); } img.setAttribute("src","phpfspot_img.php?idx=" + _c.id + "&width=200"); img.setAttribute("width",202); @@ -125,12 +150,6 @@ function detachBubble(_12){ } } -/*if(window.addEventListener){ - addEventListener("load",bindBubbles,false); -}else{ - attachEvent("onload",bindBubbles); -}*/ - function findPos(obj){ var _14=curtop=0; if(obj.offsetParent){ @@ -257,5 +276,35 @@ function var_dump(obj) { } }//end function var_dump +function get_page_height() +{ + var myHeight = 0; + if( typeof( window.innerHeight ) == 'number' ) { + //Non-IE + myHeight = window.innerHeight; + } else if( document.documentElement && document.documentElement.clientHeight ) { + //IE 6+ in 'standards compliant mode' + myHeight = document.documentElement.clientHeight; + } else if( document.body && document.body.clientHeight ) { + //IE 4 compatible + myHeight = document.body.clientHeight; + } + + return myHeight; +} + +function get_scroll_position() +{ + + if (typeof window.pageYOffset != 'undefined') + return window.pageYOffset; + else + if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') + return window.scrollTop; + else + if (typeof document.body != 'undefined') + return document.body.scrollTop; + +} BrowserDetect.init();