JavaScript.CoolDev.Com Support Forums

Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Autosize for sub-menus

 
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu
Author Message
jarod



Joined: 09 Aug 2005
Posts: 2
Location: Bucharest

PostPosted: Tue Aug 09, 2005 10:42 am    Post subject: Autosize for sub-menus Reply with quote

Hi there,

I need to make the sub-menus to self adjust their width (some sort of autosize or 100%). The width of all the sub-menus of a menu should be as big as the width of the longest sub-menu.

I'm using v2.4.8 pro.


Thanks.

Jarod
Back to top
Victor_Chuiko
Support Team


Joined: 12 Apr 2005
Posts: 145

PostPosted: Tue Aug 16, 2005 3:12 pm    Post subject: Reply with quote

Yes, it is possible. Please send your request to javascript@cooldev.com with your menu sample attached. And we will configure it the way you need.
Back to top
sshafi



Joined: 16 Dec 2005
Posts: 3

PostPosted: Fri Dec 16, 2005 2:08 am    Post subject: Reply with quote

hey..


any chance you could share the resolution on this issue? i've got a situation where i've got 2 menu levels, one horizontal and then another vertical drop-down.. i'd like to have the horitzontal ones spaces according to the width of the label (i.e., width:auto) and then have all of the items in the drop-down menu have a width equal to the width of the largest menu item, based on its label..

i realize i can do this by setting the size/offset explicitly for each menu item, but the site allows the labels of the menus to be customized by the user, so they really need to be auto-sized..

thanks in advance..


Saleem.
Back to top
jarod



Joined: 09 Aug 2005
Posts: 2
Location: Bucharest

PostPosted: Tue Dec 20, 2005 1:36 pm    Post subject: Reply with quote

Here is the solution, but I'm using cool menu 2.4.8

Code:

var MENU_ITEMS_TOP = [
   { pos:[100,15], leveloff:[20,0], style:STYLE_TOP, autosize:true },
   { code:"TOP MENU dsajdkasd kjasgdsagdgasds a", format:{itemoff:[0,0], size:[20,'+maxMain+5px'] }
]


Pay attention to autosize:true and maxMain.

I hope it helps.
Back to top
sshafi



Joined: 16 Dec 2005
Posts: 3

PostPosted: Sat Dec 31, 2005 1:27 am    Post subject: Reply with quote

Thanks, this gets me about half the way there.. It works great if i only need one horizontal menu item, but if i've got a bunch, it doesn't quite do it.. The problem seems to be related to the fact that when i 'autosize' something, the <div> that contains the menuitem doesn't know how big it is and ends up only being about 5px wide and all my menus run on top of each other..

i modified the "Relative Positioning - Tight Table" example with these changes:

Code:

var MENU_ITEMS = [
   {pos:'relative', leveloff:[21,0], style:STYLE, itemoff:[0,100], autosize:true},
   {code:"Item 1", format:{size:[22,'+maxMain+5px']},
      sub:[
         {itemoff:[21,0]},
         {code:"SubItem 1"},
         {code:"SubItem 2"},
         {code:"SubItem 3"}
      ]
   }
];

var MENU_ITEMS2 = [
   {pos:'relative', itemoff:[0,99], leveloff:[21,0], style:STYLE, size:[22,100]},
   {code:"Item 2",
      sub:[
         {itemoff:[21,0]},
         {code:"SubItem 1"},
         {code:"SubItem 2"},
         {code:"SubItem 3 and more"},
         {code:"SubItem 4"},
         {code:"SubItem 5"},
         {code:"SubItem 6"}
      ]
   }
];


and

Code:

         <tr>
            <td bgcolor="#F0FFF0">&nbsp;</td>
            <td bgcolor="#F0F0FF">
               <script type="text/javascript">
               var m1 = new COOLjsMenuPRO("menu1", MENU_ITEMS)
               m1.initTop();
               </script>
            </td>
            <td bgcolor="#F0F0FF">
               <script type="text/javascript">
               var m2 = new COOLjsMenuPRO("menu2", MENU_ITEMS2)
               m2.initTop();
               </script>
            </td>
            <td bgcolor="#F0FFF0">&nbsp;</td>
         </tr>



the problem should be pretty obvious.. i tried it with just a single menu and without the table, but that didn't work either..

this seems like it shouldn't be that difficult to pull off.. maybe there's another undocumented switch, i could try?

Saleem.
Back to top
sshafi



Joined: 16 Dec 2005
Posts: 3

PostPosted: Sat Dec 31, 2005 2:40 am    Post subject: Reply with quote

Ok, quick update on this one, in case anyone's watching this thread.. i was able to get my modified sample working by making a slight modification to version 2.4.8 of the cooljsmenupro_uncompressed.js script, namely:

Code:
if (!_bw._ns4 && !_bw._operaOld && this._isPersistent && this._menu._isRelative && !this._menu._withPlaceholder)


becomes

Code:
if (!_bw._ns4 && !_bw._operaOld && this._isPersistent && this._menu._isRelative)


i don't really understand what _withPlaceholder is or does, but it was keeping the rootDiv from getting its size updated.. is there a less invasive way to turn _withPlaceholder off?


Saleem.
Back to top
ganglegreen



Joined: 16 Feb 2006
Posts: 1

PostPosted: Thu Feb 16, 2006 10:50 am    Post subject: Can I get parent's maxMain for Horiz offset? Reply with quote

On Horiz-Vertical menu, autosize causes an issue where the horizontal offset using maxMain is the width of the sub item and not the parent. This causes erratic offset. To make this work I'd either need to ref parent's maxMain (ie. '+parent.maxMain') or offset from the right edge of the parent or skip it on the parent altogether and just autosize the sub.

Please advise if you have any solution to this (or not)

Thanks.
Back to top
AlexKunin
Developer


Joined: 03 Jan 2003
Posts: 1191

PostPosted: Sat Apr 29, 2006 1:23 am    Post subject: Reply with quote

What about just '+parent'? That is how it was designed to work.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu All times are GMT
Page 1 of 1