//v.2.5 build 91111 /* Copyright DHTMLX LTD. http://www.dhtmlx.com You allowed to use this component or parts of it under GPL terms To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com */ function xmlPointer(data){this.d=data};xmlPointer.prototype={text:function(){if (!_isFF)return this.d.xml;var x = new XMLSerializer();return x.serializeToString(this.d)}, get:function(name){return this.d.getAttribute(name)}, exists:function(){return !!this.d }, content:function(){return this.d.firstChild?this.d.firstChild.data:""}, each:function(name,f,t,i){var a=this.d.childNodes;var c=new xmlPointer();if (a.length)for (i=i||0;i0){beforeNode=new Object;beforeNode.tr=parentObject.childNodes[0].tr.previousSibling};parentObject._has_top=true;for (ik=Count;ik>0;ik--)Nodes[ik]=Nodes[ik-1];Count=0;break}}};var n;if (!(n=this._idpull[itemId])|| n.span!=-1){n=Nodes[Count]=new dhtmlXTreeItemObject(itemId,itemText,parentObject,this,itemActionHandler,1);itemId = Nodes[Count].id;parentObject.childsCount++};if(!n.htmlNode){n.label=itemText;n.htmlNode=this._createItem((this.checkBoxOff?1:0),n);n.htmlNode.objBelong=n};if(image1)n.images[0]=image1;if(image2)n.images[1]=image2;if(image3)n.images[2]=image3;var tr=this._drawNewTr(n.htmlNode);if ((this.XMLloadingWarning)||(this._hAdI)) n.htmlNode.parentNode.parentNode.style.display="none";if ((beforeNode)&&(beforeNode.tr.nextSibling)) parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);else if (this.parsingOn==parentObject.id){this.parsedArray[this.parsedArray.length]=tr}else parentObject.htmlNode.childNodes[0].appendChild(tr);if ((beforeNode)&&(!beforeNode.span)) beforeNode=null;if (this.XMLsource)if ((childs)&&(childs!=0)) n.XMLload=0;else n.XMLload=1;n.tr=tr;tr.nodem=n;if (parentObject.itemId==0)tr.childNodes[0].className="hiddenRow";if ((parentObject._r_logic)||(this._frbtr)) this._setSrc(n.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.imPath+this.radioArray[0]);if (optionStr){var tempStr=optionStr.split(",");for (var i=0;i=2){this._correctPlus(Nodes[parentObject.childsCount-2]);this._correctLine(Nodes[parentObject.childsCount-2])};if (parentObject.childsCount!=2)this._correctPlus(Nodes[0]);if (this.tscheck)this._correctCheckStates(parentObject);if (this._onradh){if (this.xmlstate==1){var old=this.onXLE;this.onXLE=function(id){this._onradh(itemId);if (old)old(id)}}else this._onradh(itemId)}};return n};dhtmlXTreeObject.prototype.insertNewItem=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){var parentObject=this._globalIdStorageFind(parentId);if (!parentObject)return (-1);var nodez=this._attachChildNode(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children);return nodez};dhtmlXTreeObject.prototype.insertNewChild=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){return this.insertNewItem(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children)};dhtmlXTreeObject.prototype._parseXMLTree=function(a,b,c,d,xml){var p=new xmlPointer(xml.getXMLTopNode("tree"));a._parse(p);a._p=p};dhtmlXTreeObject.prototype._parseItem=function(c,temp,preNode,befNode){var id;if (this._srnd && (!this._idpull[id=c.get("id")] || !this._idpull[id].span)) {this._addItemSRND(temp.id,id,c);return};var a=c.get_all();if ((typeof(this.waitUpdateXML)=="object")&&(!this.waitUpdateXML[a.id])){this._parse(c,a.id,1);return};var zST=[];if (a.select)zST.push("SELECT");if (a.top)zST.push("TOP");if (a.call)this.nodeAskingCall=a.id;if (a.checked==-1)zST.push("HCHECKED");else if (a.checked)zST.push("CHECKED");if (a.open)zST.push("OPEN");if (this.waitUpdateXML){if (this._globalIdStorageFind(a.id)) var newNode=this.updateItem(a.id,a.text,a.im0,a.im1,a.im2,a.checked);else{if (this.npl==0)zST.push("TOP");else preNode=temp.childNodes[this.npl];var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,0,preNode);preNode=null}}else var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,(befNode||0),preNode);if (a.tooltip)newNode.span.parentNode.parentNode.title=a.tooltip;if (a.style)if (newNode.span.style.cssText)newNode.span.style.cssText+=(";"+a.style);else newNode.span.setAttribute("style",newNode.span.getAttribute("style")+";"+a.style);if (a.radio)newNode._r_logic=true;if (a.nocheckbox){var check_node=newNode.span.parentNode.previousSibling.previousSibling;check_node.childNodes[0].style.display='none';if (window._KHTMLrv)check_node.style.display="none";newNode.nocheckbox=true};if (a.disabled){if (a.checked!=null)this._setCheck(newNode,a.checked);this.disableCheckbox(newNode,1)};newNode._acc=a.child||0;if (this.parserExtension)this.parserExtension._parseExtension.call(this,c,a,(temp?temp.id:0));this.setItemColor(newNode,a.aCol,a.sCol);if (a.locked=="1")this.lockItem(newNode.id,true,true);if ((a.imwidth)||(a.imheight)) this.setIconSize(a.imwidth,a.imheight,newNode);if ((a.closeable=="0")||(a.closeable=="1")) this.setItemCloseable(newNode,a.closeable);var zcall="";if (a.topoffset)this.setItemTopOffset(newNode,a.topoffset);if ((!this.slowParse)||(typeof(this.waitUpdateXML)=="object")){if (c.sub_exists("item")) zcall=this._parse(c,a.id,1)};if (zcall!="")this.nodeAskingCall=zcall;c.each("userdata",function(u){this.setUserData(c.get("id"),u.get("name"),u.content())},this) };dhtmlXTreeObject.prototype._parse=function(p,parentId,level,start){if (this._srnd && !this.parentObject.offsetHeight){var self=this;return window.setTimeout(function(){self._parse(p,parentId,level,start)},100)};if (!p.exists()) return;this.skipLock=true;if (!parentId){parentId=p.get("id");if (p.get("radio")) this.htmlNode._r_logic=true;this.parsingOn=parentId;this.parsedArray=new Array();this.setCheckList="";this.nodeAskingCall=""};var temp=this._globalIdStorageFind(parentId);if (!temp)return dhtmlxError.throwError("DataStructure","XML refers to not existing parent");this.parsCount=this.parsCount?(this.parsCount+1):1;this.XMLloadingWarning=1;if ((temp.childsCount)&&(!start)&&(!this._edsbps)&&(!temp._has_top)) var preNode=temp.childNodes[temp.childsCount-1];else var preNode=0;this.npl=0;p.each("item",function(c,i){temp.XMLload=1;if ((this._epgps)&&(this._epgpsC==this.npl)){this._setNextPageSign(temp,this.npl+1*(start||0),level,node);return -1};this._parseItem(c,temp,preNode);this.npl++},this,start);if (!level){p.each("userdata",function(u){this.setUserData(p.get("id"),u.get("name"),u.content())},this);temp.XMLload=1;if (this.waitUpdateXML){this.waitUpdateXML=false;for (var i=temp.childsCount-1;i>=0;i--)if (temp.childNodes[i]._dmark)this.deleteItem(temp.childNodes[i].id)};var parsedNodeTop=this._globalIdStorageFind(this.parsingOn);for (var i=0;i1){if ( ( (Nodes[1].style.display!="none")|| (mode==1) ) && (mode!=2) ) {this.allTree.childNodes[0].border = "1";this.allTree.childNodes[0].border = "0";nodestyle="none"}else nodestyle="";for (var i=1;i7)td2.style.width="999999px";else if (!window._KHTMLrv)td2.style.width="100%";itemObject.span.innerHTML=itemObject.label;td2.appendChild(itemObject.span);td2.parentObject=itemObject;td1.parentObject=itemObject;td2.onclick=this.onRowSelect;td1.onclick=this.onRowClick;td2.ondblclick=this.onRowClick2;if (this.ettip)tr.title=itemObject.label;if (this.dragAndDropOff){if (this._aimgs){this.dragger.addDraggableItem(td12,this);td12.parentObject=itemObject};this.dragger.addDraggableItem(td2,this)};itemObject.span.style.paddingLeft="5px";itemObject.span.style.paddingRight="5px";td2.style.verticalAlign="";td2.style.fontSize="10pt";td2.style.cursor=this.style_pointer;tr.appendChild(td1);tr.appendChild(td11);tr.appendChild(td12);tr.appendChild(td2);tbody.appendChild(tr);table.appendChild(tbody);if (this.ehlt || this.checkEvent("onMouseIn")|| this.checkEvent("onMouseOut")){tr.onmousemove=this._itemMouseIn;tr[(_isIE)?"onmouseleave":"onmouseout"]=this._itemMouseOut};return table};dhtmlXTreeObject.prototype.setImagePath=function( newPath ){this.imPath=newPath;this.iconURL=newPath};dhtmlXTreeObject.prototype.setIconPath=function(path){this.iconURL=path};dhtmlXTreeObject.prototype.setOnRightClickHandler=function(func){this.attachEvent("onRightClick",func)};dhtmlXTreeObject.prototype.setOnClickHandler=function(func){this.attachEvent("onClick",func)};dhtmlXTreeObject.prototype.setOnSelectStateChange=function(func){this.attachEvent("onSelect",func)};dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){this.XMLsource=filePath};dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){this.attachEvent("onCheck",func)};dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){this.attachEvent("onOpenStart",func)};dhtmlXTreeObject.prototype.setOnOpenStartHandler=function(func){this.attachEvent("onOpenStart",func)};dhtmlXTreeObject.prototype.setOnOpenEndHandler=function(func){this.attachEvent("onOpenEnd",func)};dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){this.attachEvent("onDblClick",func)};dhtmlXTreeObject.prototype.openAllItems=function(itemId) {var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;this._xopenAll(temp)};dhtmlXTreeObject.prototype.getOpenState=function(itemId){var temp=this._globalIdStorageFind(itemId);if (!temp)return "";return this._getOpenState(temp)};dhtmlXTreeObject.prototype.closeAllItems=function(itemId) {if (itemId===window.undefined)itemId=this.rootId;var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;this._xcloseAll(temp);this.allTree.childNodes[0].border = "1";this.allTree.childNodes[0].border = "0"};dhtmlXTreeObject.prototype.setUserData=function(itemId,name,value){var sNode=this._globalIdStorageFind(itemId,0,true);if (!sNode)return;if(name=="hint")sNode.htmlNode.childNodes[0].childNodes[0].title=value;if (typeof(sNode.userData["t_"+name])=="undefined"){if (!sNode._userdatalist)sNode._userdatalist=name;else sNode._userdatalist+=","+name};sNode.userData["t_"+name]=value};dhtmlXTreeObject.prototype.getUserData=function(itemId,name){var sNode=this._globalIdStorageFind(itemId,0,true);if (!sNode)return;return sNode.userData["t_"+name]};dhtmlXTreeObject.prototype.getItemColor=function(itemId) {var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;var res= new Object();if (temp.acolor)res.acolor=temp.acolor;if (temp.scolor)res.scolor=temp.scolor;return res};dhtmlXTreeObject.prototype.setItemColor=function(itemId,defaultColor,selectedColor) {if ((itemId)&&(itemId.span)) var temp=itemId;else var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;else {if (temp.i_sel){if (selectedColor)temp.span.style.color=selectedColor}else {if (defaultColor)temp.span.style.color=defaultColor};if (selectedColor)temp.scolor=selectedColor;if (defaultColor)temp.acolor=defaultColor}};dhtmlXTreeObject.prototype.getItemText=function(itemId) {var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;return(temp.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML)};dhtmlXTreeObject.prototype.getParentId=function(itemId) {var temp=this._globalIdStorageFind(itemId);if ((!temp)||(!temp.parentObject)) return "";return temp.parentObject.id};dhtmlXTreeObject.prototype.changeItemId=function(itemId,newItemId) {if (itemId==newItemId)return;var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;temp.id=newItemId;temp.span.contextMenuId=newItemId;this._idpull[newItemId]=this._idpull[itemId];delete this._idpull[itemId]};dhtmlXTreeObject.prototype.doCut=function(){if (this.nodeCut)this.clearCut();this.nodeCut=(new Array()).concat(this._selected);for (var i=0;i=2){this._correctPlus(Nodes[targetObject.childsCount-2]);this._correctLine(Nodes[targetObject.childsCount-2])};this._correctPlus(Nodes[targetObject.childsCount-1]);if (this.tscheck)this._correctCheckStates(targetObject);if (oldTree.tscheck)oldTree._correctCheckStates(z)};if (c>1){oldTree._correctPlus(z.childNodes[c-2]);oldTree._correctLine(z.childNodes[c-2])};oldTree._correctPlus(z);oldTree._correctLine(z);this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]);return itemObject.id};dhtmlXTreeObject.prototype._clearStyles=function(itemObject){if (!itemObject.htmlNode)return;var td1=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[1];var td3=td1.nextSibling.nextSibling;itemObject.span.innerHTML=itemObject.label;itemObject.i_sel=false;if (itemObject._aimgs)this.dragger.removeDraggableItem(td1.nextSibling);if (this.checkBoxOff){td1.childNodes[0].style.display="";td1.childNodes[0].onclick=this.onCheckBoxClick;this._setSrc(td1.childNodes[0],this.imPath+this.checkArray[itemObject.checkstate])}else td1.childNodes[0].style.display="none";td1.childNodes[0].treeNod=this;this.dragger.removeDraggableItem(td3);if (this.dragAndDropOff)this.dragger.addDraggableItem(td3,this);if (this._aimgs)this.dragger.addDraggableItem(td1.nextSibling,this);td3.childNodes[0].className="standartTreeRow";td3.onclick=this.onRowSelect;td3.ondblclick=this.onRowClick2;td1.previousSibling.onclick=this.onRowClick;this._correctLine(itemObject);this._correctPlus(itemObject);for (var i=0;i0)) {if (node.childNodes[i].unParsed)var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);else var zb=this._getAllScraggyItems(node.childNodes[i]) if (zb)if (z)z+=this.dlmtr+zb;else z=zb}else if (!z)z=node.childNodes[i].id;else z+=this.dlmtr+node.childNodes[i].id};return z};dhtmlXTreeObject.prototype._getAllFatItems =function(node) {var z="";for (var i=0;i0)) {if (!z)z=node.childNodes[i].id;else z+=this.dlmtr+node.childNodes[i].id;if (node.childNodes[i].unParsed)var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);else var zb=this._getAllFatItems(node.childNodes[i]) if (zb)z+=this.dlmtr+zb}};return z};dhtmlXTreeObject.prototype._getAllSubItems =function(itemId,z,node) {if (node)temp=node;else {var temp=this._globalIdStorageFind(itemId)};if (!temp)return 0;z="";for (var i=0;i=z.childsCount)) return null;return z.childNodes[index].id};dhtmlXTreeObject.prototype.getChildItemIdByIndex=function(itemId,index){var z=this._globalIdStorageFind(itemId);if ((!z)||(index>=z.childsCount)) return null;return z.childNodes[index].id};dhtmlXTreeObject.prototype.setDragHandler=function(func){this.attachEvent("onDrag",func)};dhtmlXTreeObject.prototype._clearMove=function(){if (this._lastMark){this._lastMark.className=this._lastMark.className.replace(/dragAndDropRow/g,"");this._lastMark=null};this.allTree.className=this.allTree.className.replace(" selectionBox","")};dhtmlXTreeObject.prototype.enableDragAndDrop=function(mode,rmode){if (mode=="temporary_disabled"){this.dADTempOff=false;mode=true}else this.dADTempOff=true;this.dragAndDropOff=convertStringToBoolean(mode);if (this.dragAndDropOff)this.dragger.addDragLanding(this.allTree,this);if (arguments.length>1)this._ddronr=(!convertStringToBoolean(rmode))};dhtmlXTreeObject.prototype._setMove=function(htmlNode,x,y){if (htmlNode.parentObject.span){var a1=getAbsoluteTop(htmlNode);var a2=getAbsoluteTop(this.allTree)-this.allTree.scrollTop;this.dadmodec=this.dadmode;this.dadmodefix=0;var zN=htmlNode.parentObject.span;zN.className+=" dragAndDropRow";this._lastMark=zN;this._autoScroll(null,a1,a2)}};dhtmlXTreeObject.prototype._autoScroll=function(node,a1,a2){if (this.autoScroll){if (node){a1=getAbsoluteTop(node);a2=getAbsoluteTop(this.allTree)};if ( (a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50) ) this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;if ( (a1-a2)<(parseInt(this.allTree.scrollTop)+30) ) this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20}};dhtmlXTreeObject.prototype._createDragNode=function(htmlObject,e){if (!this.dADTempOff)return null;var obj=htmlObject.parentObject;if (!this.callEvent("onBeforeDrag",[obj.id])) return null;if (!obj.i_sel)this._selectItem(obj,e);var dragSpan=document.createElement('div');var text=new Array();if (this._itim_dg)for (var i=0;i"+this._selected[i].span.innerHTML+"";else text=this.getSelectedItemText().split(this.dlmtr);dragSpan.innerHTML=text.join("");dragSpan.style.position="absolute";dragSpan.className="dragSpanDiv";this._dragged=(new Array()).concat(this._selected);return dragSpan};dhtmlXTreeObject.prototype._focusNode=function(item){var z=getAbsoluteTop(item.htmlNode)-getAbsoluteTop(this.allTree);if ((z>(this.allTree.scrollTop+this.allTree.offsetHeight-30))||(z2)?(sNode.checkstate-3):sNode.checkstate);this._setCheck(sNode);if (sNode.dscheck<3)sNode.dscheck=false};dhtmlXTreeObject.prototype.setEscapingMode=function(mode){this.utfesc=mode};dhtmlXTreeObject.prototype.enableHighlighting=function(mode) {this.ehlt=true;this.ehlta=convertStringToBoolean(mode)};dhtmlXTreeObject.prototype._itemMouseOut=function(){var that=this.childNodes[3].parentObject;var tree=that.treeNod;tree.callEvent("onMouseOut",[that.id]);if (that.id==tree._l_onMSI)tree._l_onMSI=null;if (!tree.ehlta)return;that.span.className=that.span.className.replace("_lor","")};dhtmlXTreeObject.prototype._itemMouseIn=function(){var that=this.childNodes[3].parentObject;var tree=that.treeNod;if (tree._l_onMSI!=that.id)tree.callEvent("onMouseIn",[that.id]);tree._l_onMSI=that.id;if (!tree.ehlta)return;that.span.className=that.span.className.replace("_lor","");that.span.className=that.span.className.replace(/((standart|selected)TreeRow)/,"$1_lor")};dhtmlXTreeObject.prototype.enableActiveImages=function(mode){this._aimgs=convertStringToBoolean(mode)};dhtmlXTreeObject.prototype.focusItem=function(itemId){var sNode=this._globalIdStorageFind(itemId);if (!sNode)return (0);this._focusNode(sNode)};dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){return this._getAllSubItems(itemId)};dhtmlXTreeObject.prototype.getAllChildless =function(){return this._getAllScraggyItems(this.htmlNode)};dhtmlXTreeObject.prototype.getAllLeafs=dhtmlXTreeObject.prototype.getAllChildless;dhtmlXTreeObject.prototype._getAllScraggyItems =function(node) {var z="";for (var i=0;i0)) {if (node.childNodes[i].unParsed)var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);else var zb=this._getAllScraggyItems(node.childNodes[i]) if (zb)if (z)z+=this.dlmtr+zb;else z=zb}else if (!z)z=node.childNodes[i].id;else z+=this.dlmtr+node.childNodes[i].id};return z};dhtmlXTreeObject.prototype._getAllFatItems =function(node) {var z="";for (var i=0;i0)) {if (!z)z=node.childNodes[i].id;else z+=this.dlmtr+node.childNodes[i].id;if (node.childNodes[i].unParsed)var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);else var zb=this._getAllFatItems(node.childNodes[i]) if (zb)z+=this.dlmtr+zb}};return z};dhtmlXTreeObject.prototype.getAllItemsWithKids =function(){return this._getAllFatItems(this.htmlNode)};dhtmlXTreeObject.prototype.getAllFatItems=dhtmlXTreeObject.prototype.getAllItemsWithKids;dhtmlXTreeObject.prototype.getAllChecked=function(){return this._getAllChecked("","",1)};dhtmlXTreeObject.prototype.getAllUnchecked=function(itemId){if (itemId)itemId=this._globalIdStorageFind(itemId);return this._getAllChecked(itemId,"",0)};dhtmlXTreeObject.prototype.getAllPartiallyChecked=function(){return this._getAllChecked("","",2)};dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){var temp= this._getAllChecked("","",1);if (temp!="")temp+=this.dlmtr;return temp+this._getAllChecked("","",2)};dhtmlXTreeObject.prototype._getAllChecked=function(htmlNode,list,mode){if (!htmlNode)htmlNode=this.htmlNode;if (htmlNode.checkstate==mode)if (!htmlNode.nocheckbox){if (list)list+=this.dlmtr+htmlNode.id;else list=htmlNode.id};var j=htmlNode.childsCount;for (var i=0;i