Attachment 'infobox.js'

Download

   1 //
   2 // Bubblehelp infoboxes, (C) 2002 Klaus Knopper <infobox@knopper.net>
   3 // You can copy/modify and distribute this code under the conditions
   4 // of the GNU GENERAL PUBLIC LICENSE Version 2.
   5 //
   6 var IWIDTH=350  // Tip box width
   7 var ie4         // Are we using Internet Explorer Version 4?
   8 var ie5         // Are we using Internet Explorer Version 5 and up?
   9 var kon         // Are we using KDE Konqueror?
  10 var x,y,winW,winH  // Current help position and main window size
  11 var idiv=null   // Pointer to infodiv container
  12 
  13 function nsfix(){setTimeout("window.onresize = rebrowse", 2000);}
  14 
  15 function rebrowse(){window.location.reload();}
  16 
  17 function hascss(){ return gettip('infodiv')?true:false }
  18 
  19 function infoinit(){
  20  ie4=(document.all)?true:false;
  21  ie5=((ie4)&&((navigator.userAgent.indexOf('MSIE 5')>0)||(navigator.userAgent.indexOf('MSIE 6')>0)))?true:false;
  22  kon=(navigator.userAgent.indexOf('konqueror')>0)?true:false;
  23  x=0;y=0;winW=800;winH=600;
  24  idiv=null;
  25  document.onmousemove = mousemove;
  26  // Workaround for just another netscape bug: Fix browser confusion on resize
  27  // obviously conqueror has a similar problem :-(
  28  if(kon){ nsfix() }
  29 }
  30 
  31 function untip(){
  32  if(idiv) idiv.visibility="hidden";
  33  idiv=null;
  34 }
  35 
  36 function gettip(name){return (document.layers&&document.layers[name])?document.layers[name]:(document.all&&document.all[name]&&document.all[name].style)?document.all[name].style:document[name]?document[name]:(document.getElementById(name)?document.getElementById(name).style:0);}
  37 
  38 // Prepare tip boxes, but don't show them yet
  39 function maketip(){
  40  text='<div id="'+arguments[0]+'" name="'+arguments[0]+'" style="position:absolute; visibility:hidden; z-index:20; top:-999em; left:0px;"><table width='+IWIDTH+' class="tip">';
  41  for (i=1;i<arguments.length;i=i+2)
  42  {
  43   text = text + '<tr><th class="tip">'+arguments[i]+'</th></tr><tr><td class="tip">'+arguments[i+1]+'</td></tr>';
  44  }
  45  text=text + '</table></div>\n';
  46  if(hascss()) document.write(text);
  47 }
  48 
  49 function tip(name){
  50  if(hascss()){
  51   if(idiv) untip();
  52   idiv=gettip(name);
  53   if(idiv){
  54    winW=(window.innerWidth)? window.innerWidth+window.pageXOffset-16:document.body.offsetWidth-20;
  55    winH=(window.innerHeight)?window.innerHeight+window.pageYOffset  :document.body.offsetHeight;
  56    if(x<=0||y<=0){ // konqueror can't get mouse position
  57     x=(winW-IWIDTH)/2+(window.pageXOffset?window.pageXOffset:0); y=(winH-50)/2+(window.pageYOffset?window.pageYOffset:0); // middle of window
  58    }
  59    showtip();
  60   }
  61  }
  62 }
  63 
  64 function showtip(){
  65   idiv.left=(((x+IWIDTH+10)<winW)?x+12:x-IWIDTH-5)+"px"; idiv.top=(((y+90)<winH)?y+12:y-90)+"px";
  66   idiv.visibility="visible";
  67 //  window.status="idiv="+idiv+"X:"+(idiv.left?idiv.left:"NAN")+", Y:"+(idiv.top?idiv.top:"NAN")+", x:"+x+", y:"+y;
  68 }
  69 
  70 function mousemove(e){
  71  if(e)   {x=e.pageX?e.pageX:e.clientX?e.clientX:0; y=e.pageY?e.pageY:e.clientY?e.clientY:0;}
  72  else if(event) {x=event.clientX; y=event.clientY;}
  73  else {x=0; y=0;}
  74  if((ie4||ie5) && document.documentElement) // Workaround for scroll offset of IE
  75   {
  76     x+=document.documentElement.scrollLeft;
  77     y+=document.documentElement.scrollTop;
  78   }
  79  if(idiv) showtip();
  80 }
  81 
  82 // Initialize after loading the page
  83 addLoadEvent(infoinit)
  84 
  85 // EOF infobox.js
  86 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-08-29 23:44:58, 20.3 KB) [[attachment:MonthCalendar.py]]
  • [get | view] (2008-08-29 23:43:14, 3.1 KB) [[attachment:infobox.js]]
  • [get | view] (2008-08-29 23:45:28, 89.7 KB) [[attachment:screenshot.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.