[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/templates/ja_purity/js/ -> ja.moomenu.js (source)

   1  if (typeof(MooTools) != 'undefined'){
   2  
   3          var subnav = new Array();
   4  
   5          Element.extend(
   6          {
   7              hide: function(timeout)
   8              {
   9                  this.status = 'hide';
  10                  clearTimeout (this.timeout);
  11                  if (timeout)
  12                  {
  13                      this.timeout = setTimeout (this.anim.bind(this), timeout);
  14                  }else{
  15                      this.anim();
  16                  }
  17              },
  18  
  19              show: function(timeout)
  20              {
  21                  this.status = 'show';
  22                  clearTimeout (this.timeout);
  23                  if (timeout)
  24                  {
  25                      this.timeout = setTimeout (this.anim.bind(this), timeout);
  26                  }else{
  27                      this.anim();
  28                  }
  29              },
  30  
  31              setActive: function () {
  32                  //this.addClass(classname);
  33                  this.className+='sfhover';
  34                  /*
  35                  for(var i=0;i<this.childNodes.length; i++) {
  36                      if(this.childNodes[i].nodeName.toLowerCase() == 'a') {
  37                          //$(this.childNodes[i]).addClass(classname);
  38                          $(this.childNodes[i]).setActive();
  39                          return;
  40                      }
  41                  }
  42                  */
  43              },
  44  
  45              setDeactive: function () {
  46                  //this.removeClass(classname);
  47                  this.className=this.className.replace(new RegExp("sfhover\\b"), "");
  48                  /*
  49                  for(var i=0;i<this.childNodes.length; i++) {
  50                      if(this.childNodes[i].nodeName.toLowerCase() == 'a') {
  51                          $(this.childNodes[i]).setDeactive();
  52                          return;
  53                      }
  54                  }
  55                  */
  56              },
  57  
  58              anim: function() {
  59                  if ((this.status == 'hide' && this.style.left != 'auto') || (this.status == 'show' && this.style.left == 'auto' && !this.hidding)) return;
  60                  this.setStyle('overflow', 'hidden');
  61                  if (this.status == 'show') {
  62                      this.hidding = 0;
  63                      this.hideAll();
  64                      //this.parentNode.setActive();
  65                  } else {
  66                      //this.parentNode.setDeactive();
  67                  }
  68  
  69                  if (this.status == 'hide')
  70                  {
  71                      this.hidding = 1;
  72                      //this.myFx1.stop();
  73                      this.myFx2.stop();
  74                      //this.myFx1.start(1,0);
  75                      if (this.parent._id) this.myFx2.start(this.offsetWidth,0);
  76                      else this.myFx2.start(this.offsetHeight,0);
  77                  } else {
  78                      this.setStyle('left', 'auto');
  79                      //this.myFx1.stop();
  80                      this.myFx2.stop();
  81                      //this.myFx1.start(0,1);
  82                      if (this.parent._id) this.myFx2.start(0,this.mw);
  83                      else this.myFx2.start(0,this.mh);
  84                  }
  85              },
  86  
  87              init: function() {
  88                  this.mw = this.clientWidth;
  89                  this.mh = this.clientHeight;
  90                  //this.myFx1 = new Fx.Style(this, 'opacity');
  91                  //this.myFx1.set(0);
  92                  if (this.parent._id)
  93                  {
  94                      this.myFx2 = new Fx.Style(this, 'width', {duration: 300});
  95                      this.myFx2.set(0);
  96                  }else{
  97                      this.myFx2 = new Fx.Style(this, 'height', {duration: 300});
  98                      this.myFx2.set(0);
  99                  }
 100                  this.setStyle('left', '-999em');
 101                  animComp = function(){
 102                      if (this.status == 'hide')
 103                      {
 104                          this.setStyle('left', '-999em');
 105                          this.hidding = 0;
 106                      }
 107                      this.setStyle('overflow', '');
 108                  }
 109                  this.myFx2.addEvent ('onComplete', animComp.bind(this));
 110              },
 111  
 112              hideAll: function() {
 113                  for(var i=0;i<subnav.length; i++) {
 114                      if (!this.isChild(subnav[i]))
 115                      {
 116                          subnav[i].hide(0);
 117                      }
 118                  }
 119              },
 120  
 121              isChild: function(_obj) {
 122                  obj = this;
 123                  while (obj.parent)
 124                  {
 125                      if (obj._id == _obj._id)
 126                      {
 127                          //alert(_obj._id);
 128                          return true;
 129                      }
 130                      obj = obj.parent;
 131                  }
 132                  return false;
 133              }
 134  
 135  
 136          });
 137  
 138  
 139          var DropdownMenu = new Class({
 140              initialize: function(element)
 141              {
 142                  //$(element).mh = 0;
 143                  $A($(element).childNodes).each(function(el)
 144                  {
 145                      if(el.nodeName.toLowerCase() == 'li')
 146                      {
 147                          //if($(element)._id) $(element).mh += 30;
 148                          $A($(el).childNodes).each(function(el2)
 149                          {
 150                              if(el2.nodeName.toLowerCase() == 'ul')
 151                              {
 152                                  $(el2)._id = subnav.length+1;
 153                                  $(el2).parent = $(element);
 154                                  subnav.push ($(el2));
 155                                  el2.init();
 156                                  el.addEvent('mouseover', function()
 157                                  {
 158                                      el.setActive();
 159                                      el2.show(0);
 160                                      return false;
 161                                  });
 162  
 163                                  el.addEvent('mouseout', function()
 164                                  {
 165                                      el.setDeactive();
 166                                      el2.hide(20);
 167                                  });
 168                                  new DropdownMenu(el2);
 169                                  el.hasSub = 1;
 170                              }
 171                          });
 172                          if (!el.hasSub)
 173                          {
 174                              el.addEvent('mouseover', function()
 175                              {
 176                                  el.setActive();
 177                                  return false;
 178                              });
 179  
 180                              el.addEvent('mouseout', function()
 181                              {
 182                                  el.setDeactive();
 183                              });
 184                          }
 185                      }
 186                  });
 187                  return this;
 188              }
 189          });
 190  
 191          Window.onDomReady(function() {new DropdownMenu($E('#ja-mainnav ul.menu'))});
 192  
 193      }else {
 194  
 195          sfHover = function() {
 196          var sfEls = document.getElementById("ja-mainnav").getElementsByTagName("li");
 197          for (var i=0; i<sfEls.length; ++i) {
 198              sfEls[i].onmouseover=function() {
 199                  this.className+="sfhover";
 200              }
 201              sfEls[i].onmouseout=function() {
 202                  this.className=this.className.replace(new RegExp("sfhover\\b"), "");
 203              }
 204          }
 205      }
 206      if (window.attachEvent) window.attachEvent("onload", sfHover);
 207  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1