?? coolmenus3.js
字號:
/********************************
Copyright (c) 2001 Thomas Brattli (www.dhtmlcentral.com)
eXperience DHTML coolMenus - Get it at www.dhtmlcentral.com
Version 3.01
This script can be used freely as long as all copyright messages are
intact.
*******************************/
function lib_bwcheck(){
this.ver=navigator.appVersion; this.agent=navigator.userAgent
this.dom=document.getElementById?1:0; this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0; this.ie4=(document.all && !this.dom)?1:0;
this.ie=this.ie4||this.ie5||this.ie6; this.mac=this.agent.indexOf("Mac")>-1
this.opera5=this.agent.indexOf("Opera 5")>-1; this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom); return this
}
var bw=new lib_bwcheck()
function makePageCoords(win,fr){if(!win) win=window; this.x=0;this.x2=(bw.ns4 || bw.ns6)?win.innerWidth-1:win.document.body.offsetWidth;
if(!fr&&bw.ie) this.x2-=20; else if(!fr&&bw.ns4) this.x2-=4; else if(bw.ns6) this.x2+=1
if(bw.ns4&&!win.rows) this.x2+=5; this.y=0;this.y2=(bw.ns4 || bw.ns6)?win.innerHeight:win.document.body.offsetHeight;
if(!fr&&bw.ie) this.y2-=4; else if(bw.ns4&&fr) this.y2+=4; this.y2orig=this.y2; this.x50=this.x2/2; this.y50=this.y2/2;
this.x10=(this.x2*10)/100-5;this.y10=(this.y2*10)/100-5; this.x15=(this.x2*15)/100-5;this.y15=(this.y2*15)/100-5; return this;
}
function debug(txt,ev){if(mDebugging==2) self.status=txt; else alert(txt); if(ev) eval(ev); return false}
function cm_checkScrolled(obj){
if(bw.ns4 || bw.ns6) obj.scrolledY=obj.win.pageYOffset; else obj.scrolledY=obj.win.document.body.scrollTop
if(obj.scrolledY!=obj.lastScrolled){
if(!obj.useframes){ for(i=0;i<obj.l[0].num;i++){var sobj=obj.l[0].o[i].oBorder; sobj.moveY(sobj.y+(obj.scrolledY-obj.lastScrolled))}
if(obj.usebar) obj.oBar.moveY(obj.oBar.y+(obj.scrolledY-obj.lastScrolled))
} obj.lastScrolled=obj.scrolledY; page.y=obj.scrolledY; page.y2=page.y2orig+obj.scrolledY
if(!obj.useframes || bw.ie){ clearTimeout(obj.tim); obj.isover=0; obj.hideSubs(1,0)}
} if((bw.ns4 || bw.ns6) && !obj.useframes) setTimeout("cm_checkScrolled("+obj.name+")",200)
}
function cm_checkp(num,w,check,istop,ds){
if(num){
var p=istop?toppage:page
if(num.toString().indexOf("%")!=-1){
if(w || (check && this.rows)) num=(p.x2*parseFloat(num)/100)
else num=(p.y2*parseFloat(num)/100)
}else num=eval(num); }else num=0; return num
}
function cm_makeObj(obj,name,level,win,nest,o){
if(o&&(bw.ns4||bw.ns6)) this.evnt=o
else this.evnt=bw.dom?win.document.getElementById(obj):bw.ie4?win.document.all[obj]:bw.ns4?nest?win.document[nest].document[obj]:win.document[obj]:0;
if(!this.evnt) return debug('There seems to be an error with this layer:\nFrame: '+win+'\nLayer: '+nest + "." + obj)
this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
this.ref=bw.dom || bw.ie4?win.document:bw.ns4?this.css.document:0;
this.hideIt=cm_hideIt; this.showIt=cm_showIt; this.writeIt=cm_writeIt; this.setactive=cm_setactive;
this.moveIt=cm_moveIt; this.clipTo=cm_clipTo; if(name) this.parent=name; this.moveY=cm_moveY;
this.l=level; this.addEvents=cm_addEvents; return this
}
function cm_writeIt(text){if(!this.img1){if(bw.ns4){this.ref.write(text);
this.ref.close()}else this.evnt.innerHTML=text}}
function cm_moveY(y){this.y=y; this.css.top=y}
function cm_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}
function cm_showIt(){this.css.visibility="visible"; this.vis=1}
function cm_hideIt(){this.css.visibility="hidden"; this.vis=0}
function cm_setactive(on,name,frmmouse){
if(!name) name=this.name; var tobj=this.parent.m[name]
if(tobj.img){if(tobj.img2){if(on) this.ref.images[tobj.img].src=tobj.img2; else this.ref.images[tobj.img].src=tobj.img1}
}else{ if(on){var color=tobj.c2; var fcolor=tobj.c4; var re=tobj.c3}else{var color=tobj.c1; var fcolor=tobj.c3; var re=tobj.c4}
if(color){if(bw.dom || bw.ie4) this.css.backgroundColor=color
else if(bw.ns4) if(color=="transparent") color=null; this.css.bgColor=color}
if(fcolor && !bw.ns4){if(bw.ie4) this.evnt.style.color=fcolor; else if(this.evnt.childNodes[0]) this.evnt.style.color=fcolor
}else if(fcolor&&frmmouse){
t=this.parent.m[name].text; t=t.replace(re,fcolor); this.writeIt(t)
}if(tobj.l==0&&bw.ns6){this.parent.l[0].o[tobj.num].oBorder.hideIt(); this.parent.l[0].o[tobj.num].oBorder.showIt();}
}}
function cm_clipTo(t,r,b,l,w){if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r; this.css.clip.bottom=b;this.css.clip.left=l
}else{this.css.clip="rect("+t+","+r+","+b+","+l+")"; if(w){this.css.width=r; this.css.height=b}}
this.width=r; this.height=b}
function cm_addEvents(n,name){
this.evnt.onmouseover=new Function(name+".mover('"+n+"')"); this.evnt.onmouseout=new Function(name+".mmout('"+n+"')")
if(bw.ns4){this.ref.captureEvents(Event.MOUSEUP); this.ref.onmouseup=new Function(name+".go('"+n+"')")}
else this.evnt.onclick=new Function(name+".go('"+n+"')")
}
function cm_makeMenu(name,parent,text,link,target,width,height,img1,img2,bgcoloroff,bgcoloron,textcolor,hovercolor,onclick,onmouseover,onmouseout){
this.m[name]=new Object(); var obj=this.m[name]; obj.name=name; obj.subs=new Array(); obj.parent=parent;
obj.lnk=(link==0||link=='')?"":link; obj.target=target
if(parent!="" && parent){this.m[parent].subs[this.m[parent].subs.length]=name; l=this.m[parent].l+1} else l=0
obj.l=l; prop1=l<this.level.length?this.level[l]:this.level[this.level.length-1]; prop2=this.level[0]
if(this.l.length<=l){this.l[l]=new Object(); this.l[l].num=0; if(l==0) this.l[l].names=new Array()
this.l[l].border=prop1["border"]||prop2["border"]; this.l[l].maxnum=0
this.l[l].bordercolor=prop1["bordercolor"]||prop2["bordercolor"];
s=prop1["align"]||prop2["align"]; if(s=="left") s=1; else if(s=="right") s=0;
else if(s=="top") s=3; else if(s=="bottom") s=2; this.l[l].align=s
this.l[l].height=prop1["height"]||prop2["height"]; this.l[l].width=prop1["width"]||prop2["width"];
this.l[l].style=prop1["style"]||prop2["style"];
this.l[l].offsetX=String(prop1["offsetX"])!="undefined"?prop1["offsetX"]:prop2["offsetX"]
this.l[l].offsetY=String(prop1["offsetY"])!="undefined"?prop1["offsetY"]:prop2["offsetY"]
this.l[l].tc=textcolor||prop1.textcolor||prop2.textcolor;
}if(l==0) this.l[l].names[this.l[l].names.length]=name
if(parent!="" && parent){obj.num=this.m[parent].subs.length-1}else obj.num=this.l[l].num
this.l[l].num++; this.aobj[l]=-1; prop=l<this.level.length?this.level[l]:this.level[this.level.length-1]
obj.width=this.checkp(width?width:prop1.width?prop1.width:prop2.width,1,0,1);
obj.height=this.checkp(height?height:prop1.height?prop1.height:prop2.height,0,0,1);
if(parent!="" && parent){if(this.m[parent].subs.length>this.l[l].maxnum) this.l[l].maxnum=this.m[parent].subs.length
if(this.m[parent].totheight==0) this.m[parent].totheight=this.l[l].border
this.m[parent].totheight+=obj.height+ this.l[l].border
if(this.m[parent].maxwidth<obj.width) this.m[parent].maxwidth=obj.width+this.l[l].border*2
}else{this.l[l].maxnum=this.l[l].names.length; this.totwidth+=obj.width; this.totheight+=obj.height
this.maxwidth=this.maxwidth>obj.width?this.maxwidth:obj.width; this.maxheight=this.maxheight>obj.height?this.maxwidth:obj.height
}
if(img1) text='<img src="'+img1+'" border="0" name="imgCMenu'+name+'">'
else if(bw.ns4){text='<font size="'+(prop1.NS4fontSize||prop2.NS4fontSize)+'" face="'+(prop1.NS4font||prop2.NS4font)+'" color="'+(textcolor||this.l[l].tc)+'">'+text+'</font>'}
if(bw.ns4&&this.useNS4links) text='<a href="#" onclick="'+this.name+'.go(\''+name+'\'); return false" class="clNS4">'+text+'</a>'
if(img1){obj.preimg1=new Image(); obj.preimg1.src=img1}; if(img2){obj.preimg2=new Image(); obj.preimg2.src=img2}
if(img2) obj.img="imgCMenu"+name; else obj.img=0; obj.img1=img1||""; obj.img2=img2||""; obj.text=text;
obj.c1=bgcoloroff||prop1.bgcoloroff||prop2.bgcoloroff; obj.c2=bgcoloron||prop1.bgcoloron||prop2.bgcoloron;
obj.c3=textcolor||this.l[l].tc; obj.c4=hovercolor||prop1.hovercolor||prop2.hovercolor;
obj.mclick=onclick||""; obj.mover=onmouseover||""; obj.mout=onmouseout||""; obj.totheight=0; obj.maxwidth=0; obj.subx=-1; obj.suby=-1;}
function cm_mout(name){clearTimeout(this.tim); this.isover=0; if(this.m[name].mout!="") eval(this.m[name].mout); if(!(!bw.ie&&this.m[name].l==0&&this.useframes&&this.aobj[1]!=-1)) this.tim=setTimeout(this.name+".hideSubs(1,0,0,0,1)",this.wait)}
function cm_mover(name){
clearTimeout(this.tim);this.isover=1;
if(this.m[name].mover!="") eval(this.m[name].mover); var l=this.m[name].l; var num=this.m[name].num; var obj=this.l[l].o[num]
if(this.aobj[l]!=-1&&this.aobj[l]!=obj){if(this.aobj[l].l>=l) this.aobj[l].setactive(0,0,1)}
if(this.lastl==name&&l!=0) return;
if(l==0&&this.loaded){if(this.aobj[0].name==name){this.hideSubs(2,1); if(this.aobj[1]!=-1) this.aobj[1].setactive(0,0,1); this.aobj[1]=-1; this.lastl=-1; return}}
this.aobj[l]=obj; this.aobj[l].name=name; this.aobj[l].setactive(1,0,1); this.lastl=name;
if(!this.loaded) return; this.showSubs(name,l,num)
}
function cm_hideSubs(l,system,cl,sys2,hc){
if(this.isover && !system) return
if(l==1 && this.aobj[0]!=-1&&!sys2){this.aobj[0].setactive(0,0,1);this.aobj[0]=-1}
if(!this.loaded) return; if(cl==1) return
for(i=l;i<this.l.length;i++){
if(this.l[i].oBorder.vis==0) break;
this.l[i].oBorder.hideIt(); this.aobj[i]=-1
}if(hc&&this.hcode){ eval(this.hcode); this.hcode=""}
}
function cm_getCoords(name,l,num,topalign,align,ln,border,cn,lev1b){
if(cn==5){ this.m[name].subx=0; this.m[name].suby=0; return }//Just in case infinitive loops
if(l==1) var pobj=this.l[l-1].o[num].oBorder
else var pobj=this.l[l-1].oBorder
var x=pobj.x; var y=pobj.y;
if(l!=1){y+=this.l[l-1].o[num].y}
pborder=this.l[l-1].border;
lx=x+pobj.width; rx=x-this.m[name].maxwidth- (this.l[l-1].offsetX*2)
if(align==0){if(l==1){y+=border} if(l==1&&this.useframes) x=0; else x=lx
}else if(align==1){x=rx; if(l==1){if(this.useframes) x=page.x2 - this.m[name].maxwidth; y+=border}}
if((align==2||topalign==2)&&lev1b!=3){
if(l!=1 && (align!=1&&align!=0)){if(topalign==1) x=rx; else x=lx}
if(l==1) if(this.useframes) y=0; else y+=this.m[name].height+border+pborder;
}
if((align==3||topalign==3)&&lev1b!=2){
if(l!=1&&align!=1&&align!=0){if(topalign==1) x=rx; else x=lx}
if(this.useframes&&l==1) y=page.y2 - this.m[name].totheight - this.l[l-1].offsetY*2
else y-=this.m[name].totheight - this.l[l].offsetY*2;if(l!=1||lev1b==3) y+=this.m[name].height
}
this.m[name].scrollY=this.lastScrolled;this.m[name].subx=x+this.l[l-1].offsetX; this.m[name].suby=y+this.l[l-1].offsetY
if(this.useframes&&l==1&&align!=3) this.m[name].suby+=this.lastScrolled
if(this.pagecheck&&(l!=1||!this.useframes)) this.checkPage(name,l,num,topalign,align,ln,border,cn)
}
function cm_checkPage(name,l,num,topalign,align,ln,border,cn){
cn++;
if(this.m[name].subx+this.m[name].maxwidth>page.x2){
if(align!=1){if(align==3&&topalign!=0) topalign=3; align=1; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
}else if(this.m[name].subx<page.x){
if(align!=0){if(align==3) topalign=3; align=0; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
}else if((this.m[name].suby+this.m[name].totheight)>page.y2){
if(l==1){topalign=3; this.getCoords(name,l,num,topalign,align,ln,border,cn,3)}
else if(align!=3){ align=3; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
}else if(this.m[name].suby<page.y){
if(l==1){topalign=2; this.getCoords(name,l,num,topalign,align,ln,border,cn,2)}
else if(align!=2){align=2; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
}
}
function cm_showSubs(name,l,num){
l+=1; if(l>=this.l.length) return; ln=this.m[name].subs.length
if(ln==0){this.hideSubs(l,1,0,1); return}
else this.hideSubs(l+1,1); var border=this.l[l].border; this.aobj[l]=-1
if(this.useframes&&(bw.ns4||bw.ns6)) cm_checkScrolled(this)
if((this.m[name].subx==-1 || this.m[name].suby==-1) || this.m[name].scrollY!=this.lastScrolled || this.isresized){
var topalign=this.l[0].align; var align=this.l[l-1].align;
this.getCoords(name,l,num,topalign,align,ln,border,0)
}var x=this.m[name].subx; var y=this.m[name].suby;
var bobj=this.l[l].oBorder; bobj.hideIt();
bobj.clipTo(0,this.m[name].maxwidth,this.m[name].totheight,0,1)
bobj.moveIt(x,y); var yy=border
for(i=0;i<this.l[l].maxnum;i++){
var obj=this.l[l].o[i]
if(i<ln){var n=this.m[name].subs[i]; obj.aname=n; if(!bw.ns4||!this.NS4hover) obj.writeIt(this.m[n].text)
obj.addEvents(n,this.name); var w=this.m[n].width; var h=this.m[n].height
if(obj.y!=yy) obj.moveY(yy); yy+=h+border; if(!obj.img) obj.setactive(0,n,1);
if(obj.width!=w||obj.height!=h) obj.clipTo(0,w,h,0,1); obj.css.visibility="inherit"
}else obj.hideIt()
}bobj.showIt()
if(!bw.ns4&&this.checkselect){
for(i=0;i<this.sel.length;i++){selx=0; sely=0
if(this.sel[i].offsetParent){selx+=this.sel[i].offsetParent.offsetLeft; sely+=this.sel[i].offsetParent.offsetTop
if(this.sel[i].offsetParent.offsetParent){
selx+=this.sel[i].offsetParent.offsetParent.offsetLeft; sely+=this.sel[i].offsetParent.offsetParent.offsetTop
if(this.sel[i].offsetParent.offsetParent.offsetParent){
selx+=this.sel[i].offsetParent.offsetParent.offsetParent.offsetLeft; sely+=this.sel[i].offsetParent.offsetParent.offsetParent.offsetTop
}}}
selx+=this.sel[i].offsetLeft; sely+=this.sel[i].offsetTop
selw=this.sel[i].offsetWidth; selh=this.sel[i].offsetHeight
if(((selx+selw)>this.m[name].subx && selx<(this.m[name].subx+this.m[name].maxwidth))
&&((sely+selh)>this.m[name].suby && sely<(this.m[name].suby+this.m[name].totheight))){
if(this.sel[i].style.visibility!="hidden"){
this.sel[i].level=l
this.sel[i].style.visibility="hidden";
this.hcode+=this.name+".sel["+i+"].style.visibility='visible';"
}
}else if(l<=this.sel[i].level) this.sel[i].style.visibility="visible"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -