Menu.js
Summary
No overview generated for 'Menu.js'
draw2d.Menu=function()
{
this.menuItems = new draw2d.ArrayList();
draw2d.Figure.call(this);
this.setSelectable(false);
this.setDeleteable(false);
this.setCanDrag(false);
this.setResizeable(false);
this.setSelectable(false);
this.setZOrder(10000);
this.dirty=false;
}
draw2d.Menu.prototype = new draw2d.Figure;
draw2d.Menu.prototype.type="Menu";
draw2d.Menu.prototype.createHTMLElement=function()
{
var item = document.createElement("div");
item.style.position="absolute";
item.style.left = this.x+"px";
item.style.top = this.y+"px";
item.style.margin = "0px";
item.style.padding= "0px";
item.style.zIndex = ""+draw2d.Figure.ZOrderBaseIndex;
item.style.border= "1px solid gray";
item.style.background = "lavender";
item.style.cursor="pointer";
return item;
}
draw2d.Menu.prototype.setWorkflow= function( workflow)
{
this.workflow = workflow;
}
draw2d.Menu.prototype.appendMenuItem=function( item)
{
this.menuItems.add(item);
item.parentMenu = this;
this.dirty=true;
}
draw2d.Menu.prototype.getHTMLElement=function()
{
var html = draw2d.Figure.prototype.getHTMLElement.call(this);
if(this.dirty)
this.createList();
return html;
}
draw2d.Menu.prototype.createList=function()
{
this.dirty=false;
this.html.innerHTML="";
var oThis = this;
for(var i=0;i<this.menuItems.getSize();i++)
{
var item = this.menuItems.get(i);
var li = document.createElement("a");
li.innerHTML = item.getLabel();
li.style.display="block";
li.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
li.style.fontSize="9pt";
li.style.color="dimgray";
li.style.borderBottom="1px solid silver";
li.style.paddingLeft="5px";
li.style.paddingRight="5px";
li.style.cursor="pointer";
this.html.appendChild(li);
li.menuItem = item;
if (li.addEventListener)
{
li.addEventListener("click", function(event)
{
var oEvent = arguments[0] || window.event;
oEvent.cancelBubble = true;
oEvent.returnValue = false;
var diffX = oEvent.clientX;
var diffY = oEvent.clientY;
var scrollLeft= document.body.parentNode.scrollLeft;
var scrollTop = document.body.parentNode.scrollTop;
this.menuItem.execute(diffX+scrollLeft, diffY+scrollTop);
}, false);
li.addEventListener("mouseup", function(event){event.cancelBubble = true; event.returnValue = false;}, false);
li.addEventListener("mousedown", function(event){event.cancelBubble = true; event.returnValue = false;}, false);
li.addEventListener("mouseover", function(event){this.style.backgroundColor="silver";},false);
li.addEventListener("mouseout", function(event){this.style.backgroundColor="transparent";},false);
}
else if (li.attachEvent)
{
li.attachEvent("onclick", function(event)
{
var oEvent = arguments[0] || window.event;
oEvent.cancelBubble = true;
oEvent.returnValue = false;
var diffX = oEvent.clientX;
var diffY = oEvent.clientY;
var scrollLeft= document.body.parentNode.scrollLeft;
var scrollTop = document.body.parentNode.scrollTop;
event.srcElement.menuItem.execute(diffX+scrollLeft, diffY+scrollTop);
});
li.attachEvent("onmousedown", function(event){event.cancelBubble = true; event.returnValue = false;});
li.attachEvent("onmouseup", function(event){event.cancelBubble = true; event.returnValue = false;});
li.attachEvent("onmouseover", function(event){event.srcElement.style.backgroundColor="silver";});
li.attachEvent("onmouseout", function(event){event.srcElement.style.backgroundColor="transparent";});
}
}
}
Documentation generated by
JSDoc on Thu Feb 7 23:45:47 2008