diff --git a/phpgwapi/js/dhtmlxtree/sources/dhtmlxtree.js b/phpgwapi/js/dhtmlxtree/sources/dhtmlxtree.js index 2c695af1b5..08f3511f37 100644 --- a/phpgwapi/js/dhtmlxtree/sources/dhtmlxtree.js +++ b/phpgwapi/js/dhtmlxtree/sources/dhtmlxtree.js @@ -1,3846 +1,3878 @@ //v.3.6 build 131023 -/* -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 +/* +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 +*/ +/*_TOPICS_ +@0:Initialization +@1:Selection control +@2:Add/delete +@3:Private +@4:Node/level control +@5:Checkboxes/user data manipulation +@6:Appearence control +@7: Handlers */ -/*_TOPICS_ -@0:Initialization -@1:Selection control -@2:Add/delete -@3:Private -@4:Node/level control -@5:Checkboxes/user data manipulation -@6:Appearence control -@7: Handlers -*/ - -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:""; }, // <4k in FF - 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&&(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; -}; - - + if (this._datamode && this._datamode!="xml") return this["load"+this._datamode.toUpperCase()](file,afterCall); + var that=this; + if (!this.parsCount) this.callEvent("onXLS",[that,this._ld_id]); + this._ld_id=null; + this.xmlstate=1; + this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe); - -/** -* @desc: create new node as a child to specified with parentId -* @type: deprecated -* @param: parentId - parent node id -* @param: itemId - new node id -* @param: itemText - new node text -* @param: itemActionHandler - function fired on node select event (optional) -* @param: image1 - image for node without children; (optional) -* @param: image2 - image for closed node; (optional) -* @param: image3 - image for opened node (optional) -* @param: optionStr - options string (optional) -* @param: children - node children flag (for dynamical trees) (optional) -* @topic: 2 -*/ - 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); - if(!this._idpull[this.rootId].XMLload) - this._idpull[this.rootId].XMLload = 1; + if (afterCall) this.XMLLoader.waitCall=afterCall; + this.XMLLoader.loadXML(file); + }; +/** +* @desc: create new child node +* @type: private +* @param: parentObject - parent node object +* @param: itemId - new node id +* @param: itemText - new node text +* @param: itemActionHandler - function fired on node select event +* @param: image1 - image for node without children; +* @param: image2 - image for closed node; +* @param: image3 - image for opened node +* @param: optionStr - string of otions +* @param: childs - node childs flag (for dynamical trees) (optional) +* @param: beforeNode - node, after which new node will be inserted (optional) +* @topic: 2 +*/ + dhtmlXTreeObject.prototype._attachChildNode=function(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,beforeNode,afterNode){ - return nodez; - }; -/** -* @desc: create new node as a child to specified with parentId -* @type: public -* @param: parentId - parent node id -* @param: itemId - new node id -* @param: itemText - new node label -* @param: itemActionHandler - function fired on node select event (optional) -* @param: image1 - image for node without children; (optional) -* @param: image2 - image for closed node; (optional) -* @param: image3 - image for opened node (optional) -* @param: optionStr - options string (optional) -* @param: children - node children flag (for dynamical trees) (optional) -* @topic: 2 -*/ - 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); - } -/** -* @desc: parse xml -* @type: private -* @param: dhtmlObject - jsTree object -* @param: node - top XML node -* @param: parentId - parent node id -* @param: level - level of tree -* @topic: 2 -*/ - 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; - } - + if (beforeNode && beforeNode.parentObject) parentObject=beforeNode.parentObject; + if (((parentObject.XMLload==0)&&(this.XMLsource))&&(!this.XMLloadingWarning)) + { + parentObject.XMLload=1; + this._loadDynXML(parentObject.id); - - - - - 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,a.child); - 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); - a.id = newNode.id; - 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.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; //disable item locking - //loading flags - - - if (!parentId) { //top level - parentId=p.get("id"); - var skey = p.get("dhx_security"); - if (skey) - dhtmlx.security_key = skey; - - 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=0;//temp.childNodes[temp.childsCount-1]; - else - var preNode=0; - - this.npl=0; - - p.each("item",function(c,i){ - - temp.XMLload=1; - - this._parseItem(c,temp,0,preNode); - + var Count=parentObject.childsCount; + var Nodes=parentObject.childNodes; - 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; 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 Nodes=itemObject.htmlNode.childNodes[0].childNodes; var Count=Nodes.length; - if (Count>1){ - if ( ( (Nodes[1].style.display!="none") || (mode==1) ) && (mode!=2) ) { -//nb:solves standard doctype prb in IE - this.allTree.childNodes[0].border = "1"; - this.allTree.childNodes[0].border = "0"; - nodestyle="none"; - } - else nodestyle=""; - - for (var i=1; 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; +}; + + + + +/** +* @desc: create new node as a child to specified with parentId +* @type: deprecated +* @param: parentId - parent node id +* @param: itemId - new node id +* @param: itemText - new node text +* @param: itemActionHandler - function fired on node select event (optional) +* @param: image1 - image for node without children; (optional) +* @param: image2 - image for closed node; (optional) +* @param: image3 - image for opened node (optional) +* @param: optionStr - options string (optional) +* @param: children - node children flag (for dynamical trees) (optional) +* @topic: 2 +*/ + 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); + if(!this._idpull[this.rootId].XMLload) + this._idpull[this.rootId].XMLload = 1; + + return nodez; + }; +/** +* @desc: create new node as a child to specified with parentId +* @type: public +* @param: parentId - parent node id +* @param: itemId - new node id +* @param: itemText - new node label +* @param: itemActionHandler - function fired on node select event (optional) +* @param: image1 - image for node without children; (optional) +* @param: image2 - image for closed node; (optional) +* @param: image3 - image for opened node (optional) +* @param: optionStr - options string (optional) +* @param: children - node children flag (for dynamical trees) (optional) +* @topic: 2 +*/ + 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); + } +/** +* @desc: parse xml +* @type: private +* @param: dhtmlObject - jsTree object +* @param: node - top XML node +* @param: parentId - parent node id +* @param: level - level of tree +* @topic: 2 +*/ + 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,a.child); + 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); + a.id = newNode.id; + 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.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; //disable item locking + //loading flags + + + if (!parentId) { //top level + parentId=p.get("id"); + var skey = p.get("dhx_security"); + if (skey) + dhtmlx.security_key = skey; + + 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=0;//temp.childNodes[temp.childsCount-1]; + else + var preNode=0; + + this.npl=0; + + p.each("item",function(c,i){ + + temp.XMLload=1; + + this._parseItem(c,temp,0,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) ) { +//nb:solves standard doctype prb in IE + 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.appendChild(document.createTextNode(itemObject.label)); - 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")){//highlighting - tr.onmousemove=this._itemMouseIn; - tr[(_isIE)?"onmouseleave":"onmouseout"]=this._itemMouseOut; - } - return table; - }; - - -/** -* @desc: set path to images directory -* @param: newPath - path to images directory (related to the page with tree or absolute http url) -* @type: public -* @topic: 0 -*/ - dhtmlXTreeObject.prototype.setImagePath=function( newPath ){ this.imPath=newPath; this.iconURL=newPath; }; - /** - * @desc: set path to external images used as tree icons - * @type: public - * @param: path - url (or relative path) of images folder with closing "/" - * @topic: 0,7 - */ - dhtmlXTreeObject.prototype.setIconPath=function(path){ - this.iconURL=path; - } - - -/** -* @desc: set function called when tree node selected -* @param: (function) func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onRightClick -* @depricated: use grid.attachEvent("onRightClick",func); instead -* @eventdesc: Event occurs after right mouse button was clicked. - Assigning this handler can disable default context menu, and incompattible with dhtmlXMenu integration. -* @eventparam: (string) ID of clicked item -* @eventparam: (object) event object -*/ - dhtmlXTreeObject.prototype.setOnRightClickHandler=function(func){ this.attachEvent("onRightClick",func); }; - -/** -* @desc: set function called when tree node clicked, also can be forced to call from API -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onClick -* @depricated: use grid.attachEvent("onClick",func); instead -* @eventdesc: Event raises immideatly after text part of item in tree was clicked, but after default onClick functionality was processed. - Richt mouse button click can be catched by onRightClick event handler. -* @eventparam: ID of clicked item -* @eventparam: ID of previously selected item -*/ - dhtmlXTreeObject.prototype.setOnClickHandler=function(func){ this.attachEvent("onClick",func); }; - -/** -* @desc: set function called when tree node selected or unselected, include any select change caused by any functionality -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onSelect -* @depricated: use grid.attachEvent("onSelect",func); instead -* @eventdesc: Event raises immideatly after selection in tree was changed -* @eventparam: selected item ID ( list of IDs in case of multiselection) -*/ - dhtmlXTreeObject.prototype.setOnSelectStateChange=function(func){ this.attachEvent("onSelect",func); }; - - -/** -* @desc: enables dynamic loading from XML -* @type: public -* @param: filePath - name of script returning XML; in case of virtual loading - user defined function -* @topic: 0 -*/ - dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){ this.XMLsource=filePath; }; - - /** -* @desc: set function called before checkbox checked/unchecked -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onCheck -* @depricated: use tree.attachEvent("onCheck",func); instead -* @eventdesc: Event raises right before item in tree was checked/unchecked. can be canceled (return false from event handler) -* @eventparam: ID of item which will be checked/unchecked -* @eventparam: Current checkbox state. 1 - item checked, 0 - item unchecked. -* @eventreturn: true - confirm changing checked state; false - deny chaning checked state; -*/ - dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){ this.attachEvent("onCheck",func); }; - - -/** -* @desc: set function called before tree node opened/closed -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onOpen -* @depricated: use grid.attachEvent("onOpenStart",func); instead -* @eventdesc: Event raises immideatly after item in tree got command to open/close , and before item was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored. - Event does not occur if node was opened by dhtmlXtree API. -* @eventparam: ID of node which will be opened/closed -* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened. -* @eventreturn: true - confirm opening/closing; false - deny opening/closing; -*/ - dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){ this.attachEvent("onOpenStart",func); }; -/** -* @desc: set function called before tree node opened/closed -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onOpenStart -* @depricated: use grid.attachEvent("onOpenStart",func); instead -* @eventdesc: Event raises immideatly after item in tree got command to open/close , and before item was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored. - Event not raised if node opened by dhtmlXtree API. -* @eventparam: ID of node which will be opened/closed -* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened. -* @eventreturn: true - confirm opening/closing; false - deny opening/closing; -*/ - dhtmlXTreeObject.prototype.setOnOpenStartHandler=function(func){ this.attachEvent("onOpenStart",func); }; - -/** -* @desc: set function called after tree node opened/closed -* @param: func - event handling function -* @type: deprecated -* @topic: 0,7 -* @event: onOpenEnd -* @depricated: use grid.attachEvent("onOpenEnd",func); instead -* @eventdesc: Event raises immideatly after item in tree was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored. - Event not raised if node opened by dhtmlXtree API. -* @eventparam: ID of node which will be opened/closed -* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened. -*/ - dhtmlXTreeObject.prototype.setOnOpenEndHandler=function(func){ this.attachEvent("onOpenEnd",func); }; - - /** -* @desc: set function called when tree node double clicked -* @param: func - event handling function -* @type: public -* @topic: 0,7 -* @event: onDblClick -* @depricated: use grid.attachEvent("onDblClick",func); instead -* @eventdesc: Event raised immideatly after item in tree was doubleclicked, before default onDblClick functionality was processed. - Beware using both onClick and onDblClick events, because component can generate onClick event before onDblClick event while doubleclicking item in tree. - ( that behavior depend on used browser ) -* @eventparam: ID of item which was doubleclicked -* @eventreturn: true - confirm opening/closing; false - deny opening/closing; -*/ - dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){ this.attachEvent("onDblClick",func); }; - - - - - - - - - - /** -* @desc: expand target node and all sub nodes -* @type: public -* @param: itemId - node id -* @topic: 4 -*/ - dhtmlXTreeObject.prototype.openAllItems=function(itemId) - { - var temp=this._globalIdStorageFind(itemId); - if (!temp) return 0; - this._xopenAll(temp); - }; - -/** -* @desc: return open/close state -* @type: public -* @param: itemId - node id -* @return: -1 - close, 1 - opened, 0 - node doesn't have children -* @topic: 4 -*/ - dhtmlXTreeObject.prototype.getOpenState=function(itemId){ - var temp=this._globalIdStorageFind(itemId); - if (!temp) return ""; - return this._getOpenState(temp); - }; - -/** -* @desc: collapse target node and all sub nodes -* @type: public -* @param: itemId - node id -* @topic: 4 -*/ - dhtmlXTreeObject.prototype.closeAllItems=function(itemId) - { - if (itemId===window.undefined) itemId=this.rootId; - - var temp=this._globalIdStorageFind(itemId); - if (!temp) return 0; - this._xcloseAll(temp); - -//nb:solves standard doctype prb in IE - this.allTree.childNodes[0].border = "1"; - this.allTree.childNodes[0].border = "0"; - - }; - - -/** -* @desc: set user data for target node -* @type: public -* @param: itemId - target node id -* @param: name - key for user data -* @param: value - user data value -* @topic: 5 -*/ - 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; - }; - -/** -* @desc: get user data from target node -* @type: public -* @param: itemId - target node id -* @param: name - key for user data -* @return: value of user data -* @topic: 5 -*/ - dhtmlXTreeObject.prototype.getUserData=function(itemId,name){ - var sNode=this._globalIdStorageFind(itemId,0,true); - if (!sNode) return; - return sNode.userData["t_"+name]; - }; - - - - -/** -* @desc: get node color (text color) -* @param: itemId - id of node -* @type: public -* @return: color of node (empty string for default color); -* @topic: 6 -*/ - 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; - }; -/** -* @desc: set node text color -* @param: itemId - id of node -* @param: defaultColor - node color -* @param: selectedColor - selected node color -* @type: public -* @topic: 6 -*/ - 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; - } - }; - -/** -* @desc: return node text -* @param: itemId - id of node -* @type: public -* @return: text of item (with HTML formatting, if any) -* @topic: 6 -*/ - 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); - }; -/** -* @desc: return parent item id -* @param: itemId - id of node -* @type: public -* @return: id of parent item -* @topic: 4 -*/ - dhtmlXTreeObject.prototype.getParentId=function(itemId) - { - var temp=this._globalIdStorageFind(itemId); - if ((!temp)||(!temp.parentObject)) return ""; - return temp.parentObject.id; - }; - - - -/** -* @desc: change item id -* @type: public -* @param: itemId - old node id -* @param: newItemId - new node id -* @topic: 4 -*/ - 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]; - }; - - -/** -* @desc: mark selected item as cut -* @type: public -* @topic: 2 -*/ - 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]); - //this._correctLine(Nodes[targetObject.childsCount-1]); - - - if (this.tscheck) this._correctCheckStates(targetObject); - if (oldTree.tscheck) oldTree._correctCheckStates(z); - - } - - //fix source parent - - if (c>1) { oldTree._correctPlus(z.childNodes[c-2]); - oldTree._correctLine(z.childNodes[c-2]); - } - - -// if (z.childsCount==0) - oldTree._correctPlus(z); - oldTree._correctLine(z); - +/** +* @desc: visual unselect item in tree +* @type: private +* @param: node - tree item object +* @edition: Professional +* @topic: 0 +*/ + dhtmlXTreeObject.prototype._unselectItem=function(node){ + if ((node)&&(node.i_sel)) + { - this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]); - return itemObject.id; - }; - - - -/** -* @desc: recursive set default styles for node -* @type: private -* @param: itemObject - target node object -* @topic: 6 -*/ - dhtmlXTreeObject.prototype._clearStyles=function(itemObject){ - if (!itemObject.htmlNode) return; //some weird case in SRND mode - 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; i