// Scroll2 Object // new version of the scroll object featuring horizontal scrolling and better code design // 19990613 // Copyright (C) 1999 Dan Steinman // Distributed under the terms of the GNU Library General Public License // Available at http://www.dansteinman.com/dynapi/ function Scroll(x,y,width,height,frame,name) { this.name=(name!=null)? name : "Scroll"+(Scroll.count++) this.x=x this.y=y this.w=width this.h=height this.frame=frame this.obj=this.name+"Object" eval(this.obj+"=this") Scroll.list[Scroll.list.length]=this } {var p=Scroll.prototype p.useV=true p.useH=false p.drawBorder=false p.vis=null p.z=null p.cornerImg="" p.imgSet=ScrollImgSet p.setDim=ScrollSetDim p.setDim(20,20,30) p.makeObjects=ScrollMakeObjects p.build=ScrollBuild p.activate=ScrollActivate p.moveBars=ScrollWindowMoveBars p.moveWindowH=ScrollBarMoveWindowH p.moveWindowV=ScrollBarMoveWindowV p.load=ScrollLoad p.showBlock=ScrollShowBlock} // myscroll.imgSet('..,,,',16, 16, 37, -1, 2, -1, 2, 1, 1) function ScrollImgSet(dir,barW,arrowH,boxH,bvy,bvh,bhx,bhw,dny,rtx,sdv,sdh) { var a=arguments for (var i=4;i<12;i++) if (a[i]==null) a[i]=0 this.setDim(barW,arrowH,boxH) if (this.useV) { this.dim.barV[1]+=a[4] this.dim.barV[3]+=a[5] this.dim.dn[1]+=(this.useH)?a[8]:0 } if (this.useH) { this.dim.barH[0]+=a[6] this.dim.barH[2]+=a[7] this.dim.rt[0]+=a[9] } this.makeObjects(dir) if (this.useV) { this.barV.setImages('scroll-bgv.gif','scroll-boxv.gif',a[10]?'scroll-sdv.gif':null,dir) this.upImg.setImages('scroll-up0.gif','scroll-up1.gif',dir) this.dnImg.setImages('scroll-dn0.gif','scroll-dn1.gif',dir) } if (this.useH) { this.barH.setImages('scroll-bgh.gif','scroll-boxh.gif',a[11]?'scroll-sdh.gif':null,dir) this.ltImg.setImages('scroll-lt0.gif','scroll-lt1.gif',dir) this.rtImg.setImages('scroll-rt0.gif','scroll-rt1.gif',dir) } if (this.useV && this.useH) this.cornerImg=dir+'scroll-corner.gif' this.window.border=0 } function ScrollSetDim(barW,arrowH,boxH) { this.dim=new Object() if (this.useV) { this.dim.barV=new Array(this.w,arrowH,barW,this.h-2*arrowH,barW,boxH) this.dim.up=new Array(this.w,0,barW,arrowH) this.dim.dn=new Array(this.w,this.h-arrowH,barW,arrowH) } if (this.useH) { this.dim.barH=new Array(arrowH,this.h,this.w-2*arrowH,barW,boxH,barW) this.dim.lt=new Array(0,this.h,arrowH,barW) this.dim.rt=new Array(this.w-arrowH,this.h,arrowH,barW) } } function ScrollMakeObjects(dir) { var a if (this.useV) { a=this.dim.barV; this.barV=new ScrollBar(a[0],a[1],a[2],a[3],a[4],a[5]) this.barV.onScroll=new Function(this.obj+'.moveWindowV()') a=this.dim.up; this.upImg=new ButtonImage(a[0],a[1],a[2],a[3]) a=this.dim.dn; this.dnImg=new ButtonImage(a[0],a[1],a[2],a[3]) this.upImg.onDown=new Function(this.obj+'.window.up()') this.upImg.onUp=new Function(this.obj+'.window.stop()') this.dnImg.onDown=new Function(this.obj+'.window.down()') this.dnImg.onUp=new Function(this.obj+'.window.stop()') } if (this.useH) { a=this.dim.barH; this.barH=new ScrollBar(a[0],a[1],a[2],a[3],a[4],a[5]) this.barH.onScroll=new Function(this.obj+'.moveWindowH()') a=this.dim.lt; this.ltImg=new ButtonImage(a[0],a[1],a[2],a[3]) a=this.dim.rt; this.rtImg=new ButtonImage(a[0],a[1],a[2],a[3]) this.ltImg.onDown=new Function(this.obj+'.window.left()') this.ltImg.onUp=new Function(this.obj+'.window.stop()') this.rtImg.onDown=new Function(this.obj+'.window.right()') this.rtImg.onUp=new Function(this.obj+'.window.stop()') } this.window=new ScrollWindow(0,0,this.w,this.h,this.frame) this.window.onScroll=new Function(this.obj+'.moveBars()') } function ScrollBuild() { this.window.build() this.css=css(this.name,this.x,this.y,null,null,null,this.vis,this.z)+this.window.css if (this.cornerImg!="") this.css+=css(this.name+'Corner',this.w,this.h,this.barV.w,this.barH.h) if (this.drawBorder) { this.css+=css(this.name+'CornerT',0,0,this.w,1,'black')+css(this.name+'CornerL',0,0,1,this.h,'black') if (!this.useH) this.css+=css(this.name+'CornerB',0,this.h-1,this.w,1,'black') } this.divStart='
\n' if (this.useV) { this.barV.boxvis='hidden' this.barV.build() this.upImg.build() this.dnImg.build() this.css+=this.barV.css+this.upImg.css+this.dnImg.css this.divStart+=this.barV.div+this.upImg.div+this.dnImg.div } if (this.useH) { this.barH.boxvis='hidden' this.barH.build() this.ltImg.build() this.rtImg.build() this.css+=this.barH.css+this.ltImg.css+this.rtImg.css this.divStart+=this.barH.div+this.ltImg.div+this.rtImg.div } if (this.cornerImg!="") this.divStart+='
\n' this.divStart+=this.window.divStart this.divEnd=this.window.divEnd if (this.drawBorder) this.divEnd+='
\n' this.divEnd+='\n
' this.div=this.divStart+this.divEnd } function ScrollActivate(w,h,reset) { if (!this.activated) { this.lyr=new DynLayer(this.name) if (this.useV) { this.barV.activate() this.upImg.activate() this.dnImg.activate() } if (this.useH) { this.barH.activate() this.ltImg.activate() this.rtImg.activate() } } this.window.activate(w,h) if (this.useV) { if (reset!=false) this.barV.boxlyr.moveTo(null,0) if (!this.window.enableVScroll) this.barV.boxlyr.hide() else this.barV.boxlyr.css.visibility="inherit" } if (this.useH) { if (reset!=false) this.barH.boxlyr.moveTo(0,null) if (!this.window.enableHScroll) this.barH.boxlyr.hide() else this.barH.boxlyr.css.visibility="inherit" } this.activated=true } function ScrollLoad(url) { this.window.load(url) } function ScrollShowBlock(i) { this.window.showBlock(i,this.obj+'.activate()') } function ScrollWindowMoveBars() { if (this.useV && this.window.enableVScroll) this.barV.boxlyr.moveTo(null,this.window.getYfactor()*this.barV.offsetHeight) if (this.useH && this.window.enableHScroll) this.barH.boxlyr.moveTo(this.window.getXfactor()*this.barH.offsetWidth,null) } function ScrollBarMoveWindowV() { if (this.window.enableVScroll) this.window.contentlyr.moveTo(null,-this.barV.getYfactor()*this.window.offsetHeight+this.window.marginT) } function ScrollBarMoveWindowH() { if (this.window.enableHScroll) this.window.contentlyr.moveTo(-this.barH.getXfactor()*this.window.offsetWidth+this.window.marginL,null) } function ScrollTestActive() { if (is.ie) return false for (var i=0;i0) this.css+=css(this.name+'BorderT',0,0,w,b,bc)+css(this.name+'BorderB',0,h-b,w,b,bc)+css(this.name+'BorderL',0,0,b,h,bc)+css(this.name+'BorderR',w-b,0,b,h,bc) if (this.inlineBlocks) { this.css+=css(this.name+'Content',0,0,w-2*b,null) this.css+=css(this.name+'Block0',ml,mt,w-2*b-ml-mr,null,this.bgColor) for (var i=1;i\n':'' this.divStart+='
'+ '
' if (is.ie && !this.usebuffer) this.divStart+='\n' else this.divStart+='
' this.divEnd='
' if (is.ns || this.usebuffer) this.divEnd+='
' if (this.border>0) this.divEnd+='
\n' this.divEnd+='
' this.div=this.divStart+this.divEnd } function ScrollWindowActivate(w,h) { if (!this.activated) { this.lyr=new DynLayer(this.name) this.screenlyr=new DynLayer(this.name+'Screen') this.blocklyr=new Array() this.blockActive=0 } if (this.inlineBlocks) { DynLayerInit() for (var i=0;i0) this.enableHScroll=(this.offsetWidth>0) this.onScroll() this.onLoad() this.activated=true } function ScrollWindowLoad(url) { if (url != this.url) { this.historyLoc+=1 this.historyLen=this.historyLoc this.history[this.historyLen]=url } this.reload(0) } function ScrollWindowBack() { if (this.historyLoc>0) this.reload(-1) } function ScrollWindowForward() { if (this.historyLoc' : '' var shade=shadeImg? '
\n' : '' this.css=css(name,x,y,w,h,bgColor,null,null,bg)+ css(name+'Box',0,0,boxW,boxH,boxColor,boxvis)+ css(name+'C',0,0,w,h) if (shadeImg) this.css+=css(name+'Shade',0,0) this.div='
'+shade+'
'+box+'
\n' } } function ScrollBarActivate() { this.lyr=new DynLayer(this.name) this.boxlyr=new DynLayer(this.name+'Box') this.boxlyr.slideInit() this.boxlyr.onSlide=new Function(this.obj+'.onScroll()') this.lyrc=new DynLayer(this.name+'C') this.lyrc.elm.scrollbar=this.obj if (is.ns) this.lyrc.elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP) this.lyrc.elm.onmousedown=ScrollBarMouseSDown this.lyrc.elm.onmousemove=ScrollBarMouseSMove this.lyrc.elm.onmouseup=ScrollBarMouseSUp this.lyrc.elm.onmouseover=new Function(this.obj+'.active=true') this.lyrc.elm.onmouseout=new Function(this.obj+'.active=false') } function ScrollBarMouseSDown(e) {eval(this.scrollbar+'.mousedown('+(is.ns?e.layerX:event.offsetX)+','+(is.ns?e.layerY:event.offsetY)+')');return false} function ScrollBarMouseSMove(e) {eval(this.scrollbar+'.mousemove('+(is.ns?e.layerX:event.offsetX)+','+(is.ns?e.layerY:event.offsetY)+')');return false} function ScrollBarMouseSUp(e) {eval(this.scrollbar+'.mouseup()');return false} function ScrollBarMouseDown(x,y) { this.mouseIsDown=true if (x>this.boxlyr.x && x<=this.boxlyr.x+this.boxlyr.w && y>this.boxlyr.y && y<=this.boxlyr.y+this.boxlyr.h) { this.dragX=x-this.boxlyr.x this.dragY=y-this.boxlyr.y this.dragActive=true } else if (!this.boxlyr.slideActive) { var newx=x-this.boxW/2 var newy=y-this.boxH/2 if (newx<0) newx=0 if (newx>=this.offsetWidth) newx=this.offsetWidth if (newy<0) newy=0 if (newy>=this.offsetHeight) newy=this.offsetHeight this.boxlyr.slideTo(newx,newy,this.inc,this.speed,this.obj+'.finishSlide()') } } function ScrollBarFinishSlide() { if (this.mouseIsDown) { this.dragX=this.boxW/2 this.dragY=this.boxH/2 this.dragActive=true } } function ScrollBarMouseMove(x,y) { if (!this.dragActive || this.boxlyr.slideActive) return var newx=x-this.dragX var newy=y-this.dragY if (x-this.dragX<0) newx=0 if (x-this.dragX>=this.offsetWidth) newx=this.offsetWidth if (y-this.dragY<0) newy=0 if (y-this.dragY>=this.offsetHeight) newy=this.offsetHeight this.boxlyr.moveTo(newx,newy) this.onScroll() } function ScrollBarMouseUp() { this.mouseIsDown=false this.dragActive=false this.boxlyr.slideActive=false } function ScrollBarGetXfactor() { return 1-(this.offsetWidth-this.boxlyr.x)/this.offsetWidth||0 } function ScrollBarGetYfactor() { return 1-(this.offsetHeight-this.boxlyr.y)/this.offsetHeight||0 } ScrollBar.count=0 function ButtonImage(x,y,w,h) { this.x = x this.y = y this.w = w this.h = h this.name = "ButtonImage"+(ButtonImage.count++) this.obj = this.name+"Object" eval(this.obj+"=this") } {var p = ButtonImage.prototype p.setImages = ButtonImageSetImages p.build = ButtonImageBuild p.activate = ButtonImageActivate p.down = ButtonImageDown p.up = ButtonImageUp p.change = ButtonImageChange p.onDown = new Function() p.onUp = new Function()} function ButtonImageSetImages(off,on,dir) { this.i0 = new Image() this.i = this.i0.src = (dir||'')+off this.i1 = new Image() this.i1.src = (dir||'')+on } function ButtonImageBuild() { with(this) { this.css = css(name,x,y,w,h)+css(name+'C',0,0,w,h) this.div = '
\n' } } function ButtonImageActivate() { this.lyr = new DynLayer(this.name) this.clyr = new DynLayer(this.name+'C') if (is.ns) this.clyr.elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP) this.clyr.elm.onmousedown = new Function(this.obj+".down(); return false;") this.clyr.elm.onmouseup = new Function(this.obj+".up(); return false;") } function ButtonImageDown() {this.change(this.i1);this.onDown()} function ButtonImageUp() {this.change(this.i0);this.onUp()} function ButtonImageChange(img) {this.lyr.doc.images[this.name+"Img"].src = img.src} ButtonImage.count = 0