//v.3.0 build 110707 /* 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(a){this.d=a} xmlPointer.prototype={text:function(){if(!_isFF)return this.d.xml;var a=new XMLSerializer;return a.serializeToString(this.d)},get:function(a){return this.d.getAttribute(a)},exists:function(){return!!this.d},content:function(){return this.d.firstChild?this.d.firstChild.data:""},each:function(a,b,c,d){var f=this.d.childNodes,e=new xmlPointer;if(f.length)for(d=d||0;d 0)i={},i.tr=a.childNodes[0].tr.previousSibling;a._has_top=!0;for(o=k;o>0;o--)l[o]=l[o-1];k=0}var n;if(!(n=this._idpull[b])||n.span!=-1)n=l[k]=new dhtmlXTreeItemObject(b,c,a,this,d,1),b=l[k].id,a.childsCount++;if(!n.htmlNode)n.label=c,n.htmlNode=this._createItem(this.checkBoxOff?1:0,n),n.htmlNode.objBelong=n;f&&(n.images[0]=f);e&&(n.images[1]=e);g&&(n.images[2]=g);var q=this._drawNewTr(n.htmlNode);if(this.XMLloadingWarning||this._hAdI)n.htmlNode.parentNode.parentNode.style.display="none";i&&i.tr.nextSibling? a.htmlNode.childNodes[0].insertBefore(q,i.tr.nextSibling):this.parsingOn==a.id?this.parsedArray[this.parsedArray.length]=q:a.htmlNode.childNodes[0].appendChild(q);i&&!i.span&&(i=null);if(this.XMLsource)n.XMLload=j&&j!=0?0:1;n.tr=q;q.nodem=n;if(a.itemId==0)q.childNodes[0].className="hiddenRow";(a._r_logic||this._frbtr)&&this._setSrc(n.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.imPath+this.radioArray[0]);if(h){s=h.split(",");for(p=0;p=2&&(this._correctPlus(l[a.childsCount-2]), this._correctLine(l[a.childsCount-2])),a.childsCount!=2&&this._correctPlus(l[0]),this.tscheck&&this._correctCheckStates(a),this._onradh))if(this.xmlstate==1){var t=this.onXLE;this.onXLE=function(a){this._onradh(b);t&&t(a)}}else this._onradh(b);return n};dhtmlXTreeObject.prototype.insertNewItem=function(a,b,c,d,f,e,g,h,j){var i=this._globalIdStorageFind(a);if(!i)return-1;var m=this._attachChildNode(i,b,c,d,f,e,g,h,j);return m}; dhtmlXTreeObject.prototype.insertNewChild=function(a,b,c,d,f,e,g,h,j){return this.insertNewItem(a,b,c,d,f,e,g,h,j)};dhtmlXTreeObject.prototype._parseXMLTree=function(a,b,c,d,f){var e=new xmlPointer(f.getXMLTopNode("tree"));a._parse(e);a._p=e}; dhtmlXTreeObject.prototype._parseItem=function(a,b,c,d){var f;if(this._srnd&&(!this._idpull[f=a.get("id")]||!this._idpull[f].span))this._addItemSRND(b.id,f,a);else{var e=a.get_all();if(typeof this.waitUpdateXML=="object"&&!this.waitUpdateXML[e.id])this._parse(a,e.id,1);else{var g=[];e.select&&g.push("SELECT");e.top&&g.push("TOP");if(e.call)this.nodeAskingCall=e.id;e.checked==-1?g.push("HCHECKED"):e.checked&&g.push("CHECKED");e.open&&g.push("OPEN");if(this.waitUpdateXML)if(this._globalIdStorageFind(e.id))var h= this.updateItem(e.id,e.text,e.im0,e.im1,e.im2,e.checked,e.child);else this.npl==0?g.push("TOP"):c=b.childNodes[this.npl],h=this._attachChildNode(b,e.id,e.text,0,e.im0,e.im1,e.im2,g.join(","),e.child,0,c),c=null;else h=this._attachChildNode(b,e.id,e.text,0,e.im0,e.im1,e.im2,g.join(","),e.child,d||0,c);if(e.tooltip)h.span.parentNode.parentNode.title=e.tooltip;e.style&&(h.span.style.cssText?h.span.style.cssText+=";"+e.style:h.span.setAttribute("style",h.span.getAttribute("style")+"; "+e.style));if(e.radio)h._r_logic= !0;if(e.nocheckbox){var j=h.span.parentNode.previousSibling.previousSibling;j.childNodes[0].style.display="none";if(window._KHTMLrv)j.style.display="none";h.nocheckbox=!0}e.disabled&&(e.checked!=null&&this._setCheck(h,e.checked),this.disableCheckbox(h,1));h._acc=e.child||0;this.parserExtension&&this.parserExtension._parseExtension.call(this,a,e,b?b.id:0);this.setItemColor(h,e.aCol,e.sCol);e.locked=="1"&&this.lockItem(h.id,!0,!0);(e.imwidth||e.imheight)&&this.setIconSize(e.imwidth,e.imheight,h);(e.closeable== "0"||e.closeable=="1")&&this.setItemCloseable(h,e.closeable);var i="";e.topoffset&&this.setItemTopOffset(h,e.topoffset);if(!this.slowParse||typeof this.waitUpdateXML=="object")a.sub_exists("item")&&(i=this._parse(a,e.id,1));if(i!="")this.nodeAskingCall=i;a.each("userdata",function(b){this.setUserData(a.get("id"),b.get("name"),b.content())},this)}}}; dhtmlXTreeObject.prototype._parse=function(a,b,c,d){if(this._srnd&&!this.parentObject.offsetHeight){var f=this;return window.setTimeout(function(){f._parse(a,b,c,d)},100)}if(a.exists()){this.skipLock=!0;if(!b){b=a.get("id");if(a.get("radio"))this.htmlNode._r_logic=!0;this.parsingOn=b;this.parsedArray=[];this.nodeAskingCall=this.setCheckList=""}var e=this._globalIdStorageFind(b);if(!e)return dhtmlxError.throwError("DataStructure","XML refers to not existing parent");this.parsCount=this.parsCount?this.parsCount+ 1:1;this.XMLloadingWarning=1;var g=e.childsCount&&!d&&!this._edsbps&&!e._has_top?0:0;this.npl=0;a.each("item",function(a){e.XMLload=1;this._parseItem(a,e,0,g);this.npl++},this,d);if(!c){a.each("userdata",function(b){this.setUserData(a.get("id"),b.get("name"),b.content())},this);e.XMLload=1;if(this.waitUpdateXML){this.waitUpdateXML=!1;for(var h=e.childsCount-1;h>=0;h--)e.childNodes[h]._dmark&&this.deleteItem(e.childNodes[h].id)}for(var j=this._globalIdStorageFind(this.parsingOn),h=0;h1){(c[1].style.display!="none"||b==1)&&b!=2?(this.allTree.childNodes[0].border="1",this.allTree.childNodes[0].border="0",nodestyle="none"):nodestyle="";for(var f=1;f7)l.style.width="999999px";else if(!window._KHTMLrv)l.style.width="100%";b.span.innerHTML=b.label;l.appendChild(b.span);l.parentObject=b;g.parentObject= b;l.onclick=this.onRowSelect;g.onclick=this.onRowClick;l.ondblclick=this.onRowClick2;if(this.ettip)e.title=b.label;if(this.dragAndDropOff){if(this._aimgs)this.dragger.addDraggableItem(m,this),m.parentObject=b;this.dragger.addDraggableItem(l,this)}b.span.style.paddingLeft="5px";b.span.style.paddingRight="5px";l.style.verticalAlign="";l.style.fontSize="10pt";l.style.cursor=this.style_pointer;e.appendChild(g);e.appendChild(j);e.appendChild(m);e.appendChild(l);f.appendChild(e);d.appendChild(f);if(this.ehlt|| this.checkEvent("onMouseIn")||this.checkEvent("onMouseOut"))e.onmousemove=this._itemMouseIn,e[_isIE?"onmouseleave":"onmouseout"]=this._itemMouseOut;return d};dhtmlXTreeObject.prototype.setImagePath=function(a){this.iconURL=this.imPath=a};dhtmlXTreeObject.prototype.setIconPath=function(a){this.iconURL=a};dhtmlXTreeObject.prototype.setOnRightClickHandler=function(a){this.attachEvent("onRightClick",a)};dhtmlXTreeObject.prototype.setOnClickHandler=function(a){this.attachEvent("onClick",a)}; dhtmlXTreeObject.prototype.setOnSelectStateChange=function(a){this.attachEvent("onSelect",a)};dhtmlXTreeObject.prototype.setXMLAutoLoading=function(a){this.XMLsource=a};dhtmlXTreeObject.prototype.setOnCheckHandler=function(a){this.attachEvent("onCheck",a)};dhtmlXTreeObject.prototype.setOnOpenHandler=function(a){this.attachEvent("onOpenStart",a)};dhtmlXTreeObject.prototype.setOnOpenStartHandler=function(a){this.attachEvent("onOpenStart",a)}; dhtmlXTreeObject.prototype.setOnOpenEndHandler=function(a){this.attachEvent("onOpenEnd",a)};dhtmlXTreeObject.prototype.setOnDblClickHandler=function(a){this.attachEvent("onDblClick",a)};dhtmlXTreeObject.prototype.openAllItems=function(a){var b=this._globalIdStorageFind(a);if(!b)return 0;this._xopenAll(b)};dhtmlXTreeObject.prototype.getOpenState=function(a){var b=this._globalIdStorageFind(a);return!b?"":this._getOpenState(b)}; dhtmlXTreeObject.prototype.closeAllItems=function(a){if(a===window.undefined)a=this.rootId;var b=this._globalIdStorageFind(a);if(!b)return 0;this._xcloseAll(b);this.allTree.childNodes[0].border="1";this.allTree.childNodes[0].border="0"}; dhtmlXTreeObject.prototype.setUserData=function(a,b,c){var d=this._globalIdStorageFind(a,0,!0);if(d){if(b=="hint")d.htmlNode.childNodes[0].childNodes[0].title=c;if(typeof d.userData["t_"+b]=="undefined")d._userdatalist?d._userdatalist+=","+b:d._userdatalist=b;d.userData["t_"+b]=c}};dhtmlXTreeObject.prototype.getUserData=function(a,b){var c=this._globalIdStorageFind(a,0,!0);return!c?void 0:c.userData["t_"+b]}; dhtmlXTreeObject.prototype.getItemColor=function(a){var b=this._globalIdStorageFind(a);if(!b)return 0;var c={};if(b.acolor)c.acolor=b.acolor;if(b.scolor)c.scolor=b.scolor;return c};dhtmlXTreeObject.prototype.setItemColor=function(a,b,c){var d=a&&a.span?a:this._globalIdStorageFind(a);if(d){if(d.i_sel){if(c)d.span.style.color=c}else if(b)d.span.style.color=b;if(c)d.scolor=c;if(b)d.acolor=b}else return 0}; dhtmlXTreeObject.prototype.getItemText=function(a){var b=this._globalIdStorageFind(a);return!b?0:b.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML};dhtmlXTreeObject.prototype.getParentId=function(a){var b=this._globalIdStorageFind(a);return!b||!b.parentObject?"":b.parentObject.id};dhtmlXTreeObject.prototype.changeItemId=function(a,b){if(a!=b){var c=this._globalIdStorageFind(a);if(!c)return 0;c.id=b;c.span.contextMenuId=b;this._idpull[b]=this._idpull[a];delete this._idpull[a]}}; dhtmlXTreeObject.prototype.doCut=function(){this.nodeCut&&this.clearCut();this.nodeCut=[].concat(this._selected);for(var a=0;a=2&&(this._correctPlus(i[b.childsCount-2]),this._correctLine(i[b.childsCount-2]));this._correctPlus(i[b.childsCount-1]);this.tscheck&&this._correctCheckStates(b);f.tscheck&&f._correctCheckStates(g)}e>1&&(f._correctPlus(g.childNodes[e-2]),f._correctLine(g.childNodes[e-2]));f._correctPlus(g);f._correctLine(g);this.callEvent("onDrop",[a.id,b.id,c?c.id:null,f,b.treeNod]);return a.id}; dhtmlXTreeObject.prototype._clearStyles=function(a){if(a.htmlNode){var b=a.htmlNode.childNodes[0].childNodes[0].childNodes[1],c=b.nextSibling.nextSibling;a.span.innerHTML=a.label;a.i_sel=!1;a._aimgs&&this.dragger.removeDraggableItem(b.nextSibling);this.checkBoxOff?(b.childNodes[0].style.display="",b.childNodes[0].onclick=this.onCheckBoxClick,this._setSrc(b.childNodes[0],this.imPath+this.checkArray[a.checkstate])):b.childNodes[0].style.display="none";b.childNodes[0].treeNod=this;this.dragger.removeDraggableItem(c); this.dragAndDropOff&&this.dragger.addDraggableItem(c,this);this._aimgs&&this.dragger.addDraggableItem(b.nextSibling,this);c.childNodes[0].className="standartTreeRow";c.onclick=this.onRowSelect;c.ondblclick=this.onRowClick2;b.previousSibling.onclick=this.onRowClick;this._correctLine(a);this._correctPlus(a);for(var d=0;d0){var d=a.childNodes[c].unParsed?this._getAllScraggyItemsXML(a.childNodes[c].unParsed,1):this._getAllScraggyItems(a.childNodes[c]);d&&(b?b+=this.dlmtr+d:b=d)}else b?b+=this.dlmtr+a.childNodes[c].id:b=a.childNodes[c].id;return b}; dhtmlXTreeObject.prototype._getAllFatItems=function(a){for(var b="",c=0;c0){b?b+=this.dlmtr+a.childNodes[c].id:b=a.childNodes[c].id;var d=a.childNodes[c].unParsed?this._getAllFatItemsXML(a.childNodes[c].unParsed,1):this._getAllFatItems(a.childNodes[c]);d&&(b+=this.dlmtr+d)}return b}; dhtmlXTreeObject.prototype._getAllSubItems=function(a,b,c){var d=c?c:this._globalIdStorageFind(a);if(!d)return 0;for(var b="",f=0;f=c.childsCount?null:c.childNodes[b].id};dhtmlXTreeObject.prototype.getChildItemIdByIndex=function(a,b){var c=this._globalIdStorageFind(a);return!c||b>=c.childsCount?null:c.childNodes[b].id};dhtmlXTreeObject.prototype.setDragHandler=function(a){this.attachEvent("onDrag",a)}; 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(a,b){a=="temporary_disabled"?(this.dADTempOff=!1,a=!0):this.dADTempOff=!0;(this.dragAndDropOff=convertStringToBoolean(a))&&this.dragger.addDragLanding(this.allTree,this);if(arguments.length>1)this._ddronr=!convertStringToBoolean(b)}; dhtmlXTreeObject.prototype._setMove=function(a){if(a.parentObject.span){var b=getAbsoluteTop(a),c=getAbsoluteTop(this.allTree)-this.allTree.scrollTop;this.dadmodec=this.dadmode;this.dadmodefix=0;var d=a.parentObject.span;d.className+=" dragAndDropRow";this._lastMark=d;this._autoScroll(null,b,c)}}; dhtmlXTreeObject.prototype._autoScroll=function(a,b,c){if(this.autoScroll){a&&(b=getAbsoluteTop(a),c=getAbsoluteTop(this.allTree));if(b-c-parseInt(this.allTree.scrollTop)>parseInt(this.allTree.offsetHeight)-50)this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;if(b-c"+this._selected[e].span.innerHTML+ "";else f=this.getSelectedItemText().split(this.dlmtr);d.innerHTML=f.join("");d.style.position="absolute";d.className="dragSpanDiv";this._dragged=[].concat(this._selected);return d};dhtmlXTreeObject.prototype._focusNode=function(a){var b=getAbsoluteTop(a.htmlNode)-getAbsoluteTop(this.allTree);if(b>this.allTree.offsetHeight-30||b<0)this.allTree.scrollTop=b+this.allTree.scrollTop};dhtmlXTreeObject.prototype._preventNsDrag=function(a){a&&a.preventDefault&&a.preventDefault();return!1}; dhtmlXTreeObject.prototype._drag=function(a,b,c){this._autoOpenTimer&&clearTimeout(this._autoOpenTimer);if(!c.parentObject)c=this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.dadmodec=0;this._clearMove();var d=a.parentObject.treeNod;d&&d._clearMove&&d._clearMove("");if(!this.dragMove||this.dragMove())for(var f=!d||!d._clearMove||!d._dragged?Array(a.parentObject):d._dragged,e=c.parentObject,g=0;g2?c.checkstate-3:c.checkstate,this._setCheck(c),c.dscheck<3))c.dscheck=!1}; dhtmlXTreeObject.prototype.setEscapingMode=function(a){this.utfesc=a};dhtmlXTreeObject.prototype.enableHighlighting=function(a){this.ehlt=!0;this.ehlta=convertStringToBoolean(a)};dhtmlXTreeObject.prototype._itemMouseOut=function(){var a=this.childNodes[3].parentObject,b=a.treeNod;b.callEvent("onMouseOut",[a.id]);if(a.id==b._l_onMSI)b._l_onMSI=null;if(b.ehlta)a.span.className=a.span.className.replace("_lor","")}; dhtmlXTreeObject.prototype._itemMouseIn=function(){var a=this.childNodes[3].parentObject,b=a.treeNod;b._l_onMSI!=a.id&&b.callEvent("onMouseIn",[a.id]);b._l_onMSI=a.id;if(b.ehlta)a.span.className=a.span.className.replace("_lor",""),a.span.className=a.span.className.replace(/((standart|selected)TreeRow)/,"$1_lor")};dhtmlXTreeObject.prototype.enableActiveImages=function(a){this._aimgs=convertStringToBoolean(a)}; dhtmlXTreeObject.prototype.focusItem=function(a){var b=this._globalIdStorageFind(a);if(!b)return 0;this._focusNode(b)};dhtmlXTreeObject.prototype.getAllSubItems=function(a){return this._getAllSubItems(a)};dhtmlXTreeObject.prototype.getAllChildless=function(){return this._getAllScraggyItems(this.htmlNode)};dhtmlXTreeObject.prototype.getAllLeafs=dhtmlXTreeObject.prototype.getAllChildless; dhtmlXTreeObject.prototype._getAllScraggyItems=function(a){for(var b="",c=0;c0){var d=a.childNodes[c].unParsed?this._getAllScraggyItemsXML(a.childNodes[c].unParsed,1):this._getAllScraggyItems(a.childNodes[c]);d&&(b?b+=this.dlmtr+d:b=d)}else b?b+=this.dlmtr+a.childNodes[c].id:b=a.childNodes[c].id;return b}; dhtmlXTreeObject.prototype._getAllFatItems=function(a){for(var b="",c=0;c0){b?b+=this.dlmtr+a.childNodes[c].id:b=a.childNodes[c].id;var d=a.childNodes[c].unParsed?this._getAllFatItemsXML(a.childNodes[c].unParsed,1):this._getAllFatItems(a.childNodes[c]);d&&(b+=this.dlmtr+d)}return b};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(a){a&&(a=this._globalIdStorageFind(a));return this._getAllChecked(a,"",0)};dhtmlXTreeObject.prototype.getAllPartiallyChecked=function(){return this._getAllChecked("","",2)}; dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){var a=[this._getAllChecked("","",1)],b=this._getAllChecked("","",2);b&&a.push(b);return a.join(this.dlmtr)};dhtmlXTreeObject.prototype._getAllChecked=function(a,b,c){if(!a)a=this.htmlNode;if(a.checkstate==c&&!a.nocheckbox)b?b+=this.dlmtr+a.id:b=a.id;for(var d=a.childsCount,f=0;f