PDA

View Full Version : JavaScript RightContext : A REAL right click context menu



yamagami
02-21-2007, 01:10 PM
1) CODE TITLE: RightContext

2) AUTHOR NAME/NOTES: Harel Malka

3) DESCRIPTION:

RightContext is a supercharged right click context menu. I created it to answer a few requirements I had of context menus which I could not find anywhere else; mainly provide the *correct* contextualized menu items depending on what was right clicked. So now when you click a name link for example, the context menu can provide you with links relating to the contact’s email, phone, address etc.
RightContext generates unique context menus that are built based on the DOM element clicked using special attributes embedded in the element’s Html. The attributes are custom generated and can be anything.
Menu items can include [tags] referencing those attributes, which will cause them to be transformed to contain the actual values when the menu is constructed (i.e., when an element is right clicked.)

Features include:

* Menu items that link somewhere
* Menu items that perform a custom javascript function
* Menu items that display hardcoded text
* Menu items that retrieve text via a remote ‘ajax’ call
* Menu item separators
* Image icons for menu items
* Supports multiple different menus that can be called depending on the element clicked
* All menu items can contain [tags] which are transformed at runtime to the values embedded in the clicked element
* Conditional evaluation of menu items. An item can show or not show depending on a specified condition in the menu template (new in v0.2.3)
* CSS based look and feel
* Unobtrusive standalone javascript: no additional js framework required.


4) URL TO CODE:

http://www.harelmalka.com/?p=60
Demo at:
http://www.harelmalka.com/rightcontext

djr33
02-21-2007, 07:28 PM
Very interesting. It overrides a useful function, but it seems applicable for an internet 'application' setting.

Twey
02-21-2007, 07:36 PM
That would be handy, but for the tendency of new browsers to disallow overriding of the context menu.

djr33
02-21-2007, 08:02 PM
Which "new" browsers?
Clearly, it's an invasion of defaults, but with a legitimate use, seems like it would be useful.

Twey
02-21-2007, 08:05 PM
Opera, Konqueror, Firefox, Netscape, and, I think, Safari, to name a few.

yamagami
02-21-2007, 08:48 PM
Hi,
Thanks for the comments.
It only overrides the browser right menu button for the elements you want the context menus form.
As for the browser defaults, I had Firefox 2 installed without the context menu disabled, though I hear about people who have it so as their default.
It doesn't seem possible to read that setting from javascript, but the script will degrade nicely if it's not allowed.

Harel

jscheuer1
02-22-2007, 05:55 AM
Definitely doesn't work in Opera.

yamagami
02-22-2007, 04:07 PM
Though I'll work on fixing that problem shortly.
Harel

jscheuer1
02-22-2007, 06:18 PM
Good luck with that.