Web Development with jQuery®

(Elliott) #1

Writing a Plugin (^) ❘ 253
background: -ms-linear-gradient(top, rgb(82, 117, 243) 0%, rgb(3, 57,
242) 100%);
/ W3C /
background: linear-gradient(to bottom, rgb(82, 117, 243) 0%, rgb(3, 57,
242) 100%);
color: white;
}
li.contextMenuDisabled {
opacity: 0.5;
}
p.applicationContextMenuToggles {
color: green;
}
p.applicationContextMenuToggles span:hover {
text-decoration: underline;
cursor: pointer;
}
Finally, the following JavaScript ties everything together and breathes life into this once static,
inanimate HTML document.
$.fn.extend({
contextMenu : function()
{
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.
}
function getViewportDimensions()
{
var x, y;
if (self.innerHeight)
http://www.it-ebooks.info

Free download pdf