Sha256: 3165b3d5fa4196c49d320b2ed4ffc1eb792d003d1004f643ec0a90c0f2bc8d79

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

Skyline.Menu = new Class({
  initialize : function(el){
    this.listEl = $(el);
    this.storeKey = "skyline.menu:current";
    this.menus = this.listEl.getElements("ul");
    var t = this;

    this.listEl.getChildren("li").each(function(li){
      li.getFirst().addEvent("click",function(event){
        t.openLi(event,li,t.listEl);
      });
    });  
    
    this.menus.each(function(ul){
      ul.getChildren("li").each(function(li){
        li.addEvent("mouseenter", t.openLi.bindWithEvent(t,[li,ul]));
      });
    });
    
    document.addEvent("click",function(event){
      var menus = t.menus.combine([t.listEl]);
      menus.each(function(ul){
        var act = ul.retrieve(t.storeKey);
        if(act){
          act.removeClass("open");
        }
        ul.eliminate(t.storeKey);
      });
    }.bind(this))
    
  },
  openLi : function(event,el,parent){
    if(event){event.stopPropagation();}
    var childList, childAct, act = parent.retrieve(this.storeKey);
    
    if(childList = el.getElement("ul")){
      if(childAct = childList.retrieve(this.storeKey)){
        childAct.removeClass("open");
        childList.eliminate(this.storeKey);
      }
    }    

    if(act == el){
      return;
    }
    
    if(act){
      act.removeClass("open");
    }

    parent.store(this.storeKey,el);    
    el.addClass("open");
  }  
});

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
westarete-skylinecms-3.0.8.20100329 public/skyline/javascripts/src/skyline/src/menu.js
westarete-skylinecms-3.0.8.20100330 public/skyline/javascripts/src/skyline/src/menu.js
skylinecms-3.0.8 public/skyline/javascripts/src/skyline/src/menu.js
skylinecms-3.0.7 public/skyline/javascripts/src/skyline/src/menu.js