📄 overlib.js
字号:
// LAYER GENERATION FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
// Makes simple table without caption
function ol_content_simple(text) {
if (o3_css == CSSCLASS) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 class=\""+o3_bgclass+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 class=\""+o3_fgclass+"\"><TR><TD VALIGN=TOP><FONT class=\""+o3_textfontclass+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
if (o3_css == CSSSTYLE) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 style=\"background-color: "+o3_bgcolor+"; height: "+o3_height+o3_heightunit+";\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 style=\"color: "+o3_fgcolor+"; background-color: "+o3_fgcolor+"; height: "+o3_height+o3_heightunit+";\"><TR><TD VALIGN=TOP><FONT style=\"font-family: "+o3_textfont+"; color: "+o3_textcolor+"; font-size: "+o3_textsize+o3_textsizeunit+"; text-decoration: "+o3_textdecoration+"; font-weight: "+o3_textweight+"; font-style:"+o3_textstyle+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
if (o3_css == CSSOFF) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 "+o3_bgcolor+" "+o3_height+"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 "+o3_fgcolor+" "+o3_fgbackground+" "+o3_height+"><TR><TD VALIGN=TOP><FONT FACE=\""+o3_textfont+"\" COLOR=\""+o3_textcolor+"\" SIZE=\""+o3_textsize+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
set_background("");
return txt;
}
// Makes table with caption and optional close link
function ol_content_caption(text, title, close) {
closing = "";
closeevent = "onMouseOver";
if (o3_closeclick == 1) closeevent = "onClick";
if (o3_capicon != "") o3_capicon = "<IMG SRC=\""+o3_capicon+"\"> ";
if (close != "") {
if (o3_css == CSSCLASS) closing = "<TD ALIGN=RIGHT><A HREF=\"/\" "+closeevent+"=\"return cClick();\" class=\""+o3_closefontclass+"\">"+close+"</A></TD>";
if (o3_css == CSSSTYLE) closing = "<TD ALIGN=RIGHT><A HREF=\"/\" "+closeevent+"=\"return cClick();\" style=\"color: "+o3_closecolor+"; font-family: "+o3_closefont+"; font-size: "+o3_closesize+o3_closesizeunit+"; text-decoration: "+o3_closedecoration+"; font-weight: "+o3_closeweight+"; font-style:"+o3_closestyle+";\">"+close+"</A></TD>";
if (o3_css == CSSOFF) closing = "<TD ALIGN=RIGHT><A HREF=\"/\" "+closeevent+"=\"return cClick();\"><FONT COLOR=\""+o3_closecolor+"\" FACE=\""+o3_closefont+"\" SIZE=\""+o3_closesize+"\">"+close+"</FONT></A></TD>";
}
if (o3_css == CSSCLASS) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 class=\""+o3_bgclass+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><FONT class=\""+o3_captionfontclass+"\">"+o3_capicon+title+"</FONT></TD>"+closing+"</TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 class=\""+o3_fgclass+"\"><TR><TD VALIGN=TOP><FONT class=\""+o3_textfontclass+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
if (o3_css == CSSSTYLE) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 style=\"background-color: "+o3_bgcolor+"; background-image: url("+o3_bgbackground+"); height: "+o3_height+o3_heightunit+";\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><FONT style=\"font-family: "+o3_captionfont+"; color: "+o3_capcolor+"; font-size: "+o3_captionsize+o3_captionsizeunit+"; font-weight: "+o3_captionweight+"; font-style: "+o3_captionstyle+";\">"+o3_capicon+title+"</FONT></TD>"+closing+"</TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 style=\"color: "+o3_fgcolor+"; background-color: "+o3_fgcolor+"; height: "+o3_height+o3_heightunit+";\"><TR><TD VALIGN=TOP><FONT style=\"font-family: "+o3_textfont+"; color: "+o3_textcolor+"; font-size: "+o3_textsize+o3_textsizeunit+"; text-decoration: "+o3_textdecoration+"; font-weight: "+o3_textweight+"; font-style:"+o3_textstyle+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
if (o3_css == CSSOFF) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 "+o3_bgcolor+" "+o3_bgbackground+" "+o3_height+"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=1><TR><td>"+o3_capicon+"</td><TD valign=\"middle\" align=\"center\"><B><FONT COLOR=\""+o3_capcolor+"\" FACE=\""+o3_captionfont+"\" SIZE=\""+o3_captionsize+"\">"+title+"</FONT></B></TD>"+closing+"</TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 "+o3_fgcolor+" "+o3_fgbackground+" "+o3_height+"><TR><TD VALIGN=TOP><FONT COLOR=\""+o3_textcolor+"\" FACE=\""+o3_textfont+"\" SIZE=\""+o3_textsize+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
set_background("");
return txt;
}
// Sets the background picture, padding and lots more. :)
function ol_content_background(text, picture, hasfullhtml) {
if (hasfullhtml) {
txt = text;
} else {
if (o3_css == CSSCLASS) txt = "<TABLE WIDTH="+o3_width+o3_widthunit+" BORDER=0 CELLPADDING=0 CELLSPACING=0 HEIGHT="+o3_height+o3_heightunit+"><TR><TD COLSPAN=3 HEIGHT="+o3_padyt+o3_padunit+"></TD></TR><TR><TD WIDTH="+o3_padxl+o3_padunit+"></TD><TD VALIGN=TOP WIDTH="+(o3_width-o3_padxl-o3_padxr)+o3_padunit+"><FONT class=\""+o3_textfontclass+"\">"+text+"</FONT></TD><TD WIDTH="+o3_padxr+o3_padunit+"></TD></TR><TR><TD COLSPAN=3 HEIGHT="+o3_padyb+o3_padunit+"></TD></TR></TABLE>";
if (o3_css == CSSSTYLE) txt = "<TABLE WIDTH="+o3_width+o3_widthunit+" BORDER=0 CELLPADDING=0 CELLSPACING=0 HEIGHT="+o3_height+o3_heightunit+"><TR><TD COLSPAN=3 HEIGHT="+o3_padyt+o3_padunit+"></TD></TR><TR><TD WIDTH="+o3_padxl+o3_padunit+"></TD><TD VALIGN=TOP WIDTH="+(o3_width-o3_padxl-o3_padxr)+o3_padunit+"><FONT style=\"font-family: "+o3_textfont+"; color: "+o3_textcolor+"; font-size: "+o3_textsize+o3_textsizeunit+";\">"+text+"</FONT></TD><TD WIDTH="+o3_padxr+o3_padunit+"></TD></TR><TR><TD COLSPAN=3 HEIGHT="+o3_padyb+o3_padunit+"></TD></TR></TABLE>";
if (o3_css == CSSOFF) txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING=0 CELLSPACING=0 HEIGHT="+o3_height+"><TR><TD COLSPAN=3 HEIGHT="+o3_padyt+"></TD></TR><TR><TD WIDTH="+o3_padxl+"></TD><TD VALIGN=TOP WIDTH="+(o3_width-o3_padxl-o3_padxr)+"><FONT FACE=\""+o3_textfont+"\" COLOR=\""+o3_textcolor+"\" SIZE=\""+o3_textsize+"\">"+text+"</FONT></TD><TD WIDTH="+o3_padxr+"></TD></TR><TR><TD COLSPAN=3 HEIGHT="+o3_padyb+"></TD></TR></TABLE>";
}
set_background(picture);
return txt;
}
// Loads a picture into the div.
function set_background(pic) {
if (pic == "") {
if (ie4) over.backgroundImage = "none";
if (ns6) over.style.backgroundImage = "none";
} else {
if (ns4) {
over.background.src = pic;
} else if (ie4) {
over.backgroundImage = "url("+pic+")";
} else if (ns6) {
over.style.backgroundImage = "url("+pic+")";
}
}
}
////////////////////////////////////////////////////////////////////////////////////
// HANDLING FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
// Displays the popup
function disp(statustext) {
if ( (ns4) || (ie4) || (ns6) ) {
if (o3_allowmove == 0) {
placeLayer();
showObject(over);
o3_allowmove = 1;
}
}
if (statustext != "") {
self.status = statustext;
}
}
// Decides where we want the popup.
function placeLayer() {
var placeX, placeY;
// HORIZONTAL PLACEMENT
if (o3_fixx > -1) {
// Fixed position
placeX = o3_fixx;
} else {
winoffset = (ie4) ? o3_frame.document.body.scrollLeft : o3_frame.pageXOffset;
if (ie4) iwidth = o3_frame.document.body.clientWidth;
if (ns4) iwidth = o3_frame.innerWidth; // was screwed in mozilla, fixed now?
if (ns6) iwidth = o3_frame.outerWidth;
// If HAUTO, decide what to use.
if (o3_hauto == 1) {
if ( (o3_x - winoffset) > ((eval(iwidth)) / 2)) {
o3_hpos = LEFT;
} else {
o3_hpos = RIGHT;
}
}
// From mouse
if (o3_hpos == CENTER) { // Center
placeX = o3_x+o3_offsetx-(o3_width/2);
}
if (o3_hpos == RIGHT) { // Right
placeX = o3_x+o3_offsetx;
if ( (eval(placeX) + eval(o3_width)) > (winoffset + iwidth) ) {
placeX = iwidth + winoffset - o3_width;
if (placeX < 0) placeX = 0;
}
}
if (o3_hpos == LEFT) { // Left
placeX = o3_x-o3_offsetx-o3_width;
if (placeX < winoffset) placeX = winoffset;
}
// Snapping!
if (o3_snapx > 1) {
var snapping = placeX % o3_snapx;
if (o3_hpos == LEFT) {
placeX = placeX - (o3_snapx + snapping);
} else {
// CENTER and RIGHT
placeX = placeX + (o3_snapx - snapping);
}
if (placeX < winoffset) placeX = winoffset;
}
}
// VERTICAL PLACEMENT
if (o3_fixy > -1) {
// Fixed position
placeY = o3_fixy;
} else {
scrolloffset = (ie4) ? o3_frame.document.body.scrollTop : o3_frame.pageYOffset;
// If VAUTO, decide what to use.
if (o3_vauto == 1) {
if (ie4) iheight = o3_frame.document.body.clientHeight;
if (ns4) iheight = o3_frame.innerHeight;
if (ns6) iheight = o3_frame.outerHeight;
iheight = (eval(iheight)) / 2;
if ( (o3_y - scrolloffset) > iheight) {
o3_vpos = ABOVE;
} else {
o3_vpos = BELOW;
}
}
// From mouse
if (o3_vpos == ABOVE) {
if (o3_aboveheight == 0) {
var divref = (ie4) ? o3_frame.document.all['overDiv'] : over;
o3_aboveheight = (ns4) ? divref.clip.height : divref.offsetHeight;
}
placeY = o3_y - (o3_aboveheight + o3_offsety);
if (placeY < scrolloffset) placeY = scrolloffset;
} else {
// BELOW
placeY = o3_y + o3_offsety;
}
// Snapping!
if (o3_snapy > 1) {
var snapping = placeY % o3_snapy;
if (o3_aboveheight > 0 && o3_vpos == ABOVE) {
placeY = placeY - (o3_snapy + snapping);
} else {
placeY = placeY + (o3_snapy - snapping);
}
if (placeY < scrolloffset) placeY = scrolloffset;
}
}
// Actually move the object.
repositionTo(over, placeX, placeY);
}
// Moves the layer
function mouseMove(e) {
if ( (ns4) || (ns6) ) {o3_x=e.pageX; o3_y=e.pageY;}
if (ie4) {o3_x=event.x; o3_y=event.y;}
if (ie5) {o3_x=event.x+o3_frame.document.body.scrollLeft; o3_y=event.y+o3_frame.document.body.scrollTop;}
if (o3_allowmove == 1) {
placeLayer();
}
}
// The Close onMouseOver function for stickies
function cClick() {
hideObject(over);
o3_showingsticky = 0;
return false;
}
// Makes sure target frame has overLIB
function compatibleframe(frameid) {
if (ns4) {
if (typeof frameid.document.overDiv =='undefined') return false;
} else if (ie4) {
if (typeof frameid.document.all["overDiv"] =='undefined') return false;
} else if (ns6) {
if (frameid.document.getElementById('overDiv') == null) return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////
// LAYER FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
// Writes to a layer
function layerWrite(txt) {
txt += "\n";
if (ns4) {
var lyr = o3_frame.document.overDiv.document
lyr.write(txt)
lyr.close()
} else if (ie4) {
o3_frame.document.all["overDiv"].innerHTML = txt
} else if (ns6) {
range = o3_frame.document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(txt);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
}
}
// Make an object visible
function showObject(obj) {
if (ns4) obj.visibility = "show";
else if (ie4) obj.visibility = "visible";
else if (ns6) obj.style.visibility = "visible";
}
// Hides an object
function hideObject(obj) {
if (ns4) obj.visibility = "hide";
else if (ie4) obj.visibility = "hidden";
else if (ns6) obj.style.visibility = "hidden";
if (o3_timerid > 0) clearTimeout(o3_timerid);
if (o3_delayid > 0) clearTimeout(o3_delayid);
o3_timerid = 0;
o3_delayid = 0;
self.status = "";
}
// Move a layer
function repositionTo(obj,xL,yL) {
if ( (ns4) || (ie4) ) {
obj.left = xL;
obj.top = yL;
} else if (ns6) {
obj.style.left = xL + "px";
obj.style.top = yL+ "px";
}
}
////////////////////////////////////////////////////////////////////////////////////
// PARSER FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
// Defines which frame we should point to.
function opt_FRAME(frm) {
o3_frame = compatibleframe(frm) ? frm : ol_frame;
if ( (ns4) || (ie4 || (ns6)) ) {
if (ns4) over = o3_frame.document.overDiv;
if (ie4) over = o3_frame.overDiv.style;
if (ns6) over = o3_frame.document.getElementById("overDiv");
}
return 0;
}
// Calls an external function
function opt_FUNCTION(callme) {
o3_text = callme()
return 0;
}
//end (For internal purposes.)
////////////////////////////////////////////////////////////////////////////////////
// OVERLIB 2 COMPATABILITY FUNCTIONS
// If you aren't upgrading you can remove the below section.
////////////////////////////////////////////////////////////////////////////////////
// Converts old 0=left, 1=right and 2=center into constants.
function vpos_convert(d) {
if (d == 0) {
d = LEFT;
} else {
if (d == 1) {
d = RIGHT;
} else {
d = CENTER;
}
}
return d;
}
// Simple popup
function dts(d,text) {
o3_hpos = vpos_convert(d);
overlib(text, o3_hpos, CAPTION, "");
}
// Caption popup
function dtc(d,text, title) {
o3_hpos = vpos_convert(d);
overlib(text, CAPTION, title, o3_hpos);
}
// Sticky
function stc(d,text, title) {
o3_hpos = vpos_convert(d);
overlib(text, CAPTION, title, o3_hpos, STICKY);
}
// Simple popup right
function drs(text) {
dts(1,text);
}
// Caption popup right
function drc(text, title) {
dtc(1,text,title);
}
// Sticky caption right
function src(text,title) {
stc(1,text,title);
}
// Simple popup left
function dls(text) {
dts(0,text);
}
// Caption popup left
function dlc(text, title) {
dtc(0,text,title);
}
// Sticky caption left
function slc(text,title) {
stc(0,text,title);
}
// Simple popup center
function dcs(text) {
dts(2,text);
}
// Caption popup center
function dcc(text, title) {
dtc(2,text,title);
}
// Sticky caption center
function scc(text,title) {
stc(2,text,title);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -