Web Development with jQuery®

(Elliott) #1

Writing a Plugin (^) ❘ 257
$('span#applicationContextMenuDisable').click(
function(event)
{
$('div#applicationContextMenu').contextMenu('disable');
$('div#applicationContextMenu').hide();
}
);
$('span#applicationContextMenuEnable').click(
function()
{
$('div#applicationContextMenu').contextMenu();
}
);
$('div#applicationContextMenu').contextMenu();
}
);
With all three documents in place, you get a fi ne example of jQuery-enabled interactivity when
you load this document into a browser that supports and has enabled the contextmenu event. (By
default, all do except legacy Presto engine-based Opera, although it’s possible to disable this event
in Firefox’s advanced preferences.) The contextMenu event, as you might have guessed, replaces the
menu that comes up by default wherever you might right-click in this web page with a mouse’s right
button or a context menu gesture. On Macs, the context menu gesture brings up the context menu
when you tap with two fi ngers on an Apple Wireless Trackpad or MacBook Trackpad (assuming
you’ve enabled the gesture in System Preferences ➪ Trackpad). The result will look something like
what you see in Figure 9-2.


FIGURE 9-2


http://www.it-ebooks.info

Free download pdf