1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
// This file is part of Natural Docs, which is Copyright (C) 2003-2005 Greg Valure
// Natural Docs is licensed under the GPL
//
// Browser Styles
// ____________________________________________________________________________
var agt=navigator.userAgent.toLowerCase();
var browserType;
var browserVer;
if (agt.indexOf("opera") != -1)
{
browserType = "Opera";
if (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1)
{ browserVer = "Opera5"; }
else if (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1)
{ browserVer = "Opera6"; }
else if (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1)
{ browserVer = "Opera7"; }
}
else if (agt.indexOf("khtml") != -1 || agt.indexOf("konq") != -1 || agt.indexOf("safari") != -1)
{
browserType = "KHTML";
}
else if (agt.indexOf("msie") != -1)
{
browserType = "IE";
if (agt.indexOf("msie 4") != -1)
{ browserVer = "IE4"; }
else if (agt.indexOf("msie 5") != -1)
{ browserVer = "IE5"; }
else if (agt.indexOf("msie 6") != -1)
{ browserVer = "IE6"; }
}
else if (agt.indexOf("gecko") != -1)
{
browserType = "Gecko";
}
// Opera already taken care of.
else if (agt.indexOf("mozilla") != -1 && agt.indexOf("compatible") == -1 && agt.indexOf("spoofer") == -1 &&
agt.indexOf("webtv") == -1 && agt.indexOf("hotjava") == -1)
{
browserType = "Netscape";
if (agt.indexOf("mozilla/4") != -1)
{ browserVer = "Netscape4"; }
}
//
// Menu
// ____________________________________________________________________________
function ToggleMenu(id)
{
if (!window.document.getElementById)
{ return; };
var display = window.document.getElementById(id).style.display;
if (display == "none")
{ display = "block"; }
else
{ display = "none"; }
window.document.getElementById(id).style.display = display;
}
//
// Tooltips
// ____________________________________________________________________________
var tooltipTimer = 0;
function ShowTip(event, tooltipID, linkID)
{
if (tooltipTimer)
{ clearTimeout(tooltipTimer); };
var docX = event.clientX + window.pageXOffset;
var docY = event.clientY + window.pageYOffset;
var showCommand = "ReallyShowTip('" + tooltipID + "', '" + linkID + "', " + docX + ", " + docY + ")";
// KHTML cant handle showing on a timer right now.
if (browserType != "KHTML")
{ tooltipTimer = setTimeout(showCommand, 1000); }
else
{ eval(showCommand); };
}
function ReallyShowTip(tooltipID, linkID, docX, docY)
{
tooltipTimer = 0;
var tooltip;
var link;
if (document.getElementById)
{
tooltip = document.getElementById(tooltipID);
link = document.getElementById(linkID);
}
else if (document.all)
{
tooltip = eval("document.all['" + tooltipID + "']");
link = eval("document.all['" + linkID + "']");
}
if (tooltip)
{
var left = 0;
var top = 0;
// Not everything supports offsetTop/Left/Width, and some, like Konqueror and Opera 5, think they do but do it badly.
if (link && link.offsetWidth != null && browserType != "KHTML" && browserVer != "Opera5")
{
var item = link;
while (item != document.body)
{
left += item.offsetLeft;
item = item.offsetParent;
}
item = link;
while (item != document.body)
{
top += item.offsetTop;
item = item.offsetParent;
}
top += link.offsetHeight;
}
// The fallback method is to use the mouse X and Y relative to the document. We use a separate if and test if its a number
// in case some browser snuck through the above if statement but didn't support everything.
if (!isFinite(top) || top == 0)
{
left = docX;
top = docY;
}
// Some spacing to get it out from under the cursor.
top += 10;
// Make sure the tooltip doesnt get smushed by being too close to the edge, or in some browsers, go off the edge of the
// page. We do it here because Konqueror does get offsetWidth right even if it doesnt get the positioning right.
if (tooltip.offsetWidth != null)
{
var width = tooltip.offsetWidth;
var docWidth = document.body.clientWidth;
if (left + width > docWidth)
{ left = docWidth - width - 1; }
}
// Opera 5 chokes on the px extension, so it can use the Microsoft one instead.
if (tooltip.style.left != null && browserVer != "Opera5")
{
tooltip.style.left = left + "px";
tooltip.style.top = top + "px";
}
else if (tooltip.style.pixelLeft != null)
{
tooltip.style.pixelLeft = left;
tooltip.style.pixelTop = top;
}
tooltip.style.visibility = "visible";
}
}
function HideTip(tooltipID)
{
if (tooltipTimer)
{
clearTimeout(tooltipTimer);
tooltipTimer = 0;
}
var tooltip;
if (document.getElementById)
{ tooltip = document.getElementById(tooltipID); }
else if (document.all)
{ tooltip = eval("document.all['" + tooltipID + "']"); }
if (tooltip)
{ tooltip.style.visibility = "hidden"; }
}
//
// Event Handlers
// ____________________________________________________________________________
function NDOnLoad()
{
if (browserType == "IE")
{
var scrollboxes = document.getElementsByTagName('blockquote');
if (scrollboxes.item(0))
{
var width = scrollboxes.item(0).parentNode.offsetWidth - scrollboxes.item(0).offsetLeft;
var i = 0;
var item;
while (item = scrollboxes.item(i))
{
item.style.width = width;
i++;
};
window.onresize=NDOnResize;
};
};
}
var resizeTimer = 0;
function NDOnResize()
{
if (browserType == "IE")
{
if (resizeTimer != 0)
{ clearTimeout(resizeTimer); };
resizeTimer = setTimeout(NDDoResize, 500);
};
};
function NDDoResize()
{
var scrollboxes = document.getElementsByTagName('blockquote');
var i;
var item;
i = 0;
while (item = scrollboxes.item(i))
{
item.style.width = "100px";
i++;
};
var width = scrollboxes.item(0).parentNode.offsetWidth - scrollboxes.item(0).offsetLeft;
i = 0;
while (item = scrollboxes.item(i))
{
item.style.width = width;
i++;
};
clearTimeout(resizeTimer);
resizeTimer = 0;
}
|