
Sorry. This message is rather long.

Cheers

REQUEST :
Ability to create and render a menu (on the client side) when it is needed, that is, just before it is displayed.
SUGGESTED SYNTAX:
This is just a suggestion.
In short :
Code: Select all
with(foo = new menuname("Foo")) {
style = menuStyle;
aI(...);
aI(..)
}
foo.popup();
// and then somewhere and sometime else ...
foo.popdown();
In long :
Code: Select all
<script>
var foo;
//===========================================
// This function itself is not part of the suggested syntax. Its body is.
//-----------------------------------------------------
function display_foo(r) {
with (foo=new menuname("Foo")) {
style=menuStyle; // declared somewhere else, in "[i]menu_data.js[/i]" for example.
ai("text=View;url=" + make_action_url("view", r) + ";");
ai("text=Edit;url=" + make_action_url("edit", r) + ";");
ai("text=Delete;url=" + make_action_url("delete", r) + ";");
}
foo.popup();
}
//===========================================
// This function itself is NOT part of the suggested syntax. Its body is.
//-----------------------------------------------------
function hide_foo() {
if (foo) {
foo.popdown();
}
}
//===========================================
// This function is NOT part of the suggested syntax.
// Its there to make the example work.
//-----------------------------------------------------
function make_action_url(action, resource) {
return "http://www.example.com/cgi-bin/" + action + "?url=" + encodeURIComponent(resource);
}
</script>
<body>
<a href="#" onmouseover=" display_foo( 'http://example.com/readme.txt') " onmouseout="hide_foo()">
Mouse over to see the menu appear
</a>
</body>
In fact, for this scenario, one doesn't even need a name for the menu. A variable holding a reference to it suffices. So another constructor that doesn't take a menu name and doesn't even register the menu in some internal global list would be OK too.
But then again, this part might be too much for "compatibility" considerations. I don't know.
USE-CASE :
We're working on a Web based directory browser.
The files on a server directory are displayed in an HTML table, one entry per line. It's possible to have several hundreds per page.
BTW, this stuff is completely server-side (perl) script generated anyway.
Basically, I need a context sensitive menu similar to what you've got when you explore a Folder's contents on Windows (which appears via a right-click on a file), with items such as "View", "Edit", "Delete", ...
Let's say we have 100 files in a folder, which are listed in an HTML table.
Now, I guess I do have the option of generating 100 menus on the server side, sticking them in the HTML and then calling them with popup(..).
context_menu_001
context_menu_002
...
context_menu_099
The thing is, these menus would have pretty much the same thing except their action urls.
This solution (or workaround) seems to be quite costly in network bandwidth and server-side CPU. That's why I would like to avoid it.
What I was looking for really is a way to create the menu when it is needed, that is, just before it is displayed.