You are on page 1of 3

merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom th e Software is * furnished

to do so, subject to the following conditions: * * The above copyright notice and this permission notice sh all be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF AN Y KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DA MAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTH ERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. **/ var MenuMatic=new Class({Implements:Options,options:{id:"nav",subMenusContainerI d:"subMenusContainer",effect:"slide & fade",duration:600,physics:Fx.Transitions. Pow.easeOut,hideDelay:1000,stretchMainMenu:false,matchWidthMode:false,orientatio n:"horizontal",direction:{x:"right",y:"down"},tweakInitial:{x:0,y:0},tweakSubseq uent:{x:0,y:0},center:false,opacity:95,mmbFocusedClassName:null,mmbClassName:nul l,killDivider:null,fixHasLayoutBug:false,onHideAllSubMenusNow_begin:(function(){ }),onHideAllSubMenusNow_complete:(function(){}),onInit_begin:(function(){}),onIn it_complete:(function(){})},hideAllMenusTimeout:null,allSubMenus:[],subMenuZinde x:1,initialize:function(B){this.setOptions(B);this.options.onInit_begin();if(thi s.options.opacity>99){this.options.opacity=99.9}this.options.opacity=this.option s.opacity/100;Element.implement({getId:function(){if(!this.id){var E=this.get("t ag")+"-"+$time();while($(E)){E=this.get("tag")+"-"+$time()}this.id=E}return this .id}});this.options.direction.x=this.options.direction.x.toLowerCase();this.opti ons.direction.y=this.options.direction.y.toLowerCase();if(this.options.direction .x==="right"){this.options.direction.xInverse="left"}else{if(this.options.direct ion.x==="left"){this.options.direction.xInverse="right"}}if(this.options.directi on.y==="up"){this.options.direction.yInverse="down"}else{if(this.options.directi on.y==="down"){this.options.direction.yInverse="up"}}var A=$(this.options.id).ge tElements("a");A.each(function(F,E){F.store("parentLinks",F.getParent().getParen ts("li").getFirst("a"));F.store("parentLinks",F.retrieve("parentLinks").erase(F. retrieve("parentLinks").getFirst()));F.store("childMenu",F.getNext("ul")||F.getN ext("ol"));theSubMenuType="subsequent";if($(F.getParent("ul")||F.getParent("ol") ).id===this.options.id){theSubMenuType="initial"}F.store("subMenuType",theSubMen uType);if(theSubMenuType==="initial"&&$(F.getNext("ul")||F.getNext("ol"))){F.add Class("mainMenuParentBtn")}else{if($(F.getNext("ul")||F.getNext("ol"))){F.addCla ss("subMenuParentBtn")}}}.bind(this));var D=new Element("div",{id:this.options.s ubMenusContainerId}).inject($(document.body),"bottom");$(this.options.id).getEle ments("ul, ol").each(function(F,E){new Element("div",{"class":"smOW"}).inject(D) .grab(F)}.bind(this));D.getElements("a").set("tabindex","-1");A.each(function(G, E){if(!G.retrieve("childMenu")){return }G.store("childMenu",G.retrieve("childMen u").getParent("div"));this.allSubMenus.include(G.retrieve("childMenu"));G.store( "parentSubMenus",G.retrieve("parentLinks").retrieve("childMenu"));var F=new Menu MaticSubMenu(this.options,this,G)}.bind(this));var C=$(this.options.id).getEleme nts("a").filter(function(F,E){return !F.retrieve("childMenu")});C.each(function( F,E){F.addEvents({mouseenter:function(G){this.hideAllSubMenusNow();if(this.optio ns.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options.duration/2),transition:this.options.physics,l

ink:"cancel"})).start(this.options.mmbFocusedClassName)}}.bind(this),focus:funct ion(G){this.hideAllSubMenusNow();if(this.options.mmbClassName&&this.options.mmbF ocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options .duration/2),transition:this.options.physics,link:"cancel"})).start(this.options .mmbFocusedClassName)}}.bind(this),mouseleave:function(G){if(this.options.mmbCla ssName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph( F,{duration:(this.options.duration*5),transition:this.options.physics,link:"canc el"})).start(this.options.mmbClassName)}}.bind(this),blur:function(G){if(this.op tions.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",n ew Fx.Morph(F,{duration:(this.options.duration*5),transition:this.options.physic s,link:"cancel"})).start(this.options.mmbClassName)}}.bind(this),keydown:functio n(H){var G=new Event(H);if(H.key==="up"||H.key==="down"||H.key==="left"||H.key== ="right"){H.stop()}if(H.key==="left"&&this.options.orientation==="horizontal"||H .key==="up"&&this.options.orientation==="vertical"){if(F.getParent("li").getPrev ious("li")){F.getParent("li").getPrevious("li").getFirst("a").focus()}else{F.get Parent("li").getParent().getLast("li").getFirst("a").focus()}}else{if(H.key==="r ight"&&this.options.orientation==="horizontal"||H.key==="down"&&this.options.ori entation==="vertical"){if(F.getParent("li").getNext("li")){F.getParent("li").get Next("li").getFirst("a").focus()}else{F.getParent("li").getParent().getFirst("li ").getFirst("a").focus()}}}}.bind(this)})},this);this.stretch();this.killDivider ();this.center();this.fixHasLayoutBug();this.options.onInit_complete()},fixHasLa youtBug:function(){if(Browser.Engine.trident&&this.options.fixHasLayoutBug){$(th is.options.id).getParents().setStyle("zoom",1);$(this.options.id).setStyle("zoom ",1);$(this.options.id).getChildren().setStyle("zoom",1);$(this.options.subMenus ContainerId).setStyle("zoom",1);$(this.options.subMenusContainerId).getChildren( ).setStyle("zoom",1)}},center:function(){if(!this.options.center){return }$(this .options.id).setStyles({left:"50%","margin-left":-($(this.options.id).getSize(). x/2)})},stretch:function(){if(this.options.stretchMainMenu&&this.options.orienta tion==="horizontal"){var C=parseFloat($(this.options.id).getCoordinates().width) ;var D=0;var B=$(this.options.id).getElements("a");B.setStyles({"padding-left":0 ,"padding-right":0});B.each(function(F,E){D+=F.getSize().x}.bind(this));if(C<D){ return }var A=(C-D)/B.length;B.each(function(F,E){F.setStyle("width",F.getSize() .x+A)}.bind(this));B.getLast().setStyle("width",B.getLast().getSize().x-1)}},kil lDivider:function(){if(this.options.killDivider&&this.options.killDivider.toLowe rCase()==="first"){$($(this.options.id).getElements("li")[0]).setStyles({backgro und:"none"})}else{if(this.options.killDivider&&this.options.killDivider.toLowerC ase()==="last"){$($(this.options.id).getElements("li").getLast()).setStyles({bac kground:"none"})}}},hideAllSubMenusNow:function(){this.options.onHideAllSubMenus Now_begin();$clear(this.hideAllMenusTimeout);$$(this.allSubMenus).fireEvent("hid e");this.options.onHideAllSubMenusNow_complete()}});var MenuMaticSubMenu=new Cla ss({Implements:Options,Extends:MenuMatic,options:{onSubMenuInit_begin:(function( A){}),onSubMenuInit_complete:(function(A){}),onMatchWidth_begin:(function(A){}), onMatchWidth_complete:(function(A){}),onHideSubMenu_begin:(function(A){}),onHide SubMenu_complete:(function(A){}),onHideOtherSubMenus_begin:(function(A){}),onHid eOtherSubMenus_complete:(function(A){}),onHideAllSubMenus_begin:(function(A){}), onHideAllSubMenus_complete:(function(A){}),onPositionSubMenu_begin:(function(A){ }),onPositionSubMenu_complete:(function(A){}),onShowSubMenu_begin:(function(A){} ),onShowSubMenu_complete:(function(A){})},root:null,btn:null,hidden:true,myEffec t:null,initialize:function(B,A,C){this.setOptions(B);this.root=A;this.btn=C;this .childMenu=this.btn.retrieve("childMenu");this.subMenuType=this.btn.retrieve("su bMenuType");this.childMenu=this.btn.retrieve("childMenu");this.parentSubMenus=$$ (this.btn.retrieve("parentSubMenus"));this.parentLinks=$$(this.btn.retrieve("par entLinks"));this.parentSubMenu=$(this.parentSubMenus[0]);if(this.parentSubMenu){ this.parentSubMenu=this.parentSubMenu.retrieve("class")}this.childMenu.store("cl ass",this);this.btn.store("class",this);this.childMenu.store("status","closed"); this.options.onSubMenuInit_begin(this);this.childMenu.addEvent("hide",function() {this.hideSubMenu()}.bind(this));this.childMenu.addEvent("show",function(){this. showSubMenu()}.bind(this));if(this.options.effect){this.myEffect=new Fx.Morph($( this.childMenu).getFirst(),{duration:this.options.duration,transition:this.optio ns.physics,link:"cancel"})}if(this.options.effect==="slide"||this.options.effect

==="slide & fade"){if(this.subMenuType=="initial"&&this.options.orientation==="h orizontal"){this.childMenu.getFirst().setStyle("margin-top","0")}else{this.child Menu.getFirst().setStyle("margin-left","0")}}else{if(this.options.effect==="fade "||this.options.effect==="slide & fade"){this.childMenu.getFirst().setStyle("opa city",0)}}if(this.options.effect!="fade"&&this.options.effect!="slide & fade"){t his.childMenu.getFirst().setStyle("opacity",this.options.opacity)}var D=$(this.c hildMenu).getElements("a").filter(function(F,E){return !F.retrieve("childMenu")} );D.each(function(F,E){$(F).addClass("subMenuBtn");F.addEvents({mouseenter:funct ion(G){this.childMenu.fireEvent("show");this.cancellHideAllSubMenus();this.hideO therSubMenus()}.bind(this),focus:function(G){this.childMenu.fireEvent("show");th is.cancellHideAllSubMenus();this.hideOtherSubMenus()}.bind(this),mouseleave:func tion(G){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),blur:fu nction(G){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),keydo wn:function(H){var G=new Event(H);if(H.key==="up"||H.key==="down"||H.key==="left "||H.key==="right"||H.key==="tab"){H.stop()}if(H.key==="up"){if(F.getParent("li" ).getPrevious("li")){F.getParent("li").getPrevious("li").getFirst("a").focus()}e lse{if(this.options.direction.y==="down"){this.btn.focus()}else{if(this.options. direction.y==="up"){F.getParent("li").getParent().getLast("li").getFirst("a").fo cus()}}}}else{if(H.key==="down"){if(F.getParent("li").getNext("li")){F.getParent ("li").getNext("li").getFirst("a").focus()}else{if(this.options.direc