|
/******************************************************
* definitii ContextMenu
******************************************************/
var indexCM = 0;
/******************************************************
* ContextMenu
******************************************************/
/* menu item object */
function MenuItem(text, action, image)
{
this.text = text;
this.action = action;
this.image = image;
}
/* context menu object */
function ContextMenu(itemList)
{
this.id = "cm" + indexCM++;
this.Items = itemList;
this.mouseout = false;
this.Create = function() {CreateContextMenu(this);}
this.Show = function() {return ShowContextMenu(this);}
this.Hide = function() {HideContextMenu(this);}
}
/* creates context menu instance */
function CreateContextMenu(obj)
{
var me = "";
me += "<div id='contextMenu" + obj.id + "' class='contextMenu'";
// me += " style='z-index:0;'";
me += ">";
for (i=0; i<obj.Items.length; i++)
{
if (obj.Items[i].text == "hr")
{
me += "<hr>";
me += "</hr>";
}
else
{
me += "<div class='menuItem' ";
me += "onclick='" + obj.Items[i].action + "' ";
me += "onmouseover='this.className=\"menuItemOver\"'";
me += "onmouseout='this.className=\"menuItem\"'";
me += ">";
me += "<div class='itemImage' >";
if (obj.Items[i].image != "" && obj.Items[i].image != null)
{
me += "<img src='" + obj.Items[i].image + "' >";
}
me += "</div>";
me += obj.Items[i].text;
me += "</div>";
}
}
me += "</div>";
document.writeln(me);
}
/* shows CM */
function ShowContextMenu(obj)
{
obj = document.getElementById("contextMenu" + obj.id);
if (obj == null)
return (true);
if (obj.mouseout)
{
HideContextMenu(obj);
return (true);
}
obj.style.top = event.clientY;
obj.style.left = event.clientX;
obj.style.visibility = "visible";
return (false);
}
/* hides CM */
function HideContextMenu(obj)
{
obj = document.getElementById("contextMenu" + obj.id);
if (obj == null)
return;
obj.style.visibility = "hidden";
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.