Web Development with jQuery®

(Elliott) #1

(^258) ❘ CHAPTER 9 PLUGINS
If you press Disable Context Menu, you should see the default context menu instead. My default
context menu is shown in Figure 9-3.


FIGURE 9-3


The remainder of this section picks apart the JavaScript in Example 9-4 line by line and explains
how and why it works.

var options = arguments[0] !== undefined? arguments[0] : {};

var contextMenuIsEnabled = true;

var contextMenu = this;

if (typeof options == 'string')
{
switch (options)
{
case 'disable':
{
contextMenuIsEnabled = false;
break;
}
}
}
else if (typeof options == 'object')
{
// You can pass in an object containing options to
// further customize your context menu.

}

http://www.it-ebooks.info

Free download pdf