initial checkin from subversion
This commit is contained in:
57
iconControl.js
Normal file
57
iconControl.js
Normal file
@@ -0,0 +1,57 @@
|
||||
function iconControl(){
|
||||
var m_domElement=document.createElement("span");
|
||||
m_domElement.setAttribute("class","iconContainer");
|
||||
|
||||
return(construct());
|
||||
|
||||
function construct(){
|
||||
m_domElement.addIcon=addIcon;
|
||||
m_domElement.fromXML=fromXML;
|
||||
m_domElement.toXML=toXML;
|
||||
return(m_domElement);
|
||||
}
|
||||
|
||||
function addIcon(iconName){
|
||||
var theIconNode=document.createElement("span");
|
||||
var theImageNode=document.createElement("img");
|
||||
theImageNode.setAttribute("src",iconName);
|
||||
theIconNode.appendChild(theImageNode);
|
||||
var mi=new Array();
|
||||
mi[0]=new textMenuItem("Delete",function(){deleteNode(theIconNode);});
|
||||
theIconNode.contextMenu=new menuControl(mi,1);
|
||||
theIconNode.contextMenu.hide();
|
||||
theIconNode.onclick=function(event) {
|
||||
theIconNode.contextMenu.toggleVisible();
|
||||
theIconNode.contextMenu.style.position="absolute";
|
||||
theIconNode.contextMenu.style.left=(5+theIconNode.offsetLeft) + "px";
|
||||
theIconNode.contextMenu.style.top=(5+theIconNode.offsetTop) + "px";
|
||||
|
||||
event.stopPropagation();
|
||||
}
|
||||
theIconNode.appendChild(theIconNode.contextMenu);
|
||||
document.addSubscriber(theIconNode.contextMenu.hide,"clicked");
|
||||
m_domElement.appendChild(theIconNode);
|
||||
}
|
||||
function deleteNode(theIconNode){
|
||||
theIconNode.parentNode.removeChild(theIconNode);
|
||||
}
|
||||
function fromXML(inXML){
|
||||
for(var i=0;i<inXML.childNodes.length;i++){
|
||||
var theIcon=inXML.childNodes[i];
|
||||
addIcon(theIcon.getAttribute("filename"));
|
||||
}
|
||||
return(construct());
|
||||
}
|
||||
function toXML(){
|
||||
var xmlEle=document.createElement("ICONS");
|
||||
var imageNodes=m_domElement.getElementsByTagName("img");
|
||||
for (var i=0;i<imageNodes.length;i++){
|
||||
var theImageNode=imageNodes[i];
|
||||
var singleIcon=document.createElement("ICON");
|
||||
singleIcon.setAttribute("filename",theImageNode.getAttribute("src"));
|
||||
xmlEle.appendChild(singleIcon);
|
||||
}
|
||||
return(xmlEle);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user