File Annotation
Not logged in
38fcc662be 2010-11-10        kinaba: /* This file is a part of CanDyDOC fileset.
38fcc662be 2010-11-10        kinaba:    File is written by Victor Nakoryakov and placed into the public domain.
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:    This file is javascript with classes that represents native style tree control. */
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba: var pmNone = 0;
38fcc662be 2010-11-10        kinaba: var pmPlus = 1;
38fcc662be 2010-11-10        kinaba: var pmMinus = 2;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba: var hlNone = 0;
38fcc662be 2010-11-10        kinaba: var hlGrey = 1;
38fcc662be 2010-11-10        kinaba: var hlSelected = 2;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba: function TreeView(hrefMode)
38fcc662be 2010-11-10        kinaba: {
38fcc662be 2010-11-10        kinaba:     this.domEntry = document.createElement("div");
38fcc662be 2010-11-10        kinaba:     this.children = new Array();
38fcc662be 2010-11-10        kinaba:     this.selection = null;
38fcc662be 2010-11-10        kinaba:     this.hrefMode = hrefMode;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.createBranch = function(text, iconSrc)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var root = new TreeNode(text, iconSrc, this.hrefMode);
38fcc662be 2010-11-10        kinaba:         root.owner = this;
38fcc662be 2010-11-10        kinaba:         this.children[ this.children.length ] = root;
38fcc662be 2010-11-10        kinaba:         this.domEntry.appendChild( root.domEntry );
38fcc662be 2010-11-10        kinaba:         return root;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.branch = function(text)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var ret = null;
38fcc662be 2010-11-10        kinaba:         for (var i = 0; i < this.children.length; ++i)
38fcc662be 2010-11-10        kinaba:             if (this.children[i].textElement.data == text)
38fcc662be 2010-11-10        kinaba:             {
38fcc662be 2010-11-10        kinaba:                 ret = this.children[i];
38fcc662be 2010-11-10        kinaba:                 break;
38fcc662be 2010-11-10        kinaba:             }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         return ret;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.domEntry.style.fontSize = "10px";
38fcc662be 2010-11-10        kinaba:     this.domEntry.style.cursor = "default";
38fcc662be 2010-11-10        kinaba:     this.domEntry.style.whiteSpace = "nowrap";
38fcc662be 2010-11-10        kinaba: }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba: var idCounter = 0;
38fcc662be 2010-11-10        kinaba: function TreeNode(text, iconSrc, hrefMode)
38fcc662be 2010-11-10        kinaba: {
38fcc662be 2010-11-10        kinaba:     this.id             = idCounter++;
38fcc662be 2010-11-10        kinaba:     this.parentNode     = null;
38fcc662be 2010-11-10        kinaba:     this.children       = new Array();
38fcc662be 2010-11-10        kinaba:     this.domEntry       = document.createElement("div");
38fcc662be 2010-11-10        kinaba:     this.icon           = document.createElement("img");
38fcc662be 2010-11-10        kinaba:     this.textElement    = document.createTextNode(text);
38fcc662be 2010-11-10        kinaba:     this.textSpan       = document.createElement("span");
38fcc662be 2010-11-10        kinaba:     this.lineDiv        = document.createElement("div");
38fcc662be 2010-11-10        kinaba:     this.hierarchyImgs  = new Array();
38fcc662be 2010-11-10        kinaba:     this.onclick        = null;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     function createIcon()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var img = document.createElement("img");
38fcc662be 2010-11-10        kinaba:         img.style.verticalAlign = "middle";
38fcc662be 2010-11-10        kinaba:         img.style.position = "relative";
38fcc662be 2010-11-10        kinaba:         img.style.top = "-1px";
38fcc662be 2010-11-10        kinaba:         img.width = 16;
38fcc662be 2010-11-10        kinaba:         img.height = 16;
38fcc662be 2010-11-10        kinaba:         return img;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     function createHierarchyImage()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var img = createIcon();
38fcc662be 2010-11-10        kinaba:         img.pointsTop = false;
38fcc662be 2010-11-10        kinaba:         img.pointsBottom = false;
38fcc662be 2010-11-10        kinaba:         img.pointsRight = false;
38fcc662be 2010-11-10        kinaba:         img.pmState = pmNone;
38fcc662be 2010-11-10        kinaba:         return img;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     function genHierarchyImageSrc(hierarchyImg)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var name = "";
38fcc662be 2010-11-10        kinaba:         if (hierarchyImg.pointsTop)
38fcc662be 2010-11-10        kinaba:             name += "t";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (hierarchyImg.pointsBottom)
38fcc662be 2010-11-10        kinaba:             name += "b";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (hierarchyImg.pointsRight)
38fcc662be 2010-11-10        kinaba:             name += "r";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (hierarchyImg.pmState == pmPlus)
38fcc662be 2010-11-10        kinaba:             name += "p";
38fcc662be 2010-11-10        kinaba:         else if (hierarchyImg.pmState == pmMinus)
38fcc662be 2010-11-10        kinaba:             name += "m";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (name == "")
38fcc662be 2010-11-10        kinaba:             name = "shim";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         return "candydoc/img/tree/" + name + ".gif";
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     function setSrc(icon, src)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         icon.src = src;
38fcc662be 2010-11-10        kinaba:         // After src change width and height are reseted in IE.
38fcc662be 2010-11-10        kinaba:         // Bug workaround:
38fcc662be 2010-11-10        kinaba:         icon.width = 16;
38fcc662be 2010-11-10        kinaba:         icon.height = 16;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.createChild = function(text, iconSrc)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var child = new TreeNode(text, iconSrc, this.owner.hrefMode);
38fcc662be 2010-11-10        kinaba:         this.children[ this.children.length ] = child;
38fcc662be 2010-11-10        kinaba:         this.domEntry.appendChild( child.domEntry );
38fcc662be 2010-11-10        kinaba:         child.parentNode = this;
38fcc662be 2010-11-10        kinaba:         child.owner = this.owner;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         // insert hierarchy images according to deepness level
38fcc662be 2010-11-10        kinaba:         // of created child.
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (this.children.length > 1)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             // there were already added child before. So copy `level-1`
38fcc662be 2010-11-10        kinaba:             // hierarchy images from it.
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             var prevAddedChild = this.children[ this.children.length - 2 ];
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             for (var i = 0; i < prevAddedChild.hierarchyImgs.length - 1; ++i)
38fcc662be 2010-11-10        kinaba:             {
38fcc662be 2010-11-10        kinaba:                 var prevAddedChildImg = prevAddedChild.hierarchyImgs[i];
38fcc662be 2010-11-10        kinaba:                 var img = createHierarchyImage();
38fcc662be 2010-11-10        kinaba:                 setSrc(img, prevAddedChildImg.src);
38fcc662be 2010-11-10        kinaba:                 img.pointsTop = prevAddedChildImg.pointsTop;
38fcc662be 2010-11-10        kinaba:                 img.pointsBottom = prevAddedChildImg.pointsBottom;
38fcc662be 2010-11-10        kinaba:                 img.pointsRight = prevAddedChildImg.pointsRight;
38fcc662be 2010-11-10        kinaba:                 img.pmState = prevAddedChildImg.pmState;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:                 child.hierarchyImgs[ child.hierarchyImgs.length ] = img;
38fcc662be 2010-11-10        kinaba:                 child.lineDiv.insertBefore(img, child.icon);
38fcc662be 2010-11-10        kinaba:             }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             // change last hierarchy image of prevAddedChild from |_ to |-
38fcc662be 2010-11-10        kinaba:             var lastHierarchyImg = prevAddedChild.hierarchyImgs[ prevAddedChild.hierarchyImgs.length - 1 ];
38fcc662be 2010-11-10        kinaba:             lastHierarchyImg.pointsBottom = true;
38fcc662be 2010-11-10        kinaba:             setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg));
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             // change hierarchy images of prevAddedChild's children on it's last
38fcc662be 2010-11-10        kinaba:             // level to |
38fcc662be 2010-11-10        kinaba:             prevAddedChild.addHierarchyTBLine(prevAddedChild.hierarchyImgs.length - 1);
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:         else
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             // this is a first child. So copy `level-2`
38fcc662be 2010-11-10        kinaba:             // hierarchy images from parent, i.e. this.
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             for (var i = 0; i < this.hierarchyImgs.length - 1; ++i)
38fcc662be 2010-11-10        kinaba:             {
38fcc662be 2010-11-10        kinaba:                 var parentImg = this.hierarchyImgs[i];
38fcc662be 2010-11-10        kinaba:                 var img = createHierarchyImage();
38fcc662be 2010-11-10        kinaba:                 setSrc(img, parentImg.src);
38fcc662be 2010-11-10        kinaba:                 img.pointsTop = parentImg.pointsTop;
38fcc662be 2010-11-10        kinaba:                 img.pointsBottom = parentImg.pointsBottom;
38fcc662be 2010-11-10        kinaba:                 img.pointsRight = parentImg.pointsRight;
38fcc662be 2010-11-10        kinaba:                 img.pmState = parentImg.pmState;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:                 child.hierarchyImgs[ child.hierarchyImgs.length ] = img;
38fcc662be 2010-11-10        kinaba:                 child.lineDiv.insertBefore(img, child.icon);
38fcc662be 2010-11-10        kinaba:             }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             if (this.hierarchyImgs.length > 0) // we are not root
38fcc662be 2010-11-10        kinaba:             {
38fcc662be 2010-11-10        kinaba:                 // change last hierarchy image of parent (i.e. this): add minus to it
38fcc662be 2010-11-10        kinaba:                 var lastHierarchyImg = this.hierarchyImgs[ this.hierarchyImgs.length - 1];
38fcc662be 2010-11-10        kinaba:                 lastHierarchyImg.pmState = pmMinus;
38fcc662be 2010-11-10        kinaba:                 setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg));
38fcc662be 2010-11-10        kinaba:                 lastHierarchyImg.owner = this;
38fcc662be 2010-11-10        kinaba:                 lastHierarchyImg.onclick = new Function("e", "this.owner.processPMClick(e);");
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:                 // make decision on image on `level-1`. It depends on parent's (ie this)
38fcc662be 2010-11-10        kinaba:                 // image on same level.
38fcc662be 2010-11-10        kinaba:                 var parentL1HierarchyImg = lastHierarchyImg;
38fcc662be 2010-11-10        kinaba:                 var l1HierarchyImg = createHierarchyImage();
38fcc662be 2010-11-10        kinaba:                 if (parentL1HierarchyImg.pointsBottom)
38fcc662be 2010-11-10        kinaba:                 {
38fcc662be 2010-11-10        kinaba:                     l1HierarchyImg.pointsTop = true;
38fcc662be 2010-11-10        kinaba:                     l1HierarchyImg.pointsBottom = true;
38fcc662be 2010-11-10        kinaba:                 }
38fcc662be 2010-11-10        kinaba:                 setSrc(l1HierarchyImg, genHierarchyImageSrc(l1HierarchyImg));
38fcc662be 2010-11-10        kinaba:                 child.hierarchyImgs[ child.hierarchyImgs.length ] = l1HierarchyImg;
38fcc662be 2010-11-10        kinaba:                 child.lineDiv.insertBefore(l1HierarchyImg, child.icon);
38fcc662be 2010-11-10        kinaba:             }
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         // in any case on last level our child will have icon |_
38fcc662be 2010-11-10        kinaba:         var img = createHierarchyImage();
38fcc662be 2010-11-10        kinaba:         img.pointsTop = true;
38fcc662be 2010-11-10        kinaba:         img.pointsRight = true;
38fcc662be 2010-11-10        kinaba:         setSrc(img, genHierarchyImageSrc(img));
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         child.hierarchyImgs[ child.hierarchyImgs.length ] = img;
38fcc662be 2010-11-10        kinaba:         child.lineDiv.insertBefore(img, child.icon);
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         return child;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.lastChild = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         return this.children[ this.children.length - 1 ];
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.child = function(text)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var ret = null;
38fcc662be 2010-11-10        kinaba:         for (var i = 0; i < this.children.length; ++i)
38fcc662be 2010-11-10        kinaba:             if (this.children[i].textElement.data == text)
38fcc662be 2010-11-10        kinaba:             {
38fcc662be 2010-11-10        kinaba:                 ret = this.children[i];
38fcc662be 2010-11-10        kinaba:                 break;
38fcc662be 2010-11-10        kinaba:             }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         return ret;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.addHierarchyTBLine = function(level)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         for (var i = 0; i < this.children.length; ++i)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             var img = this.children[i].hierarchyImgs[level];
38fcc662be 2010-11-10        kinaba:             img.pointsTop = true;
38fcc662be 2010-11-10        kinaba:             img.pointsBottom = true;
38fcc662be 2010-11-10        kinaba:             setSrc(img, genHierarchyImageSrc(img));
38fcc662be 2010-11-10        kinaba:             this.children[i].addHierarchyTBLine(level);
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.expand = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ];
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (img.pmState == pmPlus)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             img.pmState = pmMinus;
38fcc662be 2010-11-10        kinaba:             setSrc(img, genHierarchyImageSrc(img));
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             for (var i = 0; i < this.children.length; ++i)
38fcc662be 2010-11-10        kinaba:                 this.children[i].domEntry.style.display = "";
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.collapse = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ];
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         if (img.pmState == pmMinus)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             img.pmState = pmPlus;
38fcc662be 2010-11-10        kinaba:             setSrc(img, genHierarchyImageSrc(img));
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             for (var i = 0; i < this.children.length; ++i)
38fcc662be 2010-11-10        kinaba:                 this.children[i].domEntry.style.display = "none";
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.toggle = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ];
38fcc662be 2010-11-10        kinaba:         if (img.pmState == pmMinus)
38fcc662be 2010-11-10        kinaba:             this.collapse();
38fcc662be 2010-11-10        kinaba:         else
38fcc662be 2010-11-10        kinaba:             this.expand();
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.select = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         if (this.owner.selection != this)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             if (this.owner.selection)
38fcc662be 2010-11-10        kinaba:                 this.owner.selection.setHighlight(hlNone);
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:             this.owner.selection = this;
38fcc662be 2010-11-10        kinaba:             this.setHighlight(hlSelected);
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.setHighlight = function(mode)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         if (mode == hlNone)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.backgroundColor = "";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.color = "";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.border = "";
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:         else if (mode == hlGrey)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.backgroundColor = "#aaaaaa";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.color = "";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.border = "";
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:         else if (mode == hlSelected)
38fcc662be 2010-11-10        kinaba:         {
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.backgroundColor = "3399cc";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.color = "white";
38fcc662be 2010-11-10        kinaba:             this.textSpan.style.border = "dotted 1px red";
38fcc662be 2010-11-10        kinaba:         }
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.setOnclick = function(proc)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.onclick = proc;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.setRef = function(url)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         if (this.anchor)
38fcc662be 2010-11-10        kinaba:             this.anchor.href = url;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.processPMClick = function(e)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.toggle();
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:         // prevent this line selection, stop bubbling
38fcc662be 2010-11-10        kinaba:         if (e)
38fcc662be 2010-11-10        kinaba:             e.stopPropagation(); // Mozilla way
38fcc662be 2010-11-10        kinaba:         if (window.event)
38fcc662be 2010-11-10        kinaba:             window.event.cancelBubble = true; // IE way
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.processOnclick = function()
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.select();
38fcc662be 2010-11-10        kinaba:         if (this.onclick instanceof Function)
38fcc662be 2010-11-10        kinaba:             this.onclick();
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     ///////////////////////////////////////////////////////////////////////////
38fcc662be 2010-11-10        kinaba:     if (iconSrc)
38fcc662be 2010-11-10        kinaba:         this.icon.src = iconSrc;
38fcc662be 2010-11-10        kinaba:     else
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.icon.width = 0;
38fcc662be 2010-11-10        kinaba:         this.icon.height = 0;
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.icon.style.verticalAlign = "middle";
38fcc662be 2010-11-10        kinaba:     this.icon.style.position = "relative";
38fcc662be 2010-11-10        kinaba:     this.icon.style.top = "-1px";
38fcc662be 2010-11-10        kinaba:     this.icon.style.paddingRight = "2px";
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     if (!hrefMode)
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.textSpan.appendChild( this.textElement );
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba:     else
38fcc662be 2010-11-10        kinaba:     {
38fcc662be 2010-11-10        kinaba:         this.anchor = document.createElement("a");
38fcc662be 2010-11-10        kinaba:         this.anchor.appendChild( this.textElement );
38fcc662be 2010-11-10        kinaba:         this.textSpan.appendChild( this.anchor );
38fcc662be 2010-11-10        kinaba:     }
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.lineDiv.appendChild( this.icon );
38fcc662be 2010-11-10        kinaba:     this.lineDiv.appendChild( this.textSpan );
38fcc662be 2010-11-10        kinaba:     this.domEntry.appendChild( this.lineDiv );
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     this.lineDiv.owner = this;
38fcc662be 2010-11-10        kinaba: 
38fcc662be 2010-11-10        kinaba:     if (!hrefMode)
38fcc662be 2010-11-10        kinaba:         this.lineDiv.onclick = new Function("this.owner.processOnclick();");
38fcc662be 2010-11-10        kinaba: }