Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1244 linhas
34KB

  1. /* This notice must be untouched at all times.
  2. Copyright (c) 2002-2008 Walter Zorn. All rights reserved.
  3. wz_tooltip.js v. 5.01
  4. The latest version is available at
  5. http://www.walterzorn.com
  6. or http://www.devira.com
  7. or http://www.walterzorn.de
  8. Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com )
  9. Last modified: 26.3.2008
  10. Easy-to-use cross-browser tooltips.
  11. Just include the script at the beginning of the <body> section, and invoke
  12. Tip('Tooltip text') from the desired HTML onmouseover eventhandlers,
  13. and UnTip(), usually from the onmouseout eventhandlers, to hide the tip.
  14. No container DIV required.
  15. By default, width and height of tooltips are automatically adapted to content.
  16. Is even capable of dynamically converting arbitrary HTML elements to tooltips
  17. by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(),
  18. which means you can put important, search-engine-relevant stuff into tooltips.
  19. Appearance of tooltips can be individually configured
  20. via commands passed to Tip() or TagToTip().
  21. Tab Width: 4
  22. LICENSE: LGPL
  23. This library is free software; you can redistribute it and/or
  24. modify it under the terms of the GNU Lesser General Public
  25. License (LGPL) as published by the Free Software Foundation; either
  26. version 2.1 of the License, or (at your option) any later version.
  27. This library is distributed in the hope that it will be useful,
  28. but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30. For more details on the GNU Lesser General Public License,
  31. see http://www.gnu.org/copyleft/lesser.html
  32. */
  33. var config = new Object();
  34. //=================== GLOBAL TOOPTIP CONFIGURATION =========================//
  35. var tt_Debug = true // false or true - recommended: false once you release your page to the public
  36. var tt_Enabled = true // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false
  37. var TagsToTip = true // false or true - if true, HTML elements to be converted to tooltips via TagToTip() are automatically hidden;
  38. // if false, you should hide those HTML elements yourself
  39. // For each of the following config variables there exists a command, which is
  40. // just the variablename in uppercase, to be passed to Tip() or TagToTip() to
  41. // configure tooltips individually. Individual commands override global
  42. // configuration. Order of commands is arbitrary.
  43. // Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)"
  44. config. Above = false // false or true - tooltip above mousepointer
  45. // config. BgColor = '#E2E7FF' // Background colour (HTML colour value, in quotes)
  46. config. BgColor = '#f5f5dc'
  47. config. BgImg = '' // Path to background image, none if empty string ''
  48. // config. BorderColor = '#003099'
  49. // config. BorderColor = '#4070ff'
  50. config. BorderColor = '#40ff70'
  51. config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed'
  52. config. BorderWidth = 2
  53. config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer
  54. config. ClickClose = false // false or true - close tooltip if the user clicks somewhere
  55. config. ClickSticky = false // false or true - make tooltip sticky if user left-clicks on the hovered element while the tooltip is active
  56. config. CloseBtn = false // false or true - closebutton in titlebar
  57. config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colours
  58. config. CloseBtnText = '&nbsp;X&nbsp;' // Close button text (may also be an image tag)
  59. config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own
  60. config. Delay = 1000 // Time span in ms until tooltip shows up
  61. config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration, < 0 for delay in ms _after_ the onmouseout until the tooltip disappears
  62. config. FadeIn = 120 // Fade-in duration in ms, e.g. 400; 0 for no animation
  63. config. FadeOut = 120
  64. config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load
  65. config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation
  66. config. FollowMouse = true // false or true - tooltip follows the mouse
  67. config. FontColor = '#000044'
  68. config. FontFace = 'Verdana,Geneva,sans-serif'
  69. // config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory
  70. config. FontSize = '9pt' // E.g. '9pt' or '12px' - unit is mandatory
  71. config. FontWeight = 'normal' // 'normal' or 'bold';
  72. config. Height = 0 // Tooltip height; 0 for automatic adaption to tooltip content, < 0 (e.g. -100) for a maximum for automatic adaption
  73. config. JumpHorz = false // false or true - jump horizontally to other side of mouse if tooltip would extend past clientarea boundary
  74. config. JumpVert = true // false or true - jump vertically "
  75. config. Left = false // false or true - tooltip on the left of the mouse
  76. config. OffsetX = 100 // Horizontal offset of left-top corner from mousepointer
  77. config. OffsetY = 20 // Vertical offset
  78. config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent
  79. config. Padding = 4 // Spacing between border and content
  80. config. Shadow = false // false or true
  81. config. ShadowColor = '#C0C0C0'
  82. config. ShadowWidth = 5
  83. config. Sticky = false // false or true - fixate tip, ie. don't follow the mouse and don't hide on mouseout
  84. config. TextAlign = 'left' // 'left', 'right' or 'justify'
  85. config. Title = '' // Default title text applied to all tips (no default title: empty string '')
  86. config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar
  87. config. TitleBgColor = '' // If empty string '', BorderColor will be used
  88. config. TitleFontColor = '#000000' // Color of title text - if '', BgColor (of tooltip body) will be used
  89. config. TitleFontFace = '' // If '' use FontFace (boldified)
  90. config. TitleFontSize = '' // If '' use FontSize
  91. config. Width = 0 // Tooltip width; 0 for automatic adaption to tooltip content; < -1 (e.g. -240) for a maximum width for that automatic adaption;
  92. // -1: tooltip width confined to the width required for the titlebar
  93. //======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============//
  94. //===================== PUBLIC =============================================//
  95. function Tip()
  96. {
  97. tt_Tip(arguments, null);
  98. }
  99. function TagToTip()
  100. {
  101. var t2t = tt_GetElt(arguments[0]);
  102. if(t2t)
  103. tt_Tip(arguments, t2t);
  104. }
  105. function UnTip()
  106. {
  107. tt_OpReHref();
  108. if(tt_aV[DURATION] < 0)
  109. tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true);
  110. else if(!(tt_aV[STICKY] && (tt_iState & 0x2)))
  111. tt_HideInit();
  112. }
  113. //================== PUBLIC PLUGIN API =====================================//
  114. // Extension eventhandlers currently supported:
  115. // OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore,
  116. // OnMoveAfter, OnHideInit, OnHide, OnKill
  117. var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE
  118. tt_aV = new Array(), // Caches and enumerates config data for currently active tooltip
  119. tt_sContent, // Inner tooltip text or HTML
  120. tt_scrlX = 0, tt_scrlY = 0,
  121. tt_musX, tt_musY,
  122. tt_over,
  123. tt_x, tt_y, tt_w, tt_h; // Position, width and height of currently displayed tooltip
  124. function tt_Extension()
  125. {
  126. tt_ExtCmdEnum();
  127. tt_aExt[tt_aExt.length] = this;
  128. return this;
  129. }
  130. function tt_SetTipPos(x, y)
  131. {
  132. var css = tt_aElt[0].style;
  133. tt_x = x;
  134. tt_y = y;
  135. css.left = x + "px";
  136. css.top = y + "px";
  137. if(tt_ie56)
  138. {
  139. var ifrm = tt_aElt[tt_aElt.length - 1];
  140. if(ifrm)
  141. {
  142. ifrm.style.left = css.left;
  143. ifrm.style.top = css.top;
  144. }
  145. }
  146. }
  147. function tt_HideInit()
  148. {
  149. if(tt_iState)
  150. {
  151. tt_ExtCallFncs(0, "HideInit");
  152. tt_iState &= ~0x4;
  153. if(tt_flagOpa && tt_aV[FADEOUT])
  154. {
  155. tt_tFade.EndTimer();
  156. if(tt_opa)
  157. {
  158. var n = Math.round(tt_aV[FADEOUT] / (tt_aV[FADEINTERVAL] * (tt_aV[OPACITY] / tt_opa)));
  159. tt_Fade(tt_opa, tt_opa, 0, n);
  160. return;
  161. }
  162. }
  163. tt_tHide.Timer("tt_Hide();", 1, false);
  164. }
  165. }
  166. function tt_Hide()
  167. {
  168. if(tt_db && tt_iState)
  169. {
  170. tt_OpReHref();
  171. if(tt_iState & 0x2)
  172. {
  173. tt_aElt[0].style.visibility = "hidden";
  174. tt_ExtCallFncs(0, "Hide");
  175. }
  176. tt_tShow.EndTimer();
  177. tt_tHide.EndTimer();
  178. tt_tDurt.EndTimer();
  179. tt_tFade.EndTimer();
  180. if(!tt_op && !tt_ie)
  181. {
  182. tt_tWaitMov.EndTimer();
  183. tt_bWait = false;
  184. }
  185. if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY])
  186. tt_RemEvtFnc(document, "mouseup", tt_OnLClick);
  187. tt_ExtCallFncs(0, "Kill");
  188. // In case of a TagToTip tooltip, hide converted DOM node and
  189. // re-insert it into document
  190. if(tt_t2t && !tt_aV[COPYCONTENT])
  191. {
  192. tt_t2t.style.display = "none";
  193. tt_MovDomNode(tt_t2t, tt_aElt[6], tt_t2tDad);
  194. }
  195. tt_iState = 0;
  196. tt_over = null;
  197. tt_ResetMainDiv();
  198. if(tt_aElt[tt_aElt.length - 1])
  199. tt_aElt[tt_aElt.length - 1].style.display = "none";
  200. }
  201. }
  202. function tt_GetElt(id)
  203. {
  204. return(document.getElementById ? document.getElementById(id)
  205. : document.all ? document.all[id]
  206. : null);
  207. }
  208. function tt_GetDivW(el)
  209. {
  210. return(el ? (el.offsetWidth || el.style.pixelWidth || 0) : 0);
  211. }
  212. function tt_GetDivH(el)
  213. {
  214. return(el ? (el.offsetHeight || el.style.pixelHeight || 0) : 0);
  215. }
  216. function tt_GetScrollX()
  217. {
  218. return(window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0));
  219. }
  220. function tt_GetScrollY()
  221. {
  222. return(window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0));
  223. }
  224. function tt_GetClientW()
  225. {
  226. return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth
  227. : (typeof(window.innerWidth) != tt_u) ? window.innerWidth
  228. : tt_db ? (tt_db.clientWidth || 0)
  229. : 0);
  230. }
  231. function tt_GetClientH()
  232. {
  233. // Exactly this order seems to yield correct values in all major browsers
  234. return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight
  235. : (typeof(window.innerHeight) != tt_u) ? window.innerHeight
  236. : tt_db ? (tt_db.clientHeight || 0)
  237. : 0);
  238. }
  239. function tt_GetEvtX(e)
  240. {
  241. return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX)) : 0);
  242. }
  243. function tt_GetEvtY(e)
  244. {
  245. return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY)) : 0);
  246. }
  247. function tt_AddEvtFnc(el, sEvt, PFnc)
  248. {
  249. if(el)
  250. {
  251. if(el.addEventListener)
  252. el.addEventListener(sEvt, PFnc, false);
  253. else
  254. el.attachEvent("on" + sEvt, PFnc);
  255. }
  256. }
  257. function tt_RemEvtFnc(el, sEvt, PFnc)
  258. {
  259. if(el)
  260. {
  261. if(el.removeEventListener)
  262. el.removeEventListener(sEvt, PFnc, false);
  263. else
  264. el.detachEvent("on" + sEvt, PFnc);
  265. }
  266. }
  267. //====================== PRIVATE ===========================================//
  268. var tt_aExt = new Array(), // Array of extension objects
  269. tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags
  270. tt_body,
  271. tt_ovr_, // HTML element the mouse is currently over
  272. tt_flagOpa, // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C
  273. tt_maxPosX, tt_maxPosY,
  274. tt_iState = 0, // Tooltip active |= 1, shown |= 2, move with mouse |= 4
  275. tt_opa, // Currently applied opacity
  276. tt_bJmpVert, tt_bJmpHorz,// Tip temporarily on other side of mouse
  277. tt_t2t, tt_t2tDad, // Tag converted to tip, and its parent element in the document
  278. tt_elDeHref, // The tag from which we've removed the href attribute
  279. // Timer
  280. tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0),
  281. tt_tFade = new Number(0), tt_tWaitMov = new Number(0),
  282. tt_bWait = false,
  283. tt_u = "undefined";
  284. function tt_Init()
  285. {
  286. tt_MkCmdEnum();
  287. // Send old browsers instantly to hell
  288. if(!tt_Browser() || !tt_MkMainDiv())
  289. return;
  290. tt_IsW3cBox();
  291. tt_OpaSupport();
  292. tt_AddEvtFnc(window, "scroll", tt_OnScrl);
  293. // IE doesn't fire onscroll event when switching to fullscreen;
  294. // fix suggested by Yoav Karpeles 14.2.2008
  295. tt_AddEvtFnc(window, "resize", tt_OnScrl);
  296. tt_AddEvtFnc(document, "mousemove", tt_Move);
  297. // In Debug mode we search for TagToTip() calls in order to notify
  298. // the user if they've forgotten to set the TagsToTip config flag
  299. if(TagsToTip || tt_Debug)
  300. tt_SetOnloadFnc();
  301. // Ensure the tip be hidden when the page unloads
  302. tt_AddEvtFnc(window, "unload", tt_Hide);
  303. }
  304. // Creates command names by translating config variable names to upper case
  305. function tt_MkCmdEnum()
  306. {
  307. var n = 0;
  308. for(var i in config)
  309. eval("window." + i.toString().toUpperCase() + " = " + n++);
  310. tt_aV.length = n;
  311. }
  312. function tt_Browser()
  313. {
  314. var n, nv, n6, w3c;
  315. n = navigator.userAgent.toLowerCase(),
  316. nv = navigator.appVersion;
  317. tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u);
  318. tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op;
  319. if(tt_ie)
  320. {
  321. var ieOld = (!document.compatMode || document.compatMode == "BackCompat");
  322. tt_db = !ieOld ? document.documentElement : (document.body || null);
  323. if(tt_db)
  324. tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5
  325. && typeof document.body.style.maxHeight == tt_u;
  326. }
  327. else
  328. {
  329. tt_db = document.documentElement || document.body ||
  330. (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
  331. : null);
  332. if(!tt_op)
  333. {
  334. n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u;
  335. w3c = !n6 && document.getElementById;
  336. }
  337. }
  338. tt_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
  339. : (document.body || null));
  340. if(tt_ie || n6 || tt_op || w3c)
  341. {
  342. if(tt_body && tt_db)
  343. {
  344. if(document.attachEvent || document.addEventListener)
  345. return true;
  346. }
  347. else
  348. tt_Err("wz_tooltip.js must be included INSIDE the body section,"
  349. + " immediately after the opening <body> tag.", false);
  350. }
  351. tt_db = null;
  352. return false;
  353. }
  354. function tt_MkMainDiv()
  355. {
  356. // Create the tooltip DIV
  357. if(tt_body.insertAdjacentHTML)
  358. tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm());
  359. else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild)
  360. tt_body.appendChild(tt_MkMainDivDom());
  361. if(window.tt_GetMainDivRefs /* FireFox Alzheimer */ && tt_GetMainDivRefs())
  362. return true;
  363. tt_db = null;
  364. return false;
  365. }
  366. function tt_MkMainDivHtm()
  367. {
  368. return('<div id="WzTtDiV"></div>' +
  369. (tt_ie56 ? ('<iframe id="WzTtIfRm" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>')
  370. : ''));
  371. }
  372. function tt_MkMainDivDom()
  373. {
  374. var el = document.createElement("div");
  375. if(el)
  376. el.id = "WzTtDiV";
  377. return el;
  378. }
  379. function tt_GetMainDivRefs()
  380. {
  381. tt_aElt[0] = tt_GetElt("WzTtDiV");
  382. if(tt_ie56 && tt_aElt[0])
  383. {
  384. tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm");
  385. if(!tt_aElt[tt_aElt.length - 1])
  386. tt_aElt[0] = null;
  387. }
  388. if(tt_aElt[0])
  389. {
  390. var css = tt_aElt[0].style;
  391. css.visibility = "hidden";
  392. css.position = "absolute";
  393. css.overflow = "hidden";
  394. return true;
  395. }
  396. return false;
  397. }
  398. function tt_ResetMainDiv()
  399. {
  400. var w = (window.screen && screen.width) ? screen.width : 10000;
  401. tt_SetTipPos(-w, 0);
  402. tt_aElt[0].innerHTML = "";
  403. tt_aElt[0].style.width = (w - 1) + "px";
  404. tt_h = 0;
  405. }
  406. function tt_IsW3cBox()
  407. {
  408. var css = tt_aElt[0].style;
  409. css.padding = "10px";
  410. css.width = "40px";
  411. tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40);
  412. css.padding = "0px";
  413. tt_ResetMainDiv();
  414. }
  415. function tt_OpaSupport()
  416. {
  417. var css = tt_body.style;
  418. tt_flagOpa = (typeof(css.filter) != tt_u) ? 1
  419. : (typeof(css.KhtmlOpacity) != tt_u) ? 2
  420. : (typeof(css.KHTMLOpacity) != tt_u) ? 3
  421. : (typeof(css.MozOpacity) != tt_u) ? 4
  422. : (typeof(css.opacity) != tt_u) ? 5
  423. : 0;
  424. }
  425. // Ported from http://dean.edwards.name/weblog/2006/06/again/
  426. // (Dean Edwards et al.)
  427. function tt_SetOnloadFnc()
  428. {
  429. tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags);
  430. tt_AddEvtFnc(window, "load", tt_HideSrcTags);
  431. if(tt_body.attachEvent)
  432. tt_body.attachEvent("onreadystatechange",
  433. function() {
  434. if(tt_body.readyState == "complete")
  435. tt_HideSrcTags();
  436. } );
  437. if(/WebKit|KHTML/i.test(navigator.userAgent))
  438. {
  439. var t = setInterval(function() {
  440. if(/loaded|complete/.test(document.readyState))
  441. {
  442. clearInterval(t);
  443. tt_HideSrcTags();
  444. }
  445. }, 10);
  446. }
  447. }
  448. function tt_HideSrcTags()
  449. {
  450. if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done)
  451. return;
  452. window.tt_HideSrcTags.done = true;
  453. if(!tt_HideSrcTagsRecurs(tt_body))
  454. tt_Err("There are HTML elements to be converted to tooltips.\nIf you"
  455. + " want these HTML elements to be automatically hidden, you"
  456. + " must edit wz_tooltip.js, and set TagsToTip in the global"
  457. + " tooltip configuration to true.", true);
  458. }
  459. function tt_HideSrcTagsRecurs(dad)
  460. {
  461. var ovr, asT2t;
  462. // Walk the DOM tree for tags that have an onmouseover or onclick attribute
  463. // containing a TagToTip('...') call.
  464. // (.childNodes first since .children is bugous in Safari)
  465. var a = dad.childNodes || dad.children || null;
  466. for(var i = a ? a.length : 0; i;)
  467. {--i;
  468. if(!tt_HideSrcTagsRecurs(a[i]))
  469. return false;
  470. ovr = a[i].getAttribute ? (a[i].getAttribute("onmouseover") || a[i].getAttribute("onclick"))
  471. : (typeof a[i].onmouseover == "function") ? (a[i].onmouseover || a[i].onclick)
  472. : null;
  473. if(ovr)
  474. {
  475. asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/);
  476. if(asT2t && asT2t.length)
  477. {
  478. if(!tt_HideSrcTag(asT2t[0]))
  479. return false;
  480. }
  481. }
  482. }
  483. return true;
  484. }
  485. function tt_HideSrcTag(sT2t)
  486. {
  487. var id, el;
  488. // The ID passed to the found TagToTip() call identifies an HTML element
  489. // to be converted to a tooltip, so hide that element
  490. id = sT2t.replace(/.+'([^'.]+)'.+/, "$1");
  491. el = tt_GetElt(id);
  492. if(el)
  493. {
  494. if(tt_Debug && !TagsToTip)
  495. return false;
  496. else
  497. el.style.display = "none";
  498. }
  499. else
  500. tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()."
  501. + " There exists no HTML element with that ID.", true);
  502. return true;
  503. }
  504. function tt_Tip(arg, t2t)
  505. {
  506. if(!tt_db)
  507. return;
  508. if(tt_iState)
  509. tt_Hide();
  510. if(!tt_Enabled)
  511. return;
  512. tt_t2t = t2t;
  513. if(!tt_ReadCmds(arg))
  514. return;
  515. tt_iState = 0x1 | 0x4;
  516. tt_AdaptConfig1();
  517. tt_MkTipContent(arg);
  518. tt_MkTipSubDivs();
  519. tt_FormatTip();
  520. tt_bJmpVert = false;
  521. tt_bJmpHorz = false;
  522. tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1;
  523. tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1;
  524. tt_AdaptConfig2();
  525. // Ensure the tip be shown and positioned before the first onmousemove
  526. tt_OverInit();
  527. tt_ShowInit();
  528. tt_Move();
  529. }
  530. function tt_ReadCmds(a)
  531. {
  532. var i;
  533. // First load the global config values, to initialize also values
  534. // for which no command is passed
  535. i = 0;
  536. for(var j in config)
  537. tt_aV[i++] = config[j];
  538. // Then replace each cached config value for which a command is
  539. // passed (ensure the # of command args plus value args be even)
  540. if(a.length & 1)
  541. {
  542. for(i = a.length - 1; i > 0; i -= 2)
  543. tt_aV[a[i - 1]] = a[i];
  544. return true;
  545. }
  546. tt_Err("Incorrect call of Tip() or TagToTip().\n"
  547. + "Each command must be followed by a value.", true);
  548. return false;
  549. }
  550. function tt_AdaptConfig1()
  551. {
  552. tt_ExtCallFncs(0, "LoadConfig");
  553. // Inherit unspecified title formattings from body
  554. if(!tt_aV[TITLEBGCOLOR].length)
  555. tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR];
  556. if(!tt_aV[TITLEFONTCOLOR].length)
  557. tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR];
  558. if(!tt_aV[TITLEFONTFACE].length)
  559. tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE];
  560. if(!tt_aV[TITLEFONTSIZE].length)
  561. tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE];
  562. if(tt_aV[CLOSEBTN])
  563. {
  564. // Use title colours for non-specified closebutton colours
  565. if(!tt_aV[CLOSEBTNCOLORS])
  566. tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", "");
  567. for(var i = 4; i;)
  568. {--i;
  569. if(!tt_aV[CLOSEBTNCOLORS][i].length)
  570. tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR];
  571. }
  572. // Enforce titlebar be shown
  573. if(!tt_aV[TITLE].length)
  574. tt_aV[TITLE] = " ";
  575. }
  576. // Circumvents broken display of images and fade-in flicker in Geckos < 1.8
  577. if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every)
  578. tt_aV[OPACITY] = 99;
  579. // Smartly shorten the delay for fade-in tooltips
  580. if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100)
  581. tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100);
  582. }
  583. function tt_AdaptConfig2()
  584. {
  585. if(tt_aV[CENTERMOUSE])
  586. {
  587. tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1);
  588. tt_aV[JUMPHORZ] = false;
  589. }
  590. }
  591. // Expose content globally so extensions can modify it
  592. function tt_MkTipContent(a)
  593. {
  594. if(tt_t2t)
  595. {
  596. if(tt_aV[COPYCONTENT])
  597. tt_sContent = tt_t2t.innerHTML;
  598. else
  599. tt_sContent = "";
  600. }
  601. else
  602. tt_sContent = a[0];
  603. tt_ExtCallFncs(0, "CreateContentString");
  604. }
  605. function tt_MkTipSubDivs()
  606. {
  607. var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;',
  608. sTbTrTd = ' cellspacing="0" cellpadding="0" border="0" style="' + sCss + '"><tbody style="' + sCss + '"><tr><td ';
  609. tt_aElt[0].innerHTML =
  610. (''
  611. + (tt_aV[TITLE].length ?
  612. ('<div id="WzTiTl" style="position:relative;z-index:1;">'
  613. + '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">'
  614. + tt_aV[TITLE]
  615. + '</td>'
  616. + (tt_aV[CLOSEBTN] ?
  617. ('<td align="right" style="' + sCss
  618. + 'text-align:right;">'
  619. + '<span id="WzClOsE" style="padding-left:2px;padding-right:2px;'
  620. + 'cursor:' + (tt_ie ? 'hand' : 'pointer')
  621. + ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">'
  622. + tt_aV[CLOSEBTNTEXT]
  623. + '</span></td>')
  624. : '')
  625. + '</tr></tbody></table></div>')
  626. : '')
  627. + '<div id="WzBoDy" style="position:relative;z-index:0;">'
  628. + '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">'
  629. + tt_sContent
  630. + '</td></tr></tbody></table></div>'
  631. + (tt_aV[SHADOW]
  632. ? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>'
  633. + '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>')
  634. : '')
  635. );
  636. tt_GetSubDivRefs();
  637. // Convert DOM node to tip
  638. if(tt_t2t && !tt_aV[COPYCONTENT])
  639. {
  640. // Store the tag's parent element so we can restore that DOM branch
  641. // once the tooltip is hidden
  642. tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null;
  643. if(tt_t2tDad)
  644. {
  645. tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]);
  646. tt_t2t.style.display = "block";
  647. }
  648. }
  649. tt_ExtCallFncs(0, "SubDivsCreated");
  650. }
  651. function tt_GetSubDivRefs()
  652. {
  653. var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR");
  654. for(var i = aId.length; i; --i)
  655. tt_aElt[i] = tt_GetElt(aId[i - 1]);
  656. }
  657. function tt_FormatTip()
  658. {
  659. var css, w, h, iOffY, iOffSh,
  660. iAdd = (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1;
  661. //--------- Title DIV ----------
  662. if(tt_aV[TITLE].length)
  663. {
  664. css = tt_aElt[1].style;
  665. css.background = tt_aV[TITLEBGCOLOR];
  666. css.paddingTop = (tt_aV[CLOSEBTN] ? 2 : 0) + "px";
  667. css.paddingBottom = "1px";
  668. css.paddingLeft = css.paddingRight = tt_aV[PADDING] + "px";
  669. css = tt_aElt[3].style;
  670. css.color = tt_aV[TITLEFONTCOLOR];
  671. if (tt_aV[WIDTH] == -1)
  672. css.whiteSpace = "nowrap";
  673. css.fontFamily = tt_aV[TITLEFONTFACE];
  674. css.fontSize = tt_aV[TITLEFONTSIZE];
  675. css.fontWeight = "bold";
  676. css.textAlign = tt_aV[TITLEALIGN];
  677. // Close button DIV
  678. if(tt_aElt[4])
  679. {
  680. css.paddingRight = (tt_aV[PADDING] << 1) + "px";
  681. css = tt_aElt[4].style;
  682. css.background = tt_aV[CLOSEBTNCOLORS][0];
  683. css.color = tt_aV[CLOSEBTNCOLORS][1];
  684. css.fontFamily = tt_aV[TITLEFONTFACE];
  685. css.fontSize = tt_aV[TITLEFONTSIZE];
  686. css.fontWeight = "bold";
  687. }
  688. if(tt_aV[WIDTH] > 0)
  689. tt_w = tt_aV[WIDTH];
  690. else
  691. {
  692. tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]);
  693. // Some spacing between title DIV and closebutton
  694. if(tt_aElt[4])
  695. tt_w += tt_aV[PADDING];
  696. // Restrict auto width to max width
  697. if(tt_aV[WIDTH] < -1 && tt_w > -tt_aV[WIDTH])
  698. tt_w = -tt_aV[WIDTH];
  699. }
  700. // Ensure the top border of the body DIV be covered by the title DIV
  701. iOffY = -tt_aV[BORDERWIDTH];
  702. }
  703. else
  704. {
  705. tt_w = 0;
  706. iOffY = 0;
  707. }
  708. //-------- Body DIV ------------
  709. css = tt_aElt[5].style;
  710. css.top = iOffY + "px";
  711. if(tt_aV[BORDERWIDTH])
  712. {
  713. css.borderColor = tt_aV[BORDERCOLOR];
  714. css.borderStyle = tt_aV[BORDERSTYLE];
  715. css.borderWidth = tt_aV[BORDERWIDTH] + "px";
  716. }
  717. if(tt_aV[BGCOLOR].length)
  718. css.background = tt_aV[BGCOLOR];
  719. if(tt_aV[BGIMG].length)
  720. css.backgroundImage = "url(" + tt_aV[BGIMG] + ")";
  721. css.padding = tt_aV[PADDING] + "px";
  722. css.textAlign = tt_aV[TEXTALIGN];
  723. if(tt_aV[HEIGHT])
  724. {
  725. css.overflow = "auto";
  726. if(tt_aV[HEIGHT] > 0)
  727. css.height = (tt_aV[HEIGHT] + iAdd) + "px";
  728. else
  729. tt_h = iAdd - tt_aV[HEIGHT];
  730. }
  731. // TD inside body DIV
  732. css = tt_aElt[6].style;
  733. css.color = tt_aV[FONTCOLOR];
  734. css.fontFamily = tt_aV[FONTFACE];
  735. css.fontSize = tt_aV[FONTSIZE];
  736. css.fontWeight = tt_aV[FONTWEIGHT];
  737. css.background = "";
  738. css.textAlign = tt_aV[TEXTALIGN];
  739. if(tt_aV[WIDTH] > 0)
  740. w = tt_aV[WIDTH];
  741. // Width like title (if existent)
  742. else if(tt_aV[WIDTH] == -1 && tt_w)
  743. w = tt_w;
  744. else
  745. {
  746. // Measure width of the body's inner TD, as some browsers would expand
  747. // the container and outer body DIV to 100%
  748. w = tt_GetDivW(tt_aElt[6]);
  749. // Restrict auto width to max width
  750. if(tt_aV[WIDTH] < -1 && w > -tt_aV[WIDTH])
  751. w = -tt_aV[WIDTH];
  752. }
  753. if(w > tt_w)
  754. tt_w = w;
  755. tt_w += iAdd;
  756. //--------- Shadow DIVs ------------
  757. if(tt_aV[SHADOW])
  758. {
  759. tt_w += tt_aV[SHADOWWIDTH];
  760. iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3);
  761. // Bottom shadow
  762. css = tt_aElt[7].style;
  763. css.top = iOffY + "px";
  764. css.left = iOffSh + "px";
  765. css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px";
  766. css.height = tt_aV[SHADOWWIDTH] + "px";
  767. css.background = tt_aV[SHADOWCOLOR];
  768. // Right shadow
  769. css = tt_aElt[8].style;
  770. css.top = iOffSh + "px";
  771. css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px";
  772. css.width = tt_aV[SHADOWWIDTH] + "px";
  773. css.background = tt_aV[SHADOWCOLOR];
  774. }
  775. else
  776. iOffSh = 0;
  777. //-------- Container DIV -------
  778. tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]);
  779. tt_FixSize(iOffY, iOffSh);
  780. }
  781. // Fixate the size so it can't dynamically change while the tooltip is moving.
  782. function tt_FixSize(iOffY, iOffSh)
  783. {
  784. var wIn, wOut, h, add, i;
  785. tt_aElt[0].style.width = tt_w + "px";
  786. tt_aElt[0].style.pixelWidth = tt_w;
  787. wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0);
  788. // Body
  789. wIn = wOut;
  790. if(!tt_bBoxOld)
  791. wIn -= (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1;
  792. tt_aElt[5].style.width = wIn + "px";
  793. // Title
  794. if(tt_aElt[1])
  795. {
  796. wIn = wOut - (tt_aV[PADDING] << 1);
  797. if(!tt_bBoxOld)
  798. wOut = wIn;
  799. tt_aElt[1].style.width = wOut + "px";
  800. tt_aElt[2].style.width = wIn + "px";
  801. }
  802. // Max height specified
  803. if(tt_h)
  804. {
  805. h = tt_GetDivH(tt_aElt[5]);
  806. if(h > tt_h)
  807. {
  808. if(!tt_bBoxOld)
  809. tt_h -= (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1;
  810. tt_aElt[5].style.height = tt_h + "px";
  811. }
  812. }
  813. tt_h = tt_GetDivH(tt_aElt[0]) + iOffY;
  814. // Right shadow
  815. if(tt_aElt[8])
  816. tt_aElt[8].style.height = (tt_h - iOffSh) + "px";
  817. i = tt_aElt.length - 1;
  818. if(tt_aElt[i])
  819. {
  820. tt_aElt[i].style.width = tt_w + "px";
  821. tt_aElt[i].style.height = tt_h + "px";
  822. }
  823. }
  824. function tt_DeAlt(el)
  825. {
  826. var aKid;
  827. if(el)
  828. {
  829. if(el.alt)
  830. el.alt = "";
  831. if(el.title)
  832. el.title = "";
  833. aKid = el.childNodes || el.children || null;
  834. if(aKid)
  835. {
  836. for(var i = aKid.length; i;)
  837. tt_DeAlt(aKid[--i]);
  838. }
  839. }
  840. }
  841. // This hack removes the native tooltips over links in Opera
  842. function tt_OpDeHref(el)
  843. {
  844. if(!tt_op)
  845. return;
  846. if(tt_elDeHref)
  847. tt_OpReHref();
  848. while(el)
  849. {
  850. if(el.hasAttribute("href"))
  851. {
  852. el.t_href = el.getAttribute("href");
  853. el.t_stats = window.status;
  854. el.removeAttribute("href");
  855. el.style.cursor = "hand";
  856. tt_AddEvtFnc(el, "mousedown", tt_OpReHref);
  857. window.status = el.t_href;
  858. tt_elDeHref = el;
  859. break;
  860. }
  861. el = el.parentElement;
  862. }
  863. }
  864. function tt_OpReHref()
  865. {
  866. if(tt_elDeHref)
  867. {
  868. tt_elDeHref.setAttribute("href", tt_elDeHref.t_href);
  869. tt_RemEvtFnc(tt_elDeHref, "mousedown", tt_OpReHref);
  870. window.status = tt_elDeHref.t_stats;
  871. tt_elDeHref = null;
  872. }
  873. }
  874. function tt_OverInit()
  875. {
  876. if(window.event)
  877. tt_over = window.event.target || window.event.srcElement;
  878. else
  879. tt_over = tt_ovr_;
  880. tt_DeAlt(tt_over);
  881. tt_OpDeHref(tt_over);
  882. }
  883. function tt_ShowInit()
  884. {
  885. tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true);
  886. if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY])
  887. tt_AddEvtFnc(document, "mouseup", tt_OnLClick);
  888. }
  889. function tt_Show()
  890. {
  891. var css = tt_aElt[0].style;
  892. // Override the z-index of the topmost wz_dragdrop.js D&D item
  893. css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010);
  894. if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE])
  895. tt_iState &= ~0x4;
  896. if(tt_aV[DURATION] > 0)
  897. tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true);
  898. tt_ExtCallFncs(0, "Show")
  899. css.visibility = "visible";
  900. tt_iState |= 0x2;
  901. if(tt_aV[FADEIN])
  902. tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL]));
  903. tt_ShowIfrm();
  904. }
  905. function tt_ShowIfrm()
  906. {
  907. if(tt_ie56)
  908. {
  909. var ifrm = tt_aElt[tt_aElt.length - 1];
  910. if(ifrm)
  911. {
  912. var css = ifrm.style;
  913. css.zIndex = tt_aElt[0].style.zIndex - 1;
  914. css.display = "block";
  915. }
  916. }
  917. }
  918. function tt_Move(e)
  919. {
  920. if(e)
  921. tt_ovr_ = e.target || e.srcElement;
  922. e = e || window.event;
  923. if(e)
  924. {
  925. tt_musX = tt_GetEvtX(e);
  926. tt_musY = tt_GetEvtY(e);
  927. }
  928. if(tt_iState & 0x04)
  929. {
  930. // Prevent jam of mousemove events
  931. if(!tt_op && !tt_ie)
  932. {
  933. if(tt_bWait)
  934. return;
  935. tt_bWait = true;
  936. tt_tWaitMov.Timer("tt_bWait = false;", 1, true);
  937. }
  938. if(tt_aV[FIX])
  939. {
  940. var iY = tt_aV[FIX][1];
  941. // For a fixed tip to be positioned above the mouse, use the
  942. // bottom edge as anchor
  943. // (recommended by Christophe Rebeschini, 31.1.2008)
  944. if(tt_aV[ABOVE])
  945. iY -= tt_h;
  946. tt_iState &= ~0x4;
  947. tt_SetTipPos(tt_aV[FIX][0], tt_aV[FIX][1]);
  948. }
  949. else if(!tt_ExtCallFncs(e, "MoveBefore"))
  950. tt_SetTipPos(tt_Pos(0), tt_Pos(1));
  951. tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter")
  952. }
  953. }
  954. function tt_Pos(iDim)
  955. {
  956. var iX, bJmpMode, cmdAlt, cmdOff, cx, iMax, iScrl, iMus, bJmp;
  957. // Map values according to dimension to calculate
  958. if(iDim)
  959. {
  960. bJmpMode = tt_aV[JUMPVERT];
  961. cmdAlt = ABOVE;
  962. cmdOff = OFFSETY;
  963. cx = tt_h;
  964. iMax = tt_maxPosY;
  965. iScrl = tt_scrlY;
  966. iMus = tt_musY;
  967. bJmp = tt_bJmpVert;
  968. }
  969. else
  970. {
  971. bJmpMode = tt_aV[JUMPHORZ];
  972. cmdAlt = LEFT;
  973. cmdOff = OFFSETX;
  974. cx = tt_w;
  975. iMax = tt_maxPosX;
  976. iScrl = tt_scrlX;
  977. iMus = tt_musX;
  978. bJmp = tt_bJmpHorz;
  979. }
  980. if(bJmpMode)
  981. {
  982. if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16))
  983. iX = tt_PosAlt(iDim);
  984. else if(!tt_aV[cmdAlt] && bJmp && tt_CalcPosDef(iDim) > iMax - 16)
  985. iX = tt_PosAlt(iDim);
  986. else
  987. iX = tt_PosDef(iDim);
  988. }
  989. else
  990. {
  991. iX = iMus;
  992. if(tt_aV[cmdAlt])
  993. iX -= cx + tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
  994. else
  995. iX += tt_aV[cmdOff];
  996. }
  997. // Prevent tip from extending past clientarea boundary
  998. if(iX > iMax)
  999. iX = bJmpMode ? tt_PosAlt(iDim) : iMax;
  1000. // In case of insufficient space on both sides, ensure the left/upper part
  1001. // of the tip be visible
  1002. if(iX < iScrl)
  1003. iX = bJmpMode ? tt_PosDef(iDim) : iScrl;
  1004. return iX;
  1005. }
  1006. function tt_PosDef(iDim)
  1007. {
  1008. if(iDim)
  1009. tt_bJmpVert = tt_aV[ABOVE];
  1010. else
  1011. tt_bJmpHorz = tt_aV[LEFT];
  1012. return tt_CalcPosDef(iDim);
  1013. }
  1014. function tt_PosAlt(iDim)
  1015. {
  1016. if(iDim)
  1017. tt_bJmpVert = !tt_aV[ABOVE];
  1018. else
  1019. tt_bJmpHorz = !tt_aV[LEFT];
  1020. return tt_CalcPosAlt(iDim);
  1021. }
  1022. function tt_CalcPosDef(iDim)
  1023. {
  1024. return iDim ? (tt_musY + tt_aV[OFFSETY]) : (tt_musX + tt_aV[OFFSETX]);
  1025. }
  1026. function tt_CalcPosAlt(iDim)
  1027. {
  1028. var cmdOff = iDim ? OFFSETY : OFFSETX;
  1029. var dx = tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0);
  1030. if(tt_aV[cmdOff] > 0 && dx <= 0)
  1031. dx = 1;
  1032. return((iDim ? (tt_musY - tt_h) : (tt_musX - tt_w)) - dx);
  1033. }
  1034. function tt_Fade(a, now, z, n)
  1035. {
  1036. if(n)
  1037. {
  1038. now += Math.round((z - now) / n);
  1039. if((z > a) ? (now >= z) : (now <= z))
  1040. now = z;
  1041. else
  1042. tt_tFade.Timer("tt_Fade("
  1043. + a + "," + now + "," + z + "," + (n - 1)
  1044. + ")",
  1045. tt_aV[FADEINTERVAL],
  1046. true);
  1047. }
  1048. now ? tt_SetTipOpa(now) : tt_Hide();
  1049. }
  1050. function tt_SetTipOpa(opa)
  1051. {
  1052. // To circumvent the opacity nesting flaws of IE, we set the opacity
  1053. // for each sub-DIV separately, rather than for the container DIV.
  1054. tt_SetOpa(tt_aElt[5], opa);
  1055. if(tt_aElt[1])
  1056. tt_SetOpa(tt_aElt[1], opa);
  1057. if(tt_aV[SHADOW])
  1058. {
  1059. opa = Math.round(opa * 0.8);
  1060. tt_SetOpa(tt_aElt[7], opa);
  1061. tt_SetOpa(tt_aElt[8], opa);
  1062. }
  1063. }
  1064. function tt_OnScrl()
  1065. {
  1066. tt_scrlX = tt_GetScrollX();
  1067. tt_scrlY = tt_GetScrollY();
  1068. }
  1069. function tt_OnCloseBtnOver(iOver)
  1070. {
  1071. var css = tt_aElt[4].style;
  1072. iOver <<= 1;
  1073. css.background = tt_aV[CLOSEBTNCOLORS][iOver];
  1074. css.color = tt_aV[CLOSEBTNCOLORS][iOver + 1];
  1075. }
  1076. function tt_OnLClick(e)
  1077. {
  1078. // Ignore right-clicks
  1079. e = e || window.event;
  1080. if(!((e.button && e.button & 2) || (e.which && e.which == 3)))
  1081. {
  1082. if(tt_aV[CLICKSTICKY] && (tt_iState & 0x4))
  1083. {
  1084. tt_aV[STICKY] = true;
  1085. tt_iState &= ~0x4;
  1086. }
  1087. else if(tt_aV[CLICKCLOSE])
  1088. tt_HideInit();
  1089. }
  1090. }
  1091. function tt_Int(x)
  1092. {
  1093. var y;
  1094. return(isNaN(y = parseInt(x)) ? 0 : y);
  1095. }
  1096. Number.prototype.Timer = function(s, iT, bUrge)
  1097. {
  1098. if(!this.value || bUrge)
  1099. this.value = window.setTimeout(s, iT);
  1100. }
  1101. Number.prototype.EndTimer = function()
  1102. {
  1103. if(this.value)
  1104. {
  1105. window.clearTimeout(this.value);
  1106. this.value = 0;
  1107. }
  1108. }
  1109. function tt_SetOpa(el, opa)
  1110. {
  1111. var css = el.style;
  1112. tt_opa = opa;
  1113. if(tt_flagOpa == 1)
  1114. {
  1115. if(opa < 100)
  1116. {
  1117. // Hacks for bugs of IE:
  1118. // 1.) Once a CSS filter has been applied, fonts are no longer
  1119. // anti-aliased, so we store the previous 'non-filter' to be
  1120. // able to restore it
  1121. if(typeof(el.filtNo) == tt_u)
  1122. el.filtNo = css.filter;
  1123. // 2.) A DIV cannot be made visible in a single step if an
  1124. // opacity < 100 has been applied while the DIV was hidden
  1125. var bVis = css.visibility != "hidden";
  1126. // 3.) In IE6, applying an opacity < 100 has no effect if the
  1127. // element has no layout (position, size, zoom, ...)
  1128. css.zoom = "100%";
  1129. if(!bVis)
  1130. css.visibility = "visible";
  1131. css.filter = "alpha(opacity=" + opa + ")";
  1132. if(!bVis)
  1133. css.visibility = "hidden";
  1134. }
  1135. else if(typeof(el.filtNo) != tt_u)
  1136. // Restore 'non-filter'
  1137. css.filter = el.filtNo;
  1138. }
  1139. else
  1140. {
  1141. opa /= 100.0;
  1142. switch(tt_flagOpa)
  1143. {
  1144. case 2:
  1145. css.KhtmlOpacity = opa; break;
  1146. case 3:
  1147. css.KHTMLOpacity = opa; break;
  1148. case 4:
  1149. css.MozOpacity = opa; break;
  1150. case 5:
  1151. css.opacity = opa; break;
  1152. }
  1153. }
  1154. }
  1155. function tt_MovDomNode(el, dadFrom, dadTo)
  1156. {
  1157. if(dadFrom)
  1158. dadFrom.removeChild(el);
  1159. if(dadTo)
  1160. dadTo.appendChild(el);
  1161. }
  1162. function tt_Err(sErr, bIfDebug)
  1163. {
  1164. if(tt_Debug || !bIfDebug)
  1165. alert("Tooltip Script Error Message:\n\n" + sErr);
  1166. }
  1167. //============ EXTENSION (PLUGIN) MANAGER ===============//
  1168. function tt_ExtCmdEnum()
  1169. {
  1170. var s;
  1171. // Add new command(s) to the commands enum
  1172. for(var i in config)
  1173. {
  1174. s = "window." + i.toString().toUpperCase();
  1175. if(eval("typeof(" + s + ") == tt_u"))
  1176. {
  1177. eval(s + " = " + tt_aV.length);
  1178. tt_aV[tt_aV.length] = null;
  1179. }
  1180. }
  1181. }
  1182. function tt_ExtCallFncs(arg, sFnc)
  1183. {
  1184. var b = false;
  1185. for(var i = tt_aExt.length; i;)
  1186. {--i;
  1187. var fnc = tt_aExt[i]["On" + sFnc];
  1188. // Call the method the extension has defined for this event
  1189. if(fnc && fnc(arg))
  1190. b = true;
  1191. }
  1192. return b;
  1193. }
  1194. tt_Init();