Changeset 6215

Show
Ignore:
Timestamp:
08/20/08 23:58:12 (3 months ago)
Author:
jmathis
Message:

update walterzorn lib

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/lib/wz_tooltip/wz_tooltip.js

    r5725 r6215  
    22Copyright (c) 2002-2008 Walter Zorn. All rights reserved. 
    33 
    4 wz_tooltip.js    v. 5.13 
     4wz_tooltip.js    v. 5.20 
    55 
    66The latest version is available at 
     
    1010 
    1111Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com ) 
    12 Last modified: 13.6.2008 
     12Last modified: 1.8.2008 
    1313 
    1414Easy-to-use cross-browser tooltips. 
    1515Just include the script at the beginning of the <body> section, and invoke 
    16 Tip('Tooltip text') to show and UnTip() to hide the tooltip, from the desired  
     16Tip('Tooltip text') to show and UnTip() to hide the tooltip, from the desired 
    1717HTML eventhandlers. Example: 
    1818<a onmouseover="Tip('Some text')" onmouseout="UnTip()" href="index.htm">My home page</a> 
     
    7474config. FadeOut                 = 0 
    7575config. FadeInterval    = 30            // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load 
    76 config. Fix                             = null          // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation 
     76config. Fix                             = null          // Fixated position, two modes. Mode 1: x- an y-coordinates in brackets, e.g. [210, 480]. Mode 2: Show tooltip at a position related to an HTML element: [ID of HTML element, x-offset, y-offset from HTML element], e.g. ['SomeID', 10, 30]. Value null (default) for no fixated positioning. 
    7777config. FollowMouse             = true          // false or true - tooltip follows the mouse 
    7878config. FontColor               = '#000044' 
     
    135135tt_aV = new Array(),    // Caches and enumerates config data for currently active tooltip 
    136136tt_sContent,                    // Inner tooltip text or HTML 
     137tt_t2t, tt_t2tDad,              // Tag converted to tip, and its DOM parent element 
    137138tt_scrlX = 0, tt_scrlY = 0, 
    138139tt_musX, tt_musY, 
     
    205206                        tt_RemEvtFnc(document, "mouseup", tt_OnLClick); 
    206207                tt_ExtCallFncs(0, "Kill"); 
    207                 // In case of a TagToTip tooltip, hide converted DOM node and 
    208                 // re-insert it into document 
     208                // In case of a TagToTip tip, hide converted DOM node and 
     209                // re-insert it into DOM 
    209210                if(tt_t2t && !tt_aV[COPYCONTENT]) 
    210                 { 
    211                         tt_t2t.style.display = "none"; 
    212                         tt_MovDomNode(tt_t2t, tt_aElt[6], tt_t2tDad); 
    213                 } 
     211                        tt_UnEl2Tip(); 
    214212                tt_iState = 0; 
    215213                tt_over = null; 
     
    243241function tt_GetClientW() 
    244242{ 
    245         return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth 
    246                         : (typeof(window.innerWidth) != tt_u) ? window.innerWidth 
    247                         : tt_db ? (tt_db.clientWidth || 0) 
    248                         : 0); 
     243        var de = document.documentElement; 
     244        return((de && de.clientWidth) ? de.clientWidth : (document.body.clientWidth || window.innerWidth || 0)); 
    249245} 
    250246function tt_GetClientH() 
    251247{ 
    252         // Exactly this order seems to yield correct values in all major browsers 
    253         return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight 
    254                         : (typeof(window.innerHeight) != tt_u) ? window.innerHeight 
    255                         : tt_db ? (tt_db.clientHeight || 0) 
    256                         : 0); 
     248        var de = document.documentElement; 
     249        return((de && de.clientHeight) ? de.clientHeight : (document.body.clientHeight || window.innerHeight || 0)); 
    257250} 
    258251function tt_GetEvtX(e) 
     
    283276                        el.detachEvent("on" + sEvt, PFnc); 
    284277        } 
     278} 
     279function tt_GetDad(el) 
     280{ 
     281        return(el.parentNode || el.parentElement || el.offsetParent); 
     282} 
     283function tt_MovDomNode(el, dadFrom, dadTo) 
     284{ 
     285        if(dadFrom) 
     286                dadFrom.removeChild(el); 
     287        if(dadTo) 
     288                dadTo.appendChild(el); 
    285289} 
    286290 
     
    296300tt_opa,                                 // Currently applied opacity 
    297301tt_bJmpVert, tt_bJmpHorz,// Tip temporarily on other side of mouse 
    298 tt_t2t, tt_t2tDad,              // Tag converted to tip, and its parent element in the document 
    299302tt_elDeHref,                    // The tag from which we've removed the href attribute 
    300303// Timer 
     
    311314        if(!tt_Browser() || !tt_MkMainDiv()) 
    312315                return; 
    313         // Levy 06/11/2008: Important! IE doesn't fire an onscroll when a page  
     316        // Levy 06/11/2008: Important! IE doesn't fire an onscroll when a page 
    314317        // refresh is made, so we need to recalc page positions on init. 
    315318        tt_OnScrl(); 
     
    670673        // Convert DOM node to tip 
    671674        if(tt_t2t && !tt_aV[COPYCONTENT]) 
    672         { 
    673                 // Store the tag's parent element so we can restore that DOM branch 
    674                 // once the tooltip is hidden 
    675                 tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null; 
    676                 if(tt_t2tDad) 
    677                 { 
    678                         tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]); 
    679                         tt_t2t.style.display = "block"; 
    680                 } 
    681         } 
     675                tt_El2Tip(); 
    682676        tt_ExtCallFncs(0, "SubDivsCreated"); 
    683677} 
     
    693687        var css, w, h, pad = tt_aV[PADDING], padT, wBrd = tt_aV[BORDERWIDTH], 
    694688        iOffY, iOffSh, iAdd = (pad + wBrd) << 1; 
    695          
     689 
    696690        //--------- Title DIV ---------- 
    697691        if(tt_aV[TITLE].length) 
     
    770764        css.fontSize = tt_aV[FONTSIZE]; 
    771765        css.fontWeight = tt_aV[FONTWEIGHT]; 
    772         css.background = ""; 
    773766        css.textAlign = tt_aV[TEXTALIGN]; 
    774767        if(tt_aV[WIDTH] > 0) 
     
    887880        while(el) 
    888881        { 
    889                 if(el.hasAttribute("href")) 
     882                if(el.hasAttribute && el.hasAttribute("href")) 
    890883                { 
    891884                        el.t_href = el.getAttribute("href"); 
     
    898891                        break; 
    899892                } 
    900                 el = el.parentElement; 
     893                el = tt_GetDad(el); 
    901894        } 
    902895} 
     
    910903                tt_elDeHref = null; 
    911904        } 
     905} 
     906function tt_El2Tip() 
     907{ 
     908        var css = tt_t2t.style; 
     909 
     910        // Store previous positioning 
     911        tt_t2t.t_cp = css.position; 
     912        tt_t2t.t_cl = css.left; 
     913        tt_t2t.t_ct = css.top; 
     914        tt_t2t.t_cd = css.display; 
     915        // Store the tag's parent element so we can restore that DOM branch 
     916        // when the tooltip is being hidden 
     917        tt_t2tDad = tt_GetDad(tt_t2t); 
     918        tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]); 
     919        css.display = "block"; 
     920        css.position = "static"; 
     921        css.left = css.top = css.marginLeft = css.marginTop = "0px"; 
     922} 
     923function tt_UnEl2Tip() 
     924{ 
     925        // Restore positioning and display 
     926        var css = tt_t2t.style; 
     927 
     928        css.display = tt_t2t.t_cd; 
     929        tt_MovDomNode(tt_t2t, tt_GetDad(tt_t2t), tt_t2tDad); 
     930        css.position = tt_t2t.t_cp; 
     931        css.left = tt_t2t.t_cl; 
     932        css.top = tt_t2t.t_ct; 
     933        tt_t2tDad = null; 
    912934} 
    913935function tt_OverInit() 
     
    9781000                if(tt_aV[FIX]) 
    9791001                { 
    980                         var iY = tt_aV[FIX][1]; 
    981                         // For a fixed tip to be positioned above the mouse, use the 
    982                         // bottom edge as anchor 
    983                         // (recommended by Christophe Rebeschini, 31.1.2008) 
    984                         if(tt_aV[ABOVE]) 
    985                                 iY -= tt_h; 
    9861002                        tt_iState &= ~0x4; 
    987                         tt_SetTipPos(tt_aV[FIX][0], tt_aV[FIX][1]); 
     1003                        tt_PosFix(); 
    9881004                } 
    9891005                else if(!tt_ExtCallFncs(e, "MoveBefore")) 
     
    9941010function tt_Pos(iDim) 
    9951011{ 
    996         var iX, bJmpMode, cmdAlt, cmdOff, cx, iMax, iScrl, iMus, bJmp; 
     1012        var iX, bJmpMod, cmdAlt, cmdOff, cx, iMax, iScrl, iMus, bJmp; 
    9971013 
    9981014        // Map values according to dimension to calculate 
    9991015        if(iDim) 
    10001016        { 
    1001                 bJmpMode = tt_aV[JUMPVERT]; 
     1017                bJmpMod = tt_aV[JUMPVERT]; 
    10021018                cmdAlt = ABOVE; 
    10031019                cmdOff = OFFSETY; 
     
    10101026        else 
    10111027        { 
    1012                 bJmpMode = tt_aV[JUMPHORZ]; 
     1028                bJmpMod = tt_aV[JUMPHORZ]; 
    10131029                cmdAlt = LEFT; 
    10141030                cmdOff = OFFSETX; 
     
    10191035                bJmp = tt_bJmpHorz; 
    10201036        } 
    1021         if(bJmpMode) 
     1037        if(bJmpMod) 
    10221038        { 
    10231039                if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16)) 
     
    10381054        // Prevent tip from extending past clientarea boundary 
    10391055        if(iX > iMax) 
    1040                 iX = bJmpMode ? tt_PosAlt(iDim) : iMax; 
     1056                iX = bJmpMod ? tt_PosAlt(iDim) : iMax; 
    10411057        // In case of insufficient space on both sides, ensure the left/upper part 
    10421058        // of the tip be visible 
    10431059        if(iX < iScrl) 
    1044                 iX = bJmpMode ? tt_PosDef(iDim) : iScrl; 
     1060                iX = bJmpMod ? tt_PosDef(iDim) : iScrl; 
    10451061        return iX; 
    10461062} 
     
    10731089        return((iDim ? (tt_musY - tt_h) : (tt_musX - tt_w)) - dx); 
    10741090} 
     1091function tt_PosFix() 
     1092{ 
     1093        var iX, iY; 
     1094 
     1095        if(typeof(tt_aV[FIX][0]) == "number") 
     1096        { 
     1097                iX = tt_aV[FIX][0]; 
     1098                iY = tt_aV[FIX][1]; 
     1099        } 
     1100        else 
     1101        { 
     1102                if(typeof(tt_aV[FIX][0]) == "string") 
     1103                        el = tt_GetElt(tt_aV[FIX][0]); 
     1104                // First slot in array is direct reference to HTML element 
     1105                else 
     1106                        el = tt_aV[FIX][0]; 
     1107                iX = tt_aV[FIX][1]; 
     1108                iY = tt_aV[FIX][2]; 
     1109                // By default, vert pos is related to bottom edge of HTML element 
     1110                if(!tt_aV[ABOVE] && el) 
     1111                        iY += tt_GetDivH(el); 
     1112                for(; el; el = el.offsetParent) 
     1113                { 
     1114                        iX += el.offsetLeft || 0; 
     1115                        iY += el.offsetTop || 0; 
     1116                } 
     1117        } 
     1118        // For a fixed tip positioned above the mouse, use the bottom edge as anchor 
     1119        // (recommended by Christophe Rebeschini, 31.1.2008) 
     1120        if(tt_aV[ABOVE]) 
     1121                iY -= tt_h; 
     1122        tt_SetTipPos(iX, iY); 
     1123} 
    10751124function tt_Fade(a, now, z, n) 
    10761125{ 
     
    10811130                        now = z; 
    10821131                else 
    1083                         tt_tFade.Timer("tt_Fade(" 
    1084                                                         + a + "," + now + "," + z + "," + (n - 1) 
    1085                                                         + ")", 
    1086                                                         tt_aV[FADEINTERVAL], 
    1087                                                         true); 
     1132                        tt_tFade.Timer( 
     1133                                        "tt_Fade(" 
     1134                                        + a + "," + now + "," + z + "," + (n - 1) 
     1135                                        + ")", 
     1136                                        tt_aV[FADEINTERVAL], 
     1137                                        true 
     1138                        ); 
    10881139        } 
    10891140        now ? tt_SetTipOpa(now) : tt_Hide(); 
     
    11971248        } 
    11981249} 
    1199 function tt_MovDomNode(el, dadFrom, dadTo) 
    1200 { 
    1201         if(dadFrom) 
    1202                 dadFrom.removeChild(el); 
    1203         if(dadTo) 
    1204                 dadTo.appendChild(el); 
    1205 } 
    12061250function tt_Err(sErr, bIfDebug) 
    12071251{