issue6, only show page selector if more then one page
[phpfspot.git] / bubble.js
index 935a7d74dbfc34dad7612b8b9c18921276b2e1f1..d44780e4ab22cb12a7402691c3c5dd195fb51515 100644 (file)
--- a/bubble.js
+++ b/bubble.js
@@ -17,9 +17,39 @@ if(typeof Array.prototype.push!="function"){
    }\r
 }\r
 \r
-function WSR_getElementsByClassName(_2,_3,_4){\r
+function WSR_getElementsByClassName(oElm, strTagName, oClassNames){\r
+   var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);\r
+   var arrReturnElements = new Array();\r
+   var arrRegExpClassNames = new Array();\r
+   if(typeof oClassNames == "object"){\r
+      for(var i=0; i<oClassNames.length; i++){\r
+         arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));\r
+      }\r
+   }\r
+   else{\r
+      arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));\r
+   }\r
+   var oElement;\r
+   var bMatchesAll;\r
+   for(var j=0; j<arrElements.length; j++){\r
+      oElement = arrElements[j];\r
+      bMatchesAll = true;\r
+      for(var k=0; k<arrRegExpClassNames.length; k++){\r
+         if(!arrRegExpClassNames[k].test(oElement.className)){\r
+            bMatchesAll = false;\r
+            break;\r
+         }\r
+      }\r
+      if(bMatchesAll){\r
+         arrReturnElements.push(oElement);\r
+      }\r
+   }\r
+   return (arrReturnElements)\r
+}\r
+/*function WSR_getElementsByClassName(_2,_3,_4){\r
 \r
    var _5=(_3=="*"&&_2.all)?_2.all:_2.getElementsByTagName(_3);\r
+         window.alert(_5[0]);\r
    var _6=new Array();\r
    _4=_4.replace(/\-/g,"\\-");\r
    var _7=new RegExp("(^|\\s)"+_4+"(\\s|$)");\r
@@ -31,20 +61,22 @@ function WSR_getElementsByClassName(_2,_3,_4){
       }\r
    }\r
    return (_6);\r
-}\r
+}*/\r
 \r
 function bindBubbles(e){\r
-   lbActions=WSR_getElementsByClassName(document,"a","bubble");\r
+   lbActions=WSR_getElementsByClassName(document,"img","thumb");\r
    for(i=0;i<lbActions.length;i++){\r
       if(window.addEventListener){ // Mozilla, Firefox\r
          lbActions[i].addEventListener("mouseover",attachBubble,false);\r
          lbActions[i].addEventListener("mouseout",detachBubble,false);\r
          lbActions[i].addEventListener("click",detachBubble,false);\r
-      }else{ // IE\r
+      }else if (window.attachEvent) { // IE\r
          lbActions[i].attachEvent("onmouseover",attachBubble);\r
          lbActions[i].attachEvent("onmouseout",detachBubble);\r
          lbActions[i].attachEvent("onclick",detachBubble);\r
-      }\r
+      } else {\r
+         // it seems this browser doesn't support any eventhandling\r
+      }  \r
    }\r
 }\r
 \r
@@ -60,54 +92,44 @@ function attachBubble(_b){
    }\r
 \r
    var _d=_c.href;\r
+\r
    var _10=document.createElement("div");\r
    document.getElementsByTagName("body")[0].appendChild(_10);\r
    _10.className="bubble";\r
 \r
-   var _e=findPos(_c)[0]+5;\r
-   var cur_height = findPos(_c)[1]-get_scroll_position() + 283;\r
+   if(BrowserDetect.browser != 'Explorer') {\r
+\r
+      var _e=findPos(_c)[0]+5;\r
+      var cur_height = findPos(_c)[1]-get_scroll_position() + 283;\r
 \r
-   // should the bubble be displayed above or below the object\r
-   if(cur_height >= get_page_height()) {\r
-      var _f=findPos(_c)[1]-363;\r
-      var _mL=2;\r
-      var _mT=39;\r
-      bubbleImage = bubbleImageUp;\r
+      // should the bubble be displayed above or below the object\r
+      if(cur_height >= get_page_height()) {\r
+         var _f=findPos(_c)[1]-363;\r
+         bubbleImage = bubbleImageUp;\r
+      }\r
+      else {\r
+         var _f=findPos(_c)[1]+17;\r
+         bubbleImage = bubbleImageDown;\r
+      }\r
    }\r
    else {\r
-      var _f=findPos(_c)[1]+17;\r
-      var _mL=2;\r
-      var _mT=34;\r
-      bubbleImage = bubbleImageDown;\r
+         var _e=findPos(_c)[0]+5;\r
+         var _f=findPos(_c)[1]+129;\r
+         bubbleImage = bubbleImageDown;\r
    }\r
-\r
    if (BrowserDetect.browser == 'Explorer') {\r
       _10.style.width="275px";\r
+      _10.style.height="275px";\r
       _10.style.position="absolute";\r
       _10.style.top=_f;\r
       _10.style.zIndex=99999;\r
       _10.style.left=_e;\r
       _10.style.textAlign="left";\r
-      _10.style.height="275px";\r
-      _10.style.paddingTop="0";\r
-      _10.style.paddingLeft="0";\r
-      _10.style.paddingBottom="0";\r
-      _10.style.paddingRight="0";\r
-      _10.style.marginTop="0";\r
-      _10.style.marginLeft="0";\r
-      _10.style.marginBottom="0";\r
-      _10.style.marginRight="0";\r
       _10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImage + "',sizingMethod='image')";\r
+   } else if (BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Konqueror' ) {\r
+      _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;");\r
    } else {\r
-      _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;");\r
-   }\r
-\r
-   if (BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Konqueror' ) {\r
-\r
-      var _height = _f;\r
-    \r
-      _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;");\r
-    \r
+      _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;");\r
    }\r
 \r
    if(cur_height >= get_page_height()) \r
@@ -115,32 +137,6 @@ function attachBubble(_b){
    else\r
       showBubbleDetails(_10, _c.id, 'down');\r
 \r
-   return;\r
-\r
-   var img=document.createElement("img");\r
-   _10.appendChild(img);\r
-\r
-   if (BrowserDetect.browser == 'Explorer') {\r
-      img.style.paddingTop="0";\r
-      img.style.paddingLeft="0";\r
-      img.style.paddingBottom="0";\r
-      img.style.paddingRight="0";\r
-      img.style.margin="auto";\r
-      img.style.marginTop=_mT;\r
-      img.style.marginLeft=_mL;\r
-      img.style.marginBottom="0";\r
-      img.style.marginRight="0";\r
-      img.style.borderTop="0";\r
-      img.style.borderLeft="0";\r
-      img.style.borderBottom="0";\r
-      img.style.borderRight="0";\r
-   } else {\r
-      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");\r
-   }\r
-   img.setAttribute("src","phpfspot_img.php?idx=" + _c.id + "&width=200");\r
-   img.setAttribute("width",202);\r
-   img.setAttribute("height",152);\r
-   img.setAttribute("alt","Snapshot");\r
 }\r
 \r
 function detachBubble(_12){\r
@@ -313,15 +309,25 @@ function get_page_height()
 \r
 function get_scroll_position()\r
 {\r
+   if (typeof window.pageYOffset != 'undefined') {\r
+      return window.pageYOffset;\r
+   }\r
+   else {\r
+      if (typeof document.compatMode != 'undefined' &&\r
+         document.compatMode != 'BackCompat' &&\r
+         typeof window.scrollTop != 'undefined')\r
+         return window.scrollTop;\r
+      else {\r
+         if(typeof document.documentElement.scrollTop != 'undefined')\r
+            return document.documentElement.scrollTop;\r
+         else {\r
+            if (typeof document.body.scrollTop != 'undefined')\r
+               return document.body.scrollTop;\r
+         }\r
+      }\r
+   }\r
 \r
-  if (typeof window.pageYOffset != 'undefined')\r
-    return window.pageYOffset;\r
-  else\r
-    if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')\r
-      return window.scrollTop;\r
-    else\r
-      if (typeof document.body != 'undefined')\r
-        return document.body.scrollTop;\r
+   return 0;\r
 \r
 }\r
 \r