// ----------------------- Llamada ------------------------- // divControl(tip,obj,child) // tip = nombre del objeto a crear // obj = Div a inicializar // child = capa anidada a obj, se puede omitir, solo admite 1 anidamiento // // --------------------- Propiedades ----------------------- // x -> Posicion x // y -> Posicion y // z -> Posición en la pila de objetos(zIndex) // color -> Color de la capa // activo -> Si está en algun proceso // nameObj -> Nombre del objeto // // ----------------------- Metodos ------------------------- // show() -> Hacer visible // hide() -> Ocultar // stack() -> Posicionar en la pila de capas // paint() -> Pinta la capa de un color dado en hexadecimal // move(x,y) -> Mover hasta un punto // push(x,y) -> Empujar a un punto // fill(contenido) -> Escribir en la capa un contenido // slide(xf,yf,resolution,speed,kine,nextEv) -> Deslizar linealmente // xf = posición x final // yf = posición y final // resolution = resolución o suavidad del movimiento // speed = velocidad del movimiento // kine = tipo de movimiento. Valor de (-10..0..10) // -10:maxima aceleracion; 0:uniforme; 10:maxima deceleracion // nextEv = siguiente evento a ejecutar tras el movimiento // beizer(xf,yf,resolution,speed,xbeizer,ybeizer,nextEv) -> Deslizar mediante curva Beizer // xf = posición x final // yf = posición y final // resolution = resolución o suavidad del movimiento // speed = velocidad del movimiento // xbeizer = punto x de la curva Beizer // ybeizer = punto y de la curva Beizer // nextEv = siguiente evento a ejecutar tras el movimiento // whatToMove(xi,yi,xf,yf,resolution,speed,xbeizer,ybeizer,func,nextEv) -> Que quieres que mueva??? // xi = posición x inicial // yi = posición y inicial // xf = posición x final // yf = posición y final // resolution = resolución o suavidad del movimiento // speed = velocidad del movimiento // xbeizer = punto x de la curva Beizer // ybeizer = punto y de la curva Beizer // func = función a la que se le aplica el movimiento o introducción de datos // nextEv = siguiente evento a ejecutar tras el movimiento // --------------------------------------------------------- function divControl(tip,obj,child) { this.ie4 = (document.all) ? true : false; this.ns4 = (document.layers) ? true : false; this.ns6 = (document.getElementById) ? true : false; if(this.ie4) { if (child) { this.name = document.all[child].style; this.nostyle = document.all[child]; this.strName = 'document.all["'+child+'"]'; } else { this.name = document.all[obj].style; this.nostyle = document.all[obj]; this.strName = 'document.all["'+obj+'"]'; } } // netscape6 else if(this.ns6){ if (child) { this.name = getElementById(child).style; this.nostyle = getElementById(child); this.strName = 'document.getElementById("'+child+'")'; } else { this.name = document.getElementById(obj).style; this.nostyle = document.getElementById(obj); this.strName = 'document.getElementById("'+obj+'")'; } } else{ this.strName = 'document.layers["'+obj+'"]'; if (child) { this.name = document.layers[obj].document.layers[child]; this.strName += '.document.layers["'+child+'"]'; } else { this.name = document.layers[obj]; } } this.nameTip = tip; if(this.ie4){ this.x = this.name.pixelLeft; this.y = this.name.pixelTop; this.w = this.nostyle.offsetWidth; this.h = this.nostyle.offsetHeight; this.w2 = this.nostyle.scrollWidth; this.h2 = this.nostyle.scrollHeight; this.color = this.name.backgroundColor; } // netscape6 else if(this.ns6){ this.x = this.name.left; this.y = this.name.top; this.w = this.nostyle.offsetWidth; this.h = this.nostyle.offsetHeight; this.w2 = this.nostyle.offsetWidth; this.h2 = this.nostyle.offsetHeight; this.color = this.name.backgroundColor; } else{ this.x = this.name.left; this.y = this.name.top; this.w = this.name.clip.width; this.h = this.name.clip.height; this.w2 = this.name.width; this.h2 = this.name.height; this.color = this.name.bgColor; } this.ov= this.name.overflow; this.z = this.name.zIndex; this.activo = false; this.draging = false; this.xdrag = 0; this.ydrag = 0; this.haveFrame=false; this.show = divControlShow; this.hide = divControlHide; this.stack = divControlStack; this.paint = divControlPaint; this.fader = divControlFader; this.faderGoo = divControlFaderGoo; this.faderHex = divControlFaderHex; this.move = divControlMove; this.push = divControlPush; this.resize = divControlResize; this.clip = divControlClip; this.fill = divControlFill; this.load = divControlLoad; this.drag = divControlDrag; this.dragOn = divControlDragOn; this.dragMove = divControlDragMove; this.dragOff = divControlDragOff; this.dragOut = divControlDragOut; this.mOver = divControlMOver; this.mOut = divControlMOut; this.mMove = divControlMMove; this.mClick = divControlMClick; this.mUp = divControlMUp; this.mDown = divControlMDown; this.cut = divControlCut; this.slide = divControlSlide; this.beizer = divControlBeizer; this.whatToMove = teknoWhatToMoveGoo; this.runGoo = teknoWhatToMoveRun; } function divControlDrag() { var aux='"'+this.nameTip+'"'; eval(this.nameTip+".mDown('"+this.nameTip+".dragOn(event,"+aux+")')"); eval(this.nameTip+".mMove('"+this.nameTip+".dragMove(event,"+aux+")')"); eval(this.nameTip+".mUp('"+this.nameTip+".dragOff(event,"+aux+")')"); eval(this.nameTip+".mOut('"+this.nameTip+".dragOut(event,"+aux+")')"); } function divControlDragOn(e,obj) { if(this.ie4){ var x = event.x+document.body.scrollLeft; var y = event.y+document.body.scrollTop; } // netscape6 else if(this.ns6){ var x = event.x+window.pageXOffset; var y = event.y+window.pageYOffset; } else{ var x = e.pageX; var y = e.pageY; } eval(obj+".xdrag="+x+"-"+obj+".x"); eval(obj+".ydrag="+y+"-"+obj+".y"); eval(obj+".draging=true"); return false } function divControlDragMove(e,obj) { if(this.ie4){ var x = event.x+document.body.scrollLeft; var y = event.y+document.body.scrollTop; } // netscape6 else if(this.ns6){ var x = event.x+window.pageXOffset; var y = event.y+window.pageYOffset; } else{ var x = e.pageX; var y = e.pageY; } if (eval(obj+".draging")) { eval(obj+".move("+x+"-"+obj+".xdrag,"+y+"-"+obj+".ydrag)"); return false } else return true } function divControlDragOff(e,obj) { eval(obj+".draging=false"); return true } function divControlDragOut(e,obj) { eval(obj+".draging=false"); return true } function divControlShow() { if(this.ie4){ this.name.visibility = 'visible'; } // netscape6 else if(this.ns6){ this.name.visibility = 'visible'; } else{ this.name.visibility = 'show'; } } function divControlHide() { if(this.ie4){ this.name.visibility = 'hidden'; } // netscape6 else if(this.ns6){ this.name.visibility = 'hidden'; } else{ this.name.visibility = 'hide'; } } function divControlStack(zI) { this.name.zIndex = zI; } function divControlPaint(colH) { if(this.ie4){ this.name.backgroundColor = colH; } // netscape6 else if(this.ns6){ this.name.backgroundColor = colH; } else{ this.name.bgColor = colH; } } function divControlFader(speed,res,i1,i2,i3,f1,f2,f3) { this.datFad = new Array(); this.datFad[0] = res; this.datFad[1] = 0; this.datFad[2] = new Array(); this.datFad[2][1] = i1; this.datFad[2][2] = i2; this.datFad[2][3] = i3; this.datFad[2][4] = f1; this.datFad[2][5] = f2; this.datFad[2][6] = f3; this.datFad[3] = speed; eval(this.nameTip+"hexa = new makearray(16)"); for(var i = 0; i < 10; i++) eval(this.nameTip+"hexa["+i+"] = "+i); eval(this.nameTip+"hexa[10]='a'"); eval(this.nameTip+"hexa[11]='b'"); eval(this.nameTip+"hexa[12]='c'"); eval(this.nameTip+"hexa[13]='d'"); eval(this.nameTip+"hexa[14]='e'"); eval(this.nameTip+"hexa[15]='f'"); this.faderGoo(); } function divControlFaderHex(i) { if (i < 0) return "00"; else if (i > 255) return "ff"; else return ""+eval(this.nameTip+"hexa[Math.floor("+i+"/16)]")+eval(this.nameTip+"hexa["+i+"%16]"); } function divControlFaderGoo() { if (this.datFad[1]<=this.datFad[0]){ var aux1 = this.datFad[1]/this.datFad[0]; var aux2 = (this.datFad[0]-this.datFad[1])/this.datFad[0]; var hr = this.faderHex(Math.floor(this.datFad[2][1]*aux2+this.datFad[2][4]*aux1)); var hg = this.faderHex(Math.floor(this.datFad[2][2]*aux2+this.datFad[2][5]*aux1)); var hb = this.faderHex(Math.floor(this.datFad[2][3]*aux2+this.datFad[2][6]*aux1)); this.paint("#"+hr+hg+hb); this.datFad[1]++; setTimeout(this.nameTip+".faderGoo()",this.datFad[3]); } } function divControlResize(x,y) { if(this.ie4){ this.name.width = x; this.name.height = y; this.name.clip = "rect(0px "+x+"px "+y+"px 0px)" } //netscape6 else if(this.ns6){ eval(this.strName+'.resizeTo('+x+','+y+')'); } else{ eval(this.strName+'.resizeTo('+x+','+y+')'); } } function divControlClip(r,b,t,l) { if(this.ie4){ if (!t) t=0; if (!l) l=0; this.name.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"; } //netscape6 else if(this.ns6){ if (!t) t=0; if (!l) l=0; this.name.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"; } else{ if (t) this.name.clip.top += t; this.name.clip.right += r; this.name.clip.bottom += b; if (l) this.name.clip.left += l; } } function divControlMove(x,y) { this.x = x; this.y = y; this.name.left = this.x; this.name.top = this.y; } function divControlPush(x,y) { this.x += x; this.y += y; this.name.left = this.x; this.name.top = this.y; } function divControlFill(puppet) { if(this.ie4){ this.nostyle.innerHTML = puppet; } //netscape6 else if(this.ns6){ this.nostyle.innerHTML = puppet; } else{ this.name.document.open(); this.name.document.write(puppet); this.name.document.close(); } } function divControlLoad(puppet) { if(this.ie4){ if (!this.haveFrame){ this.fill(""); this.haveFrame=true; } parent.frames[this.tip+'Frame'].document.location = puppet; } //netscape6 else if(this.ns6){ if (!this.haveFrame){ this.fill(""); this.haveFrame=true; } parent.frames[this.tip+'Frame'].document.location = puppet; //alert(parent.frames[0].location) //alert(parent.frames[0]) //parent.frames[0].location = puppet; } else{ this.name.src = puppet; } } function divControlMOver(eve) { if(this.ie4){ eval(this.strName+".onmouseover = function(event){"+eve+"}"); } //netscape6 else if(this.ns6){ eval(this.strName+".onmouseover = function(event){"+eve+"}"); } else{ eval(this.strName+'.captureEvents(Event.MOUSEOVER)'); } } function divControlMOut(eve) { if(this.ie4){ eval(this.strName+".onmouseout = function(event){"+eve+"}"); } //netscape6 else if(this.ns6){ eval(this.strName+".onmouseout = function(event){"+eve+"}"); } else{ eval(this.strName+'.captureEvents(Event.MOUSEOUT)'); } } function divControlMMove(eve) { if(this.ie4){ eval(this.strName+".onmousemove = function(event){"+eve+"}"); } //netscape6 else if(this.ns6){ eval(this.strName+".onmousemove = function(event){"+eve+"}"); } else{ eval(this.strName+'.captureEvents(Event.MOUSEMOVE)'); } } function divControlMClick(eve) { if(this.ie4){ eval(this.strName+".onclick = function(event){"+eve+"}"); } //netscape6 else if(this.ns6){ eval(this.strName+".onclick = function(event){"+eve+"}"); } else{ eval(this.strName+'.captureEvents(Event.CLICK)'); } } function divControlMUp(eve) { if (this.ns4){ eval(this.strName+'.captureEvents(Event.MOUSEUP)'); } else if(this.ie4){ eval(this.strName+".onmouseup = function(event){"+eve+"}"); } //netscape6 else{ eval(this.strName+".onmouseup = function(event){"+eve+"}"); } } function divControlMDown(eve) { if (this.ns4){ eval(this.strName+'.captureEvents(Event.MOUSEDOWN)'); } else if(this.ie4){ eval(this.strName+".onmousedown = function(event){"+eve+"}"); } //netscape6 else{ eval(this.strName+".onmousedown = function(event){"+eve+"}"); } } function divControlCut(xi,yi,xf,yf,resolution,speed,kine,nextEv) { this.whatToMove(xi,yi,xf,yf,resolution,speed,Math.round(xi+(xf-xi)/20*(10+kine)),Math.round(yi+(yf-yi)/20*(10+kine)),'this.clip',nextEv); } function divControlSlide(xf,yf,resolution,speed,kine,nextEv) { this.whatToMove(this.x,this.y,xf,yf,resolution,speed,Math.round(this.x+(xf-this.x)/20*(10+kine)),Math.round(this.y+(yf-this.y)/20*(10+kine)),'this.move',nextEv); } function divControlBeizer(xf,yf,resolution,speed,xbeizer,ybeizer,nextEv) { this.whatToMove(this.x,this.y,xf,yf,resolution,speed,xbeizer,ybeizer,'this.move',nextEv); } function teknoWhatToMoveGoo(xi,yi,xf,yf,resolution,speed,xbeizer,ybeizer,func,nextEv) { this.datGoo = new Array(); this.datGoo[0] = resolution+1; this.datGoo[1] = speed; this.datGoo[2] = 1; this.datGoo[3] = 0; this.datGoo[4] = 1/resolution; this.datGoo[5] = func; this.datGoo[6] = nextEv; this.datGoo[7] = new Array(); this.datGoo[8] = new Array(); for (i=1;i<=this.datGoo[0];i++){ var auxS0 = 1-this.datGoo[3]; var auxS1 = auxS0 * auxS0; var auxS2 = this.datGoo[3] * this.datGoo[3]; var auxS3 = 2 * this.datGoo[3] * auxS0; this.datGoo[7][i] = Math.round((auxS1*xi)+(auxS3*xbeizer)+(auxS2*xf)); this.datGoo[8][i] = Math.round((auxS1*yi)+(auxS3*ybeizer)+(auxS2*yf)); this.datGoo[3] = i * this.datGoo[4]; } this.runGoo(); } function teknoWhatToMoveRun() { if (this.datGoo[2] <= this.datGoo[0]) { eval(this.datGoo[5]+'('+this.datGoo[7][this.datGoo[2]]+','+this.datGoo[8][this.datGoo[2]]+')'); this.datGoo[2]++; setTimeout(this.nameTip+".runGoo()",this.datGoo[1]); } else { if (this.datGoo[6]) eval(this.datGoo[6]); } }