Advertisement
tribulant

gallery.js for information bar fade in/out

Apr 12th, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var TINY={};
  3.  
  4. function tid(i){ return document.getElementById(i); }
  5. function tag(e,p){ p=p||document; return p.getElementsByTagName(e); }
  6.  
  7. TINY.slideshow=function(n){
  8.     this.infoSpeed=this.imgSpeed=this.speed=10;
  9.     this.thumbOpacity=this.navHover=70;
  10.     this.navOpacity=25;
  11.     this.scrollSpeed=5;
  12.     this.letterbox='#000';
  13.     this.n=n;
  14.     this.c=0;
  15.     this.a=[]
  16. };
  17.  
  18. TINY.slideshow.prototype={
  19.     init:function(s,z,b,f,q){
  20.         s=tid(s);
  21.         var m= tag('li',s), i=0, w=0;
  22.         this.l=m.length;
  23.         this.q=tid(q);
  24.         this.f=tid(z);
  25.         this.r=tid(this.info);
  26.         this.o=parseInt(TINY.style.val(z,'width'));
  27.        
  28.         if(this.thumbs){
  29.             var u=tid(this.left), r=tid(this.right);
  30.             u.onmouseover=new Function('TINY.scroll.init("'+this.thumbs+'",-1,'+this.scrollSpeed+')');
  31.             u.onmouseout=r.onmouseout=new Function('TINY.scroll.cl("'+this.thumbs+'")');
  32.             r.onmouseover=new Function('TINY.scroll.init("'+this.thumbs+'",1,'+this.scrollSpeed+')');
  33.             this.p=tid(this.thumbs)
  34.         }
  35.        
  36.         for(i;i<this.l;i++){
  37.             this.a[i]={};
  38.             var h=m[i], a=this.a[i];
  39.             a.t= tag('h3',h)[0].innerHTML;
  40.             a.d= tag('p',h)[0].innerHTML;
  41.             a.l= tag('a',h)[0]? tag('a',h)[0].href:'';
  42.             a.tg = tag('a',h)[0] != '' ? tag('a',h)[0].target:'_self';
  43.             a.p= tag('span',h)[0].innerHTML;
  44.             if(this.thumbs){
  45.                 var g = tag('img',h)[0];
  46.                 this.p.appendChild(g);
  47.                 w+=parseInt(g.offsetWidth);
  48.                 if(i!=this.l-1){
  49.                     g.style.marginRight=this.spacing+'px';
  50.                     w+=this.spacing
  51.                 }
  52.                 this.p.style.width=w+'px';
  53.                 g.style.opacity=this.thumbOpacity/100;
  54.                 g.style.filter='alpha(opacity='+this.thumbOpacity+')';
  55.                 g.onmouseover=new Function('TINY.alpha.set(this,100,5)');
  56.                 g.onmouseout=new Function('TINY.alpha.set(this,'+this.thumbOpacity+',5)');
  57.                 g.onclick=new Function(this.n+'.pr('+i+',1)')
  58.             }
  59.         }
  60.         if(b&&f){
  61.             b=tid(b);
  62.             f=tid(f);
  63.             b.style.opacity=f.style.opacity=this.navOpacity/100;
  64.             b.style.filter=f.style.filter='alpha(opacity='+this.navOpacity+')';
  65.             b.onmouseover=f.onmouseover=new Function('TINY.alpha.set(this,'+this.navHover+',5)');
  66.             b.onmouseout=f.onmouseout=new Function('TINY.alpha.set(this,'+this.navOpacity+',5)');
  67.             b.onclick=new Function(this.n+'.mv(-1,1)');
  68.             f.onclick=new Function(this.n+'.mv(1,1)');
  69.         }
  70.         this.auto?this.is(0,0):this.is(0,1)
  71.     },
  72.     mv:function(d,c){
  73.         var t=this.c+d;
  74.         this.c=t=t<0?this.l-1:t>this.l-1?0:t;
  75.         this.pr(t,c)
  76.     },
  77.     pr:function(t,c){
  78.         clearTimeout(this.lt);
  79.         if(c){
  80.             clearTimeout(this.at)
  81.         }
  82.         this.c=t;
  83.         this.is(t,c)
  84.     },
  85.     is:function(s,c){
  86.         if(this.info){
  87.             //TINY.height.set(this.r,1,this.infoSpeed/2,-1)
  88.             TINY.alpha.set(this.r,0,this.infoSpeed);
  89.            
  90.         }
  91.         var i=new Image();
  92.         i.style.opacity=0;
  93.         i.style.filter='alpha(opacity=0)';
  94.         this.i=i;
  95.         i.onload=new Function(this.n+'.le('+s+','+c+')');
  96.         string = this.a[s].p;
  97.         string = string.replace(/&amp;/g, '&');
  98.         i.src = string;
  99.         if(this.thumbs){
  100.             var a= tag('img',this.p), l=a.length, x=0;
  101.             for(x;x<l;x++){
  102.                 a[x].style.borderColor=x!=s?'':this.active
  103.             }
  104.         }
  105.     },
  106.     le:function(s,c){
  107.         this.f.appendChild(this.i);
  108.         var w=this.o-parseInt(this.i.offsetWidth);
  109.         if(w>0){
  110.             var l=Math.floor(w/2);
  111.         }
  112.         TINY.alpha.set(this.i,100,this.imgSpeed);
  113.         var n=new Function(this.n+'.nf('+s+')');
  114.         this.lt=setTimeout(n,this.imgSpeed*100);
  115.         if(!c){
  116.             this.at=setTimeout(new Function(this.n+'.mv(1,0)'),this.speed*1000)
  117.         }
  118.         if(this.a[s].l != ""){         
  119.             var baseURL = this.a[s].l;
  120.             var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
  121.             var urlType = baseURL.toLowerCase().match(urlString);
  122.  
  123.             if (this.imagesthickbox == "true" && (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp')) {           
  124.                 this.q.onclick = new Function('jQuery.colorbox({href:"' + this.a[s].l + '",maxWidth:"90%",maxHeight:"90%",title:"' + this.a[s].t + '"})');
  125.             } else {
  126.                 this.q.onclick = new Function('window.open("' + this.a[s].l + '","' + this.a[s].tg + '")');
  127.             }
  128.            
  129.             this.q.onmouseover = new Function('this.className="' + this.linkclass + '"');
  130.             this.q.onmouseout = new Function('this.className=""');
  131.             this.q.style.cursor = 'pointer';
  132.         }else{
  133.             this.q.onclick=this.q.onmouseover=null;
  134.             this.q.style.cursor='default';
  135.         }
  136.         var m= tag('img',this.f);
  137.         if(m.length >= 2){
  138.             this.f.removeChild(m[0])
  139.         }
  140.     },
  141.     nf:function(s){
  142.         if(this.info){
  143.             s=this.a[s];
  144.             tag('h3',this.r)[0].innerHTML=s.t;
  145.             tag('p',this.r)[0].innerHTML=s.d;
  146.             this.r.style.height='auto';
  147.             var h=parseInt(this.r.offsetHeight);
  148.             //this.r.style.height=0;
  149.             //TINY.height.set(this.r,h,this.infoSpeed,0)
  150.             this.r.style.height = h;
  151.             TINY.alpha.set(this.r,100,this.infoSpeed);
  152.         }
  153.     }
  154. };
  155.  
  156. TINY.scroll=function(){
  157.     return{
  158.         init:function(e,d,s){
  159.             e=typeof e=='object'?e: tid(e); var p=e.style.left||TINY.style.val(e,'left'); e.style.left=p;          
  160.             var l = (d==1) ? Math.abs(parseInt(e.offsetWidth)-parseInt(e.parentNode.offsetWidth)) : 0;
  161.            
  162.             if ((e.childNodes.length+1)*e.firstChild.width > e.parentNode.offsetWidth) {
  163.                 e.si=setInterval(function(){
  164.                     TINY.scroll.mv(e,l,d,s)},20);
  165.             }
  166.         },
  167.         mv:function(e,l,d,s){
  168.             var c=parseInt(e.style.left); if(c==l){TINY.scroll.cl(e)}else{var i=Math.abs(l+c); i=i<s?i:s; var n=c-i*d; e.style.left=n+'px'}
  169.         },
  170.         cl:function(e){e=typeof e=='object'?e: tid(e); clearInterval(e.si)}
  171.     }
  172. }();
  173.  
  174. TINY.height=function(){
  175.     return{
  176.         set:function(e,h,s,d){
  177.             e=typeof e=='object'?e:tid(e); var oh=e.offsetHeight, ho=e.style.height||TINY.style.val(e,'height');
  178.             ho=oh-parseInt(ho); var hd=oh-ho>h?-1:1; clearInterval(e.si); e.si=setInterval(function(){TINY.height.tw(e,h,ho,hd,s)},20)
  179.         },
  180.         tw:function(e,h,ho,hd,s){
  181.             var oh=e.offsetHeight-ho;
  182.             if(oh == h){clearInterval(e.si)}else{if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}}
  183.         }
  184.     }
  185. }();
  186.  
  187. TINY.alpha=function(){
  188.     return{
  189.         set:function(e,a,s){
  190.             e=typeof e=='object'?e:tid(e); var o=e.style.opacity||TINY.style.val(e,'opacity'),
  191.             d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai); e.ai=setInterval(function(){TINY.alpha.tw(e,a,d,s)},20)
  192.         },
  193.         tw:function(e,a,d,s){
  194.             var o=Math.round(e.style.opacity*100);
  195.             if(o==a){clearInterval(e.ai)}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'}
  196.         }
  197.     }
  198. }();
  199.  
  200. TINY.style=function(){return{val:function(e,p){e=typeof e=='object'?e:tid(e); return e.currentStyle?e.currentStyle[p]:document.defaultView.getComputedStyle(e,null).getPropertyValue(p)}}}();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement