Results 1 to 6 of 6

Thread: help needed for pop up menu

  1. #1
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help needed for pop up menu

    Hi guys. really need help. i'm a newbie and have been trying to create a drop down menu for my website. after a while and extra effort finding and creating drop down menu(mostly failed to generate..huhuhu ) and i manage to use pop up menu for my dropdown menu. The problem here is, i want the submenu to be fixed and to be reveal down. Could anyone here help me with my problem/or is there suggestion for newbie like me successfully to create a drop down menu?huhu...i try the tutorial, its working.but when i try to convert it and apply it to my page, it does not work..cud sumone help me pls~~pls~~~really appreciate it...here i attached the source code and also the print screen of my web
    Last edited by jetonz; 06-08-2010 at 05:47 PM.

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    please provide the css
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    opss sorry, my bad..i've uploaded the css code.just to inform that i've include the css for the pop up menu in the index.html.i've atttaches the css code

  4. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    menu CSS

    Code:
    .popitmenu{
    position: absolute;
    background-color: white;
    border:1px solid black;
    font: normal 12px Verdana;
    line-height: 18px;
    z-index: 100;
    visibility: hidden;
    }
    
    .popitmenu a{
    text-decoration: none;
    padding-left: 6px;
    color: black;
    display: block;
    }
    
    .popitmenu a:hover{ /*hover background color*/
    background-color: #CCFF9D;
    }
    sample HTML

    Code:
        <!-- This is 'product_linkover' -->
        <div id="Layer-19"  onMouseover="M.Show(this,0,0,20);" onMouseout="M.Hide();" >
          <a href="product.html"><img src="images/Layer-19.png" width="112" height="36" alt="product"  border="0" onMouseover="" onMouseout=""/></a></div>
    
    
        <!-- This is 'partners_linkover' -->
        <div id="Layer-17"   onMouseover="M.Show(this,1,0,20);" onMouseout="M.Hide();" >
          <a href="partners.html"><img src="images/Layer-17.png" width="112" height="36" alt="partners" class="pngimg" border="0" /></a></div>
    menu script
    Code:
    var menu=[]
    
    menu[0]=[];
    // field [0][0] = the class name of the menu.
    // field [0][1] = (optional) the menu width.
    // field [0][2] = (optional) the menu height.
     menu[0][0]=['popitmenu',150,60];
    // field [n][0] = the menu item text.
    // field [n][1] = the menu item href.
    // field [n][2] = (optional) the menu height.
    menu[0][1]=['The Company','The_Company.html'];
    menu[0][2]=['Management Team','The_ManaTeam.html'];
    menu[0][3]=['Facilities','Facilities.html'];
    
    menu[1]=[];
    menu[1][0]=['popitmenu'];
    menu[1][1]=['Electric Power Generation (EPG)','EPG.html'];
    menu[1][2]=['Public Sector','Public_Sect.html'];
    menu[1][3]=['Product Support','Pro_Support.html'];
    menu[1][4]=['Fabrication','Fabrication.html'];
    menu[1][5]=['Marine','Marine.html'];
    
    function MenuPop(o){
     var menus=[],ary=o.MenuArray,oop=this;
     for (var z0=0;z0<ary.length;z0++){
      menus[z0]=zxcES('DIV',{},document.body);
      menus[z0].className=ary[z0][0][0];
       zxcES(menus[z0],{left:200*z0+'px'});
      if (ary[z0][0][1]){
       zxcES(menus[z0],{width:ary[z0][0][1]+'px'});
      }
      if (ary[z0][0][2]){
       zxcES(menus[z0],{height:ary[z0][0][2]+'px'});
      }
      for (var a,z0a=1;z0a<ary[z0].length;z0a++){
       a=zxcES('A',{},menus[z0],ary[z0][z0a][0]);
       if (ary[z0][z0a][1]){
        a.href=ary[z0][z0a][1];
       }
      }
     }
     this.menus=[];
     for (var z1=0;z1<menus.length;z1++){
      this.menus[z1]=[menus[z1],menus[z1].offsetHeight];
      zxcES(menus[z1],{overflow:'hidden'});
      menus[z1].onmouseover=function(){ clearTimeout(oop.to); }
      menus[z1].onmouseout=function(){ oop.Hide(); }
     }
     this.oop=new zxcAnimate('height',menus[0],0);
     this.ms=o.EffectDuration||500;
     this.to=null;
    }
    
    MenuPop.prototype={
    
     Show:function(obj,nu,xos,yos){
      this.oop.obj.style.visibility='hidden';
      if (this.menus[nu]){
       this.oop.obj=this.menus[nu][0];
       this.oop.animate(0,this.menus[nu][1],this.ms);
       var pos=zxcPos(obj);
       this.oop.obj.style.visibility='visible';
       zxcES(this.oop.obj,{visibility:'visible',left:pos[0]+(xos||0)+'px',top:pos[1]+(yos||0)+'px'});
      }
     },
    
     Hide:function(){
      var oop=this;
      this.to=setTimeout(function(){ zxcES(oop.oop.obj,{visibility:'hidden'}); },100);
     }
    
    }
    
    function zxcES(ele,style,par,txt){
     if (typeof(ele)=='string') ele=document.createElement(ele);
     for (key in style) ele.style[key]=style[key];
     if (par) par.appendChild(ele);
     if (txt) ele.appendChild(document.createTextNode(txt));
     return ele;
    }
    
    function zxcPos(obj){
     var rtn=[0,0];
     while(obj){
      rtn[0]+=obj.offsetLeft;
      rtn[1]+=obj.offsetTop;
      obj=obj.offsetParent;
     }
     return rtn;
    }
    the animator

    Code:
    // Animate (11-January-2010)
    // by Vic Phillips http://www.vicsjavascripts.org.uk
    
    // To progressively change the Left, Top, Width, Height or Opacity of an element over a specified period of time.
    // With the ability to scale the effect time on specified minimum/maximum values
    // and with three types of progression 'sin' and 'cos' and liner.
    
    // **** Application Notes
    
    // **** The HTML Code
    //
    // when moving an element the inline or class rule style position of the element should be assigned as
    // 'position:relative;' or 'position:absolute;'
    //
    // The element would normally be assigned a unique ID name.
    //
    
    // **** Initialising the Script.
    //
    // The script is initialised by assigning an instance of the script to a variable.
    // e.g A = new zxcAnimate('left','id1')
    // where:
    //  A           = a global variable                                                               (variable)
    //  parameter 0 = the mode(see Note 1).                                                           (string)
    //  parameter 1 = the unique ID name or element object.                                           (string or element object)
    //  parameter 1 = the initial value.                                                              (digits, default = 0)
    
    // **** Executing the Effect
    //
    // The effect is executed by an event call to function 'A.animate(10,800 ,5000,[10,800]);'
    // where:
    //  A           = the global referencing the script instance.                                 (variable)
    //  parameter 0 = the start value.                                                            (digits, for opacity minimum 0, maximum 100)
    //  parameter 1 = the finish value.                                                           (digits, for opacity minimum 0, maximum 100)
    //  parameter 2 =  period of time between the start and finish of the effect in milliseconds. (digits or defaults to previous or 0(on first call) milliSeconds)
    //  parameter 3 = (optional) to scale the effect time on a specified minimum/maximum.         (array, see Note 3)
    //                 field 0 the minimum value. (digits)
    //                 field 1 the maximum value. (digits)
    //  parameter 3 = (optional) the type of progression, 'sin', 'cos' or 'liner'.                (string, default = 'liner')
    //                 'sin' progression starts fast and ends slow.
    //                 'cos' progression starts slow and ends fast.
    //
    //  Note 1:  Examples modes: 'left', 'top', 'width', 'height', 'opacity.
    //  Note 2:  The default units(excepting opacity) are 'px'.
    //           For hyphenated modes, the first character after the hyphen must be upper case, all others lower case.
    //  Note 3:  The scale is of particular use when re-calling the effect
    //           in mid progression to retain an constant rate of progression.
    //  Note 4:  The current effect value is recorded in A.data[0].
    //  Note 5:  A function may be called on completion of the effect by assigning the function
    //           to the animator intance property .Complete.
    //           e.g. [instance].Complete=function(){ alert(this.data[0]); };
    //
    
    
    
    // **** Functional Code(1.58K) - NO NEED to Change
    
    function zxcAnimate(mde,obj,srt){
     this.to=null;
     this.obj=typeof(obj)=='object'?obj:document.getElementById(obj);
     this.mde=mde.replace(/\W/g,'');
     this.data=[srt||0];
     return this;
    }
    
    zxcAnimate.prototype.animate=function(srt,fin,ms,scale,c){
     clearTimeout(this.to);
     this.time=ms||this.time||0;
     this.neg=srt<0||fin<0;
     this.data=[srt,srt,fin];
     this.mS=this.time*(!scale?1:Math.abs((fin-srt)/(scale[1]-scale[0])));
     this.c=typeof(c)=='string'?c.charAt(0).toLowerCase():this.c?this.c:'';
     this.inc=Math.PI/(2*this.mS);
     this.srttime=new Date().getTime();
     this.cng();
    }
    
    zxcAnimate.prototype.cng=function(){
     var oop=this,ms=new Date().getTime()-this.srttime;
     this.data[0]=(this.c=='s')?(this.data[2]-this.data[1])*Math.sin(this.inc*ms)+this.data[1]:(this.c=='c')?this.data[2]-(this.data[2]-this.data[1])*Math.cos(this.inc*ms):(this.data[2]-this.data[1])/this.mS*ms+this.data[1];
     this.apply();
     if (ms<this.mS) this.to=setTimeout(function(){oop.cng()},10);
     else {
      this.data[0]=this.data[2];
      this.apply();
      if (this.Complete) this.Complete(this);
     }
    }
    
    zxcAnimate.prototype.apply=function(){
     if (isFinite(this.data[0])){
      if (this.data[0]<0&&!this.neg) this.data[0]=0;
      if (this.mde!='opacity') this.obj.style[this.mde]=Math.floor(this.data[0])+'px';
      else zxcOpacity(this.obj,this.data[0]);
     }
    }
    
    function zxcOpacity(obj,opc){
     if (opc<0||opc>100) return;
     obj.style.filter='alpha(opacity='+opc+')';
     obj.style.opacity=obj.style.MozOpacity=obj.style.KhtmlOpacity=opc/100-.001;
    }
    initialise by (just before the </BODY> tag) ie one the page has loaded

    Code:
    var M=new MenuPop({
     MenuArray:menu,
     EffectDuration:500
    });
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. #5
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mucho Gracias~~~TQ~~juz a little bit confused for a beginner like me..the animator sccript,where shud i put those?for the css,and menu script i know where to put it,in the head of the code...but as for the animator code?This below code, shud be put in the body rite?

    Code:
    var M=new MenuPop({
    MenuArray:menu,
    EffectDuration:500
    });

    TQ

  6. #6
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    http://www.vicsjavascripts.org.uk/Demos/100609A.htm
    the way your main menu is constructed with overlapping images makes the sub menus difficult to trigger
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •