How to create a DHTML menu? - menu

I need to create a DHTML menu with the specified features, but I can't figure out how to do it. Here's what I need:
All items are layed out horizontally. If they would be wider than the screen, two little arrows appear on the right side of the menu that allow to scroll it. Something like this:
+--------+--------+-------+---+---+
| Item 1 | Item 2 | Item 3| < | > |
+--------+--------+-------+---+---+
Menu items should be clickable anywhere in the cell. They should stretch both vertically and horizontally to the contents. The text in the items should be centered both vertically and horizontally. The menu should work in IE7/Opera/FF/Safari.
The scrolling is the easy part - I just place it all in a container (say, a <div>), set the container to overflow: hidden and then play around in Javascript with clientWidth, scrollWidth and scrollLeft. That I've figured out and have already tried.
But how to make the menu items so stretchy, clickable anywhere and centered text?

Try the CSS below:
#menu {
display: table;
}
#menu a {
display:table-cell;
vertical-align:middle;
}
And then format your menu like:
<div id="menu">
normal text
<big>large text</big>
<span style="line-height:100px;">very tall text</span>
</div>
This will force vertical alignment and prevent the links from wrapping. Let us know how it works out.

OK, I talked with my superiors and they decided that it might be OK that you cannot right-click a menu item and select "Open in New Window". If this requirement is dropped, then I'm not bound to <a> elements for links. With JavaScript I can turn anything into a link. Thus, I choose you, pikachoo <table>!
Yap, it's a heresy, but it works. More specifically, it's the only construct that I can think of that can do all of the following at the same time:
Center text horizontally and vertically;
Stretch to contents horizontally and vertically;
Not wrap to next line when items are starting to overflow.
Anything else that can do the same will probably be more convulted anyway. And before anyone has the idea - no, I don't need search engine support. It's an internal web application. It'd be pretty bad if Google could index that...

clickable anywhere is easy: you can either bind the onclick event trigger (and hopefully some cursor styling) to the atomic cell element, or you can make the atomic cell elements <a> tags (or more likely wrap these in <li>) and link and style appropriately (padding, margin, foo).
e.g. case 1:
<ul id="menu"><li class="item" onclick="foo()" style="cursor:pointer; cursor:hand; padding:1em; margin:1px; float: left;">FOO!</li></ul>
(obviously I don't really recommend inline styling or script handlers but you get the idea)
Applying padding will effectively centre the text, and having no width assigned they'll naturally stretch to fit their content.

Related

Context menu for Tabulator

I try to use column header menus and row context menus in my tabulator but nothing appear. Then I realize in the DOM that the menu is there but out of the window and at the top of the tree in the dom, it's the div with the class tabulator-menu.
The DOM, the div with smd take the whole page
I use Vuejs with Bootstrap 4.
How to make it appear at the right place ?
Thanks
The menu is appearing in exactly the correctly place in the DOM.
It is standard practice in a lot of context menu libraries to append the menu directly to the body rather than to the element that triggered it, this happens because menus are often long and overflow their containing element, by absolutely positioning the elements in the DOM the sit on top of these and prevent this being an issue.
It is hard to say without seeing an example, but it is likely a z-index issue that is causing the problem.
By default Tabulator menus have a z-index of 10,000 if you have anything with a z-index higher than this it will sit over the menu.
To resolve this you simply need to add a bit of CSS after you have imported the tablator style sheet, that changes the z-index to be higher than any others on your page:
.tabulator-menu{
z-index: 99999999;
}

xe:navigator, expandable: how to replace the "twisties" with some custom icon?

For navigation I'm using an xe:navigator and containing xe:basicContainerNodes, which in turn contain xe:pageTreeNodes. Rather classic design, I'd say.
If I mark the xe:navigator as "expandable" all the containerNodes are showing something that at first glance appear to be classic "twisties" so that users can collapse / expand them.
This is kind of OK but I'd love to replace the "twisties" with icons showing "+" or "-" as that is what I'm using everywhere else inside the application.
Looking at the rendered html code for my navigator I see that the "twisties" in fact are links with a background sprite applied through css:
<a class="lotusSprite lotusArrow lotusTwistyOpenMenu" style="padding: 0px" role="button" href="#" onclick="javascript:XSP.oneUIMenuSwap(event,'wipe','view:_id1:_id2:facetLeft:_id278:outline_node_0')" title="Click to expand or collapse this section">
<span class="lotusAltText">▼</span>
</a>
(btw: the <span> inside the link appears to be a fake element as it is set to display:none)
Examining the sprite I in fact find some "+" icons but no "-" ones.
Question: is there probably away to reach my goal, other than building my own sprite and replacing the original one?
Update: another helpful option would be to make the container's label clickable so thar user could expand / collapse the containers by clicking their headline labels. Any idea here?
Update #2: apparently not too many responses ;). Meanwhile I solved it by switching to an Accordion based navigator; a bit more programming effort, but nicer looking, too...
solved it by switching to accordions. Looks even nicer but is a bit more programming effort (keeping the right accordion panels open and marking the currently selected menu entries)

Moving ChromeVox focus from menu div to content div

I am working with the ChromeVox extension to add a text reader for our church web site www.uulynchburg.org. When using the mouse to navigate, it is easy to click on a text block to start the reader. The problem comes for someone unable to use the mouse and relying on navigation keys. I can walk down the menu, but once a menu item is selected, I want the focus to jump from the memu to the start of the text in the content .
If you want to focus ChromeVox on a particular page element, you need to focus on that element.
Create a wrapper element which is focusable.
To make inherently un-focusable elements (non-form elements, buttons, links, etc) focusable, add tab-index="-1".)
<div id="main-content" tab-index="-1">
<h1>heading</h1>
</div>
Use javascript to focus on the element after navigating, on page load, or whatever event makes most sense.
document.getElementById('main-content').focus()
This is an example but you can select any specific element.
This technique is especially useful if you are building a single-page-app.

CarouFredSel: scroll not working properly with html content

So, when I have some items with html content in it, and the fx = scroll, direction = left, the first item scrolls left, the container remains empty, then quickly the second item appears.
If I use images only, one image is one scrollable item, the items follow each other smoothly, so when the first item moves left, right after the second item also comes in from the right side.
Any idea what should I set, to make the plugin work properly?
My guess is its something with the width settings of an item, but I tried several settings, no one was good.
Thank you
Maybe your item is to big for the container? or someting with position absolute/relative? Coudl you show me some of your code (and images/div sizes?)
I found the solution (in stackoverflow). I have to use float:left on the div elements I want to scroll. Now they follow nicely each other.
#subdesign,
As nicely quoted by #RunningFusion may your item be too big for the container.
Try width: "100%" instead of specifying the width in px.

Place <div> 'under' drop shadow

I have a black navigation bar (bar) and a vertical white page (page).
The page is supposed to run from to to bottom and look like it just comes out from right under the bar. The bar has a drop shadow which should obviously be 'on' the page - like this:
The problem with this is that the page needs a z-index of -1 to look like this (both have a fixed or relative positioning) - and this means (at least in Chrome) that I can't select or click anything on the page.
When I assign a z-index of 2 (bar being 10) it obviously doesn't work anymore:
Yet at least I can click the page's elements.
How can I achive the correct look while still being able to click/select elements?
you could set box-shadow: inset (...) to page.
http://jsfiddle.net/seler/fP2Gx/
or: http://jsfiddle.net/seler/fP2Gx/12/

Resources