Foros del Web » Programando para Internet » Javascript »

Alguien me pude explicar este codigo

Estas en el tema de Alguien me pude explicar este codigo en el foro de Javascript en Foros del Web. Estuve viendo y la verdad que no lo comprendo creo que es de slider o algo asi lo encontre navagado pero no se como usarlo ...
  #1 (permalink)  
Antiguo 17/02/2012, 07:18
 
Fecha de Ingreso: julio-2011
Ubicación: Paraguay
Mensajes: 3
Antigüedad: 12 años, 9 meses
Puntos: 0
Alguien me pude explicar este codigo

Estuve viendo y la verdad que no lo comprendo creo que es de slider o algo asi lo encontre navagado pero no se como usarlo desde ya gracias
Código Javascript:
Ver original
  1. var TINY={};
  2.  
  3. function T$(i){return document.getElementById(i)}
  4. function T$$(e,p){return p.getElementsByTagName(e)}
  5.  
  6. TINY.slider=function(){
  7.     function slide(n,p){this.n=n; this.init(p)}
  8.     slide.prototype.init=function(p){
  9.         var s=this.x=T$(p.id), u=this.u=T$$('ul',s)[0], c=this.m=T$$('li',u), l=c.length, i=this.l=this.c=0; this.b=1;
  10.         if(p.navid&&p.activeclass){this.g=T$$('li',T$(p.navid)); this.s=p.activeclass}
  11.         this.a=p.auto||0; this.p=p.resume||0; this.r=p.rewind||0; this.e=p.elastic||false; this.v=p.vertical||0; s.style.overflow='hidden';
  12.         for(i;i<l;i++){if(c[i].parentNode==u){this.l++}}
  13.         if(this.v){;
  14.             u.style.top=0; this.h=p.height||c[0].offsetHeight; u.style.height=(this.l*this.h)+'px'
  15.         }else{
  16.             u.style.left=0; this.w=p.width||c[0].offsetWidth; u.style.width=(this.l*this.w)+'px'
  17.         }
  18.         this.nav(p.position||0);
  19.         if(p.position){this.pos(p.position||0,this.a?1:0,1)}else if(this.a){this.auto()}
  20.         if(p.left){this.sel(p.left)}
  21.         if(p.right){this.sel(p.right)}
  22.     },
  23.     slide.prototype.auto=function(){
  24.         this.x.ai=setInterval(new Function(this.n+'.move(1,1,1)'),this.a*1000)
  25.     },
  26.     slide.prototype.move=function(d,a){
  27.         var n=this.c+d;
  28.         if(this.r){n=d==1?n==this.l?0:n:n<0?this.l-1:n}
  29.         this.pos(n,a,1)
  30.     },
  31.     slide.prototype.pos=function(p,a,m){
  32.         var v=p; clearInterval(this.x.ai); clearInterval(this.x.si);
  33.         if(!this.r){
  34.             if(m){
  35.                 if(p==-1||(p!=0&&Math.abs(p)%this.l==0)){
  36.                     this.b++;
  37.                     for(var i=0;i<this.l;i++){this.u.appendChild(this.m[i].cloneNode(1))}
  38.                     this.v?this.u.style.height=(this.l*this.h*this.b)+'px':this.u.style.width=(this.l*this.w*this.b)+'px';
  39.                 }
  40.                 if(p==-1||(p<0&&Math.abs(p)%this.l==0)){
  41.                     this.v?this.u.style.top=(this.l*this.h*-1)+'px':this.u.style.left=(this.l*this.w*-1)+'px'; v=this.l-1
  42.                 }
  43.             }else if(this.c>this.l&&this.b>1){
  44.                 v=(this.l*(this.b-1))+p; p=v
  45.             }
  46.         }
  47.         var t=this.v?v*this.h*-1:v*this.w*-1, d=p<this.c?-1:1; this.c=v; var n=this.c%this.l; this.nav(n);
  48.         if(this.e){t=t-(8*d)}
  49.         this.x.si=setInterval(new Function(this.n+'.slide('+t+','+d+',1,'+a+')'),10)
  50.     },
  51.     slide.prototype.nav=function(n){
  52.         if(this.g){for(var i=0;i<this.l;i++){this.g[i].className=i==n?this.s:''}}
  53.     },
  54.     slide.prototype.slide=function(t,d,i,a){
  55.         var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left);
  56.         if(o==t){
  57.             clearInterval(this.x.si);
  58.             if(this.e&&i<3){
  59.                 this.x.si=setInterval(new Function(this.n+'.slide('+(i==1?t+(12*d):t+(4*d))+','+(i==1?(-1*d):(-1*d))+','+(i==1?2:3)+','+a+')'),10)
  60.             }else{
  61.                 if(a||(this.a&&this.p)){this.auto()}
  62.                 if(this.b>1&&this.c%this.l==0){this.clear()}
  63.             }
  64.         }else{
  65.             var v=o-Math.ceil(Math.abs(t-o)*.1)*d+'px';
  66.             this.v?this.u.style.top=v:this.u.style.left=v
  67.         }
  68.     },
  69.     slide.prototype.clear=function(){
  70.         var c=T$$('li',this.u), t=i=c.length; this.v?this.u.style.top=0:this.u.style.left=0; this.b=1; this.c=0;
  71.         for(i;i>0;i--){
  72.             var e=c[i-1];
  73.             if(t>this.l&&e.parentNode==this.u){this.u.removeChild(e); t--}
  74.         }
  75.     },
  76.     slide.prototype.sel=function(i){
  77.         var e=T$(i); e.onselectstart=e.onmousedown=function(){return false}
  78.     }
  79.     return{slide:slide}
  80. }();
  #2 (permalink)  
Antiguo 17/02/2012, 08:25
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Alguien me pude explicar este codigo

A pues claro, ese código es bien simple solo es cuestión de comparar lo que tiene este material http://www.w3schools.com/js/default.asp
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #3 (permalink)  
Antiguo 17/02/2012, 13:32
Avatar de Rafael
Modegráfico
 
Fecha de Ingreso: marzo-2003
Mensajes: 9.028
Antigüedad: 21 años, 1 mes
Puntos: 1826
Respuesta: Alguien me pude explicar este codigo

O revisa la página del autor: http://www.scriptiny.com/2011/01/javascript-slider/

Etiquetas: html, slider
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:09.