View Full Version : Menubar Suggestion
Zikes
05-25-2005, 09:40 PM
Yeah it's nitpicking, but I noticed something earlier that I just know is going to bug the hell out of me. The popup menus don't seem to align very well with the titles. I did a little digging and found that each menu link up there is in a table cell and it's the left position of that cell that determines the left position of the resultant popup. This makes the menu alignment look odd to me, especially the Site Navigation one.
Anyways I'm not one to expect someone to trawl through thousands of lines of code just because I'm a little put off by something, so I came up with a solution (I think) :D I haven't been able to test the code, but I came up with a method for centering each menu under the link.
In the vbulletin_menu.js file on line 221-ish there's a line where the left position of the popup menu is determined like so:
var leftpx = fetch_object_posleft(elm);
I propose replacing that with this:
var A = fetch_object_posleft(elm); //Get left position of parent element
var B = elm.offsetWidth/2; //Find the center of the parent element
var C = menuobj.offsetWidth/2; //Find the center of the menu
var leftpx = A + B - C;
As far as I know that should do the trick, but there's really only one way to find out :)
viscousmemories
05-25-2005, 09:56 PM
That has annoyed me since the beginning of time, but I had no idea how to fix it. I'll give your code a whirl on the test server now and if it works you'll get a big gold star. :D
Zikes
05-25-2005, 10:04 PM
Glad I'm not the only one to notice :phew:
Hope it works! :crossed:
viscousmemories
05-25-2005, 10:08 PM
Okay, I've tested your solution and unfortunately it doesn't really help. Each link is indeed in a cell, but centered in that cell. So where the current script drops the left border of the menu aligned with the left of the cell (which ends up being about halfway between the two menu items), your method makes the left border centered. The result is the left edge of the menu dropping straight down from the 'g' in 'navigation' and the 'c' in 'search'. Which as you can imagine makes the whole menu look thrown off to the right instead of the left.
Did that make any sense? :D
Zikes
05-25-2005, 10:17 PM
Made a lot of sense, actually :D
I came to my senses and realized I could save a page to my computer and test it that way and had the same problem. I know what's causing it but I'm not altogether sure how to fix it...
The thing is that the A+B is supposed to give you the center of the cell and then subtracting C would bring it far enough to the left to center the menu, but it's calculating C that's causing the trouble. I'd seen menuobj.offsetWidth used in that function before the menu was shown, so I assumed the menu did have a defined width even though it wasn't visible yet but unfortunately that's not the case.
Since the menu's not visible when you try to retrieve the width you get 0, and 0/2 is still 0 so A+B-0 puts each menu left aligned to the center of the cell :hm:
If I can figure out how to grab the width of the menu then we'll be able to get it working :)
Zikes
05-25-2005, 10:26 PM
Got it!
Just throw this in right above the "var C" line:
menuobj.style.display="block";
viscousmemories
05-25-2005, 10:34 PM
Duuuuuude! Changed and uploaded. You rock. :1thumbup:
Zikes
05-25-2005, 10:37 PM
:woohoo: Glad I could help! :D
/me pets his shiny new gold star :goldstar:
I mean, like, is Zikes cool, or what? :shades:
viscousmemories
05-25-2005, 10:43 PM
WAY cool. And I can't believe I forgot to dole out the gold star, dammit. Here's five!
:goldstar: :goldstar: :goldstar: :goldstar: :goldstar:
livius drusus
05-25-2005, 10:44 PM
Zikes is like Fonzie cool. :bow:
Zikes
05-25-2005, 10:52 PM
:giggle: Thank you, thank you :bowing:
SharonDee
05-26-2005, 03:36 AM
I don't even understand what problem he fixed. :dunce:
Maybe it's time to hang up my IT hat.
viscousmemories
05-26-2005, 04:28 AM
The drop-down menus up top used to be grossly mis-aligned. For instance the "Site Navigation" menu used to drop down like this:
http://www.freethought-forum.com/images/screen1.GIF
and now it drops down like this:
http://www.freethought-forum.com/images/screen2.GIF
SharonDee
05-26-2005, 04:33 AM
Oh, okay. I see now. Thanks for the 'splanation, vm. :yup:
viscousmemories
05-26-2005, 04:38 AM
Sure. :)
beyelzu
05-26-2005, 04:59 AM
congratulations, zikes, I have known vm for quite a while and I have never gotten a gold star.
very cool, zikes.
viscousmemories
05-26-2005, 05:17 AM
Aww. Here ya go, bey. :goldstar:
beyelzu
05-26-2005, 10:20 AM
why thank you sir, you shouldnt have :tmgrin:
Ensign Steve
05-26-2005, 09:02 PM
The drop-down menus up top used to be grossly mis-aligned. For instance the "Site Navigation" menu used to drop down like this:
http://www.freethought-forum.com/images/screen1.GIF
and now it drops down like this:
http://www.freethought-forum.com/images/screen2.GIF
Do you have a pic of what it looked like after you tried the first suggestion, when it was all middle aligned and fucked up?
Blake
05-26-2005, 09:21 PM
Yeah, 'cause if you don't, you need to break it again and get a screen cap.
No, really!
Zikes
05-26-2005, 09:37 PM
It looks a bit odd because I saved a page to my PC and unfixed it there, but you get the gist :)
Dingfod
05-31-2005, 07:51 PM
Hey, the Show Threads selection on the Menu Bar isn't working.
And: The Quick Edit button doesn't work either.
Zikes
05-31-2005, 07:56 PM
It's working for me, what browser/OS are you using? Are you getting any specific error messages when you try to use them?
viscousmemories
05-31-2005, 07:57 PM
Hmm... they're all working for me with Firefox and MSIE.
Try forcing a refresh of your cache (Ctrl-F5) and see if that helps.
Dingfod
05-31-2005, 07:58 PM
Firefox 1.0.4. No error messages, Show Threads just is not clickable (no underline). The Edit and Quote buttons right next to the Quick Edit button work.
viscousmemories
05-31-2005, 07:58 PM
However I did just notice that the Quick Edit box is showing up quite far to the left of the button. Zikes, I'm guessing the change we made to the js for the menubar is the culprit there.
Dingfod
05-31-2005, 08:00 PM
BTW, all the other Menubar selections except Show Threads are working fine.
viscousmemories
05-31-2005, 08:01 PM
No error messages, Show Threads just is not clickable (no underline).
I'm not getting an underline either, but a menu still pops down when I click it. Not for you?
viscousmemories
05-31-2005, 08:08 PM
Incidentally I changed Show Threads so it'll appear underlined like a link now, but as far as I can tell it's only a cosmetic change. It didn't change how it works for me at all.
Shake
05-31-2005, 08:09 PM
... when did we switch to where the Gallery and Arcade open in new windows?
Zikes
05-31-2005, 08:19 PM
The absence of the underline is due to the fact that there's no actual link around the text. It appears the menu system latches onto the TD cell itself and makes that the clickable link, with cancelled A tags inside it as a fallback in case javascript is disabled. Not sure why Show Threads wouldn't have this A tag like the others do, have you made any changes to the menubar other than the centering?
However I did just notice that the Quick Edit box is showing up quite far to the left of the button. Zikes, I'm guessing the change we made to the js for the menubar is the culprit there.
I agree. I think I can whip up a different formula for that specific one if you want, but it might take a while.
viscousmemories
05-31-2005, 08:35 PM
Not sure why Show Threads wouldn't have this A tag like the others do, have you made any changes to the menubar other than the centering?
See my post above. I probably removed that link inadvertently last time I made changes to the menubar options, but I've put it back now. Thanks for telling me it's a fallback for when js is disabled, though. I had no idea what the purpose of it was. :)
I agree. I think I can whip up a different formula for that specific one if you want, but it might take a while.
I'm not terribly concerned about it, to be honest. I didn't even notice until today and I use quick edit regularly. But if a solution pops into your head at some point I'll implement it.
viscousmemories
05-31-2005, 08:36 PM
... when did we switch to where the Gallery and Arcade open in new windows?
I think it was a month or so ago. I don't remember what inspired it, though.
Shake
06-03-2005, 08:56 PM
I preferred the old way, but am not bothered by this.
viscousmemories
06-03-2005, 08:58 PM
I preferred the old way, but am not bothered by this.
You should use Firefox; it lets you override the target_ directive. :)
Ensign Steve
06-03-2005, 09:18 PM
The gallery opens in a new winidow? Where have I been?
I like when things open in a new window. I am way too easily distracted to remember where I was and where else I wanted to go in just one window.
Rambly: I used to have all of the external links and some of the internal links in my website open up in new windows until I read that it was bad web design to do so. Something about how it clutters up the user's workspace by making them have all these windows going at once, and also they have the choice to open any link in a new window, and we should let them make that choice for themselves.
Ramblier: Since then I've realized that I disagree with a lot of the advice given by the source of the above admonition, and that the advice was written years ago when the techology was different (and RAM was much less) and a lot of it doesn't really apply to modern web design. Still, while a lot of the choices are just those of aesthetics and style and are totally subjective, some of the points are really good at a fundamental level, and I still try to incorporate them into my own design.
viscousmemories
06-03-2005, 09:44 PM
Rambly: I used to have all of the external links and some of the internal links in my website open up in new windows until I read that it was bad web design to do so. Something about how it clutters up the user's workspace by making them have all these windows going at once, and also they have the choice to open any link in a new window, and we should let them make that choice for themselves.
Yeah I've heard that a lot too, and people are still saying it. After I made the post above I spent some time surfing around to see if anyone was singing a different tune these days. One thing I discovered is that the 'target' attribute is deprecated in HTML 4.01 and XHTML 1.0, so I'm probably going to change some things if they haven't already in the new version.
I used to hate links that opened in new windows until I started using Firefox. Now things that typically open in new windows open in new tabs, and I much prefer having multiple tabs to multiple windows. Honestly it seems to me that people can just as easily take actions on the client end to prevent a new window/tab opening as they can to make it happen at will, so I'm not sure I believe anymore that the default should be one or the other for web designers.
viscousmemories
06-03-2005, 10:25 PM
I found an interesting solution (http://www.serve.com/apg/workshop/replacingTarget/) to the problem, using Javascript instead of the target tag. :yup:
Ensign Steve
06-03-2005, 10:31 PM
I used to hate links that opened in new windows until I started using Firefox. Now things that typically open in new windows open in new tabs, and I much prefer having multiple tabs to multiple windows. Honestly it seems to me that people can just as easily take actions on the client end to prevent a new window/tab opening as they can to make it happen at will, so I'm not sure I believe anymore that the default should be one or the other for web designers.
I don't think it is "just as easily" done, though. Safari has tabbed browsing, but in order to get new windows to open up as a new tab by default, I had to fiddle around in "preferences" to get it to do that. Same when I was using Firefox. I've never seen a browser where you could just right click on an external link and select "open link in current window". Also depending on your flavor of pop-up blocker, users may have the added task of having to hold down shift every time they click a link. Easy enough, for computer gurus like you and me, but "just as easy" for the average user? I doubt it.
viscousmemories
06-03-2005, 10:35 PM
I've never seen a browser where you could just right click on an external link and select "open link in current window".
Ah, yeah. Good point. When I right click in Firefox I get "Open Link in New Window" and "Open Link in New Tab", but not "Open Link in Current Tab/Window". I've never really used any such functionality myself. I usually just click and then deal with whatever happens.
Dingfod
06-23-2005, 05:00 PM
I finally figured it out after uninstalling and reloading Firefox several times. I somehow Adblocked vbulletin. Unblocked it today and voila, the mojobar buttons workie.
viscousmemories
06-23-2005, 07:55 PM
Huh, that's weird. I wouldn't have thunk that would happen.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.