Advertisement
nrdgrl

dropdown

Apr 27th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. var menu=function(){
  2. var t=15,z=50,s=6,a;
  3. function dd(n){this.n=n; this.h=[]; this.c=[]}
  4. dd.prototype.init=function(p,c){
  5. a=c; //Old code: var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
  6.  
  7. var w=p, s=w.getElementsByTagName('ul'), l=s.length, i=0;
  8. for(i;i<l;i++){
  9. var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
  10. h.onmouseover=new Function(this.n+'.st('+i+',true)');
  11. h.onmouseout=new Function(this.n+'.st('+i+')');
  12. }
  13. }
  14. dd.prototype.st=function(x,f){
  15. var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
  16. clearInterval(c.t); c.style.overflow='hidden';
  17. if(f){
  18. p.className+=' '+a;
  19. if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
  20. if(c.mh==c.offsetHeight){c.style.overflow='visible'}
  21. else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
  22. }else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
  23. }
  24. function sl(c,f){
  25. var h=c.offsetHeight;
  26. if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
  27. if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
  28. clearInterval(c.t); return
  29. }
  30. var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
  31. c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
  32. c.style.height=h+(d*f)+'px'
  33. }
  34. return{dd:dd}
  35. }();
  36.  
  37. document.getElementsByClassName = function (c, t) {
  38. t = this.getElementsByTagName(t ? t : "*");
  39. for (var i = 0, r = new Array(), l = t.length; i < l; i++)
  40. if (t[i].className == c)
  41. r[r.length] = t[i];
  42. return r;
  43. }
  44.  
  45. var _Menus = new Array();
  46. function initializeDateDropDowns(){
  47. var box = document.getElementsByClassName('menu','ul');
  48. if (box.length > 0) {
  49. for(i = 0; i < box.length; i++) {
  50. var id = box[i];
  51. _Menus[i] = new menu.dd('_Menus[' + i + ']');
  52. _Menus[i].init(id,"menuhover");
  53. }
  54. }
  55. }
  56. window.onload = initializeDateDropDowns;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement