?? wz_tooltip.js
字號:
{
var css = tt_aElt[0].style;
css.visibility = "hidden";
css.position = "absolute";
css.overflow = "hidden";
return true;
}
return false;
}
function tt_ResetMainDiv()
{
var w = (window.screen && screen.width) ? screen.width : 10000;
tt_SetTipPos(-w, 0);
tt_aElt[0].innerHTML = "";
tt_aElt[0].style.width = (w - 1) + "px";
}
function tt_IsW3cBox()
{
var css = tt_aElt[0].style;
css.padding = "10px";
css.width = "40px";
tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40);
css.padding = "0px";
tt_ResetMainDiv();
}
function tt_OpaSupport()
{
var css = tt_body.style;
tt_flagOpa = (typeof(css.filter) != tt_u) ? 1
: (typeof(css.KhtmlOpacity) != tt_u) ? 2
: (typeof(css.KHTMLOpacity) != tt_u) ? 3
: (typeof(css.MozOpacity) != tt_u) ? 4
: (typeof(css.opacity) != tt_u) ? 5
: 0;
}
// Ported from http://dean.edwards.name/weblog/2006/06/again/
// (Dean Edwards et al.)
function tt_SetOnloadFnc()
{
tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags);
tt_AddEvtFnc(window, "load", tt_HideSrcTags);
if(tt_body.attachEvent)
tt_body.attachEvent("onreadystatechange",
function() {
if(tt_body.readyState == "complete")
tt_HideSrcTags();
} );
if(/WebKit|KHTML/i.test(navigator.userAgent))
{
var t = setInterval(function() {
if(/loaded|complete/.test(document.readyState))
{
clearInterval(t);
tt_HideSrcTags();
}
}, 10);
}
}
function tt_HideSrcTags()
{
if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done)
return;
window.tt_HideSrcTags.done = true;
if(!tt_HideSrcTagsRecurs(tt_body))
tt_Err("To enable the capability to convert HTML elements to tooltips,"
+ " you must set TagsToTip in the global tooltip configuration"
+ " to true.");
}
function tt_HideSrcTagsRecurs(dad)
{
var a, ovr, asT2t;
// Walk the DOM tree for tags that have an onmouseover attribute
// containing a TagToTip('...') call.
// (.childNodes first since .children is bugous in Safari)
a = dad.childNodes || dad.children || null;
for(var i = a ? a.length : 0; i;)
{--i;
if(!tt_HideSrcTagsRecurs(a[i]))
return false;
ovr = a[i].getAttribute ? a[i].getAttribute("onmouseover")
: (typeof a[i].onmouseover == "function") ? a[i].onmouseover
: null;
if(ovr)
{
asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/);
if(asT2t && asT2t.length)
{
if(!tt_HideSrcTag(asT2t[0]))
return false;
}
}
}
return true;
}
function tt_HideSrcTag(sT2t)
{
var id, el;
// The ID passed to the found TagToTip() call identifies an HTML element
// to be converted to a tooltip, so hide that element
id = sT2t.replace(/.+'([^'.]+)'.+/, "$1");
el = tt_GetElt(id);
if(el)
{
if(tt_Debug && !TagsToTip)
return false;
else
el.style.display = "none";
}
else
tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()."
+ " There exists no HTML element with that ID.");
return true;
}
function tt_Tip(arg, t2t)
{
if(!tt_db)
return;
if(tt_iState)
tt_Hide();
if(!tt_Enabled)
return;
tt_t2t = t2t;
if(!tt_ReadCmds(arg))
return;
tt_iState = 0x1 | 0x4;
tt_AdaptConfig1();
tt_MkTipContent(arg);
tt_MkTipSubDivs();
tt_FormatTip();
tt_bJmpVert = false;
tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1;
tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1;
tt_AdaptConfig2();
// We must fake the first mousemove in order to ensure the tip
// be immediately shown and positioned
tt_Move();
tt_ShowInit();
}
function tt_ReadCmds(a)
{
var i;
// First load the global config values, to initialize also values
// for which no command has been passed
i = 0;
for(var j in config)
tt_aV[i++] = config[j];
// Then replace each cached config value for which a command has been
// passed (ensure the # of command args plus value args be even)
if(a.length & 1)
{
for(i = a.length - 1; i > 0; i -= 2)
tt_aV[a[i - 1]] = a[i];
return true;
}
tt_Err("Incorrect call of Tip() or TagToTip().\n"
+ "Each command must be followed by a value.");
return false;
}
function tt_AdaptConfig1()
{
tt_ExtCallFncs(0, "LoadConfig");
// Inherit unspecified title formattings from body
if(!tt_aV[TITLEBGCOLOR].length)
tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR];
if(!tt_aV[TITLEFONTCOLOR].length)
tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR];
if(!tt_aV[TITLEFONTFACE].length)
tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE];
if(!tt_aV[TITLEFONTSIZE].length)
tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE];
if(tt_aV[CLOSEBTN])
{
// Use title colors for non-specified closebutton colors
if(!tt_aV[CLOSEBTNCOLORS])
tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", "");
for(var i = 4; i;)
{--i;
if(!tt_aV[CLOSEBTNCOLORS][i].length)
tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR];
}
// Enforce titlebar be shown
if(!tt_aV[TITLE].length)
tt_aV[TITLE] = " ";
}
// Circumvents broken display of images and fade-in flicker in Geckos < 1.8
if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every)
tt_aV[OPACITY] = 99;
// Smartly shorten the delay for fade-in tooltips
if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100)
tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100);
}
function tt_AdaptConfig2()
{
if(tt_aV[CENTERMOUSE])
tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1);
}
// Expose content globally so extensions can modify it
function tt_MkTipContent(a)
{
if(tt_t2t)
{
if(tt_aV[COPYCONTENT])
tt_sContent = tt_t2t.innerHTML;
else
tt_sContent = "";
}
else
tt_sContent = a[0];
tt_ExtCallFncs(0, "CreateContentString");
}
function tt_MkTipSubDivs()
{
var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;',
sTbTrTd = ' cellspacing=0 cellpadding=0 border=0 style="' + sCss + '"><tbody style="' + sCss + '"><tr><td ';
tt_aElt[0].innerHTML =
(''
+ (tt_aV[TITLE].length ?
('<div id="WzTiTl" style="position:relative;z-index:1;">'
+ '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">'
+ tt_aV[TITLE]
+ '</td>'
+ (tt_aV[CLOSEBTN] ?
('<td align="right" style="' + sCss
+ 'text-align:right;">'
+ '<span id="WzClOsE" style="padding-left:2px;padding-right:2px;'
+ 'cursor:' + (tt_ie ? 'hand' : 'pointer')
+ ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">'
+ tt_aV[CLOSEBTNTEXT]
+ '</span></td>')
: '')
+ '</tr></tbody></table></div>')
: '')
+ '<div id="WzBoDy" style="position:relative;z-index:0;">'
+ '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">'
+ tt_sContent
+ '</td></tr></tbody></table></div>'
+ (tt_aV[SHADOW]
? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>'
+ '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>')
: '')
);
tt_GetSubDivRefs();
// Convert DOM node to tip
if(tt_t2t && !tt_aV[COPYCONTENT])
{
// Store the tag's parent element so we can restore that DOM branch
// once the tooltip is hidden
tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null;
if(tt_t2tDad)
{
tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]);
tt_t2t.style.display = "block";
}
}
tt_ExtCallFncs(0, "SubDivsCreated");
}
function tt_GetSubDivRefs()
{
var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR");
for(var i = aId.length; i; --i)
tt_aElt[i] = tt_GetElt(aId[i - 1]);
}
function tt_FormatTip()
{
var css, w, iOffY, iOffSh;
//--------- Title DIV ----------
if(tt_aV[TITLE].length)
{
css = tt_aElt[1].style;
css.background = tt_aV[TITLEBGCOLOR];
css.paddingTop = (tt_aV[CLOSEBTN] ? 2 : 0) + "px";
css.paddingBottom = "1px";
css.paddingLeft = css.paddingRight = tt_aV[PADDING] + "px";
css = tt_aElt[3].style;
css.color = tt_aV[TITLEFONTCOLOR];
css.fontFamily = tt_aV[TITLEFONTFACE];
css.fontSize = tt_aV[TITLEFONTSIZE];
css.fontWeight = "bold";
css.textAlign = tt_aV[TITLEALIGN];
// Close button DIV
if(tt_aElt[4])
{
css.paddingRight = (tt_aV[PADDING] << 1) + "px";
css = tt_aElt[4].style;
css.background = tt_aV[CLOSEBTNCOLORS][0];
css.color = tt_aV[CLOSEBTNCOLORS][1];
css.fontFamily = tt_aV[TITLEFONTFACE];
css.fontSize = tt_aV[TITLEFONTSIZE];
css.fontWeight = "bold";
}
if(tt_aV[WIDTH] > 0)
tt_w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
else
{
tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]);
// Some spacing between title DIV and closebutton
if(tt_aElt[4])
tt_w += tt_aV[PADDING];
}
// Ensure the top border of the body DIV be covered by the title DIV
iOffY = -tt_aV[BORDERWIDTH];
}
else
{
tt_w = 0;
iOffY = 0;
}
//-------- Body DIV ------------
css = tt_aElt[5].style;
css.top = iOffY + "px";
if(tt_aV[BORDERWIDTH])
{
css.borderColor = tt_aV[BORDERCOLOR];
css.borderStyle = tt_aV[BORDERSTYLE];
css.borderWidth = tt_aV[BORDERWIDTH] + "px";
}
if(tt_aV[BGCOLOR].length)
css.background = tt_aV[BGCOLOR];
if(tt_aV[BGIMG].length)
css.backgroundImage = "url(" + tt_aV[BGIMG] + ")";
css.padding = tt_aV[PADDING] + "px";
css.textAlign = tt_aV[TEXTALIGN];
// TD inside body DIV
css = tt_aElt[6].style;
css.color = tt_aV[FONTCOLOR];
css.fontFamily = tt_aV[FONTFACE];
css.fontSize = tt_aV[FONTSIZE];
css.fontWeight = tt_aV[FONTWEIGHT];
css.background = "";
css.textAlign = tt_aV[TEXTALIGN];
if(tt_aV[WIDTH] > 0)
w = tt_aV[WIDTH] + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
else
// We measure the width of the body's inner TD, because some browsers
// expand the width of the container and outer body DIV to 100%
w = tt_GetDivW(tt_aElt[6]) + ((tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1);
if(w > tt_w)
tt_w = w;
//--------- Shadow DIVs ------------
if(tt_aV[SHADOW])
{
tt_w += tt_aV[SHADOWWIDTH];
iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3);
// Bottom shadow
css = tt_aElt[7].style;
css.top = iOffY + "px";
css.left = iOffSh + "px";
css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px";
css.height = tt_aV[SHADOWWIDTH] + "px";
css.background = tt_aV[SHADOWCOLOR];
// Right shadow
css = tt_aElt[8].style;
css.top = iOffSh + "px";
css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px";
css.width = tt_aV[SHADOWWIDTH] + "px";
css.background = tt_aV[SHADOWCOLOR];
}
else
iOffSh = 0;
//-------- Container DIV -------
tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]);
tt_FixSize(iOffY, iOffSh);
}
// Fixate the size so it can't dynamically change while the tooltip is moving.
function tt_FixSize(iOffY, iOffSh)
{
var wIn, wOut, i;
tt_aElt[0].style.width = tt_w + "px";
tt_aElt[0].style.pixelWidth = tt_w;
wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -