From 11ce7b455d4c78699de6dde4ff0c1024f9b73f84 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 20 Mar 2006 19:13:15 +0000 Subject: [PATCH] fix from DHTMLx Team modified by me to fix the wrong alignment of open folders in Konqueror --- phpgwapi/js/dhtmlxtree/doc/dhtmlXCommon.js | 86 +++++++++++++++++---- phpgwapi/js/dhtmlxtree/doc/dhtmlXTree.js | 19 +++-- phpgwapi/js/dhtmlxtree/js/dhtmlXCommon.js | 82 ++++++++++++++++++-- phpgwapi/js/dhtmlxtree/js/dhtmlXTree.js | 17 ++++- phpgwapi/js/dhtmlxtree/src/dhtmlXCommon.js | 87 ++++++++++++++++++---- phpgwapi/js/dhtmlxtree/src/dhtmlXTree.js | 10 ++- 6 files changed, 251 insertions(+), 50 deletions(-) diff --git a/phpgwapi/js/dhtmlxtree/doc/dhtmlXCommon.js b/phpgwapi/js/dhtmlxtree/doc/dhtmlXCommon.js index 20a70de59d..c688716410 100644 --- a/phpgwapi/js/dhtmlxtree/doc/dhtmlXCommon.js +++ b/phpgwapi/js/dhtmlxtree/doc/dhtmlXCommon.js @@ -1,7 +1,3 @@ -/* -Copyright Scand LLC http://www.scbr.com -This version of Software is free for using in non-commercial applications. For commercial use please contact info@scbr.com to obtain license -*/ /** * @desc: xmlLoader object * @type: private @@ -26,12 +22,12 @@ function dtmlXMLLoaderObject(funcObject, dhtmlObject,async){ * @topic: 0 */ dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){ - this.check=function (){ + this.check=function (){ if(dhtmlObject.onloadAction!=null){ if (!dhtmlObject.xmlDoc.readyState) dhtmlObject.onloadAction(dhtmlObject.mainObject); - else { + else { if (dhtmlObject.xmlDoc.readyState != 4) return false; - else dhtmlObject.onloadAction(dhtmlObject.mainObject); } + else dhtmlObject.onloadAction(dhtmlObject.mainObject,null,null,null,dhtmlObject); } } }; return this.check; @@ -48,16 +44,16 @@ function dtmlXMLLoaderObject(funcObject, dhtmlObject,async){ if (this.xmlDoc.responseXML) { var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName); var z=temp[0]; } else var z=this.xmlDoc.documentElement; if (z) return z; - alert("Incorrect XML"); + dhtmlxError.throwError("LoadXML","Incorrect XML",[this.xmlDoc]) return document.createElement("DIV"); }; - /** + /** * @desc: load XML * @type: private * @param: filePath - xml file path * @topic: 0 - */ + */ dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){ try { @@ -342,9 +338,17 @@ function dhtmlDragAndDropObject(){ window.frames[i].dhtmlDragAndDrop.initFrameRoute(window,((!win||mode)?1:0)); } - +var _isFF=false; var _isIE=false; var _isOpera=false; var _isSafari=false; +if (navigator.userAgent.indexOf('Safari') != -1 || navigator.userAgent.indexOf('Konqueror') != -1) + _isSafari=true; +else if (navigator.userAgent.indexOf('Opera') != -1) + _isOpera=true; +else if(navigator.appName.indexOf("Microsoft")!=-1) + _isIE=true; +else _isFF=true; +//deprecated, use global constant instead //determines if current browser is IE function isIE(){ if(navigator.appName.indexOf("Microsoft")!=-1) @@ -355,6 +359,7 @@ function isIE(){ //multibrowser Xpath processor dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){ + if ((_isOpera)||(_isSafari)) return this.doXPathOpera(xpathExp,docObj); if(isIE()){//IE if(arguments.length==1){ docObj = this.xmlDoc @@ -374,7 +379,7 @@ dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){ }else{ nodeObj = docObj; docObj = docObj.ownerDocument; - + } var rowsCol = new Array(); var col = docObj.evaluate(xpathExp, nodeObj, null, XPathResult.ANY_TYPE,null); @@ -386,8 +391,8 @@ dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){ return rowsCol; } } - -if ( window.Node ) + +if (( window.Node )&&(!_isSafari)) Node.prototype.removeNode = function( removeChildren ) { var self = this; @@ -403,3 +408,56 @@ Node.prototype.removeNode = function( removeChildren ) } } +function _dhtmlxError(type,name,params){ + if (!this.catches) + this.catches=new Array(); + + return this; +} + +_dhtmlxError.prototype.catchError=function(type,func_name){ + this.catches[type]=func_name; +} +_dhtmlxError.prototype.throwError=function(type,name,params){ + if (this.catches[type]) return this.catches[type](type,name,params); + if (this.catches["ALL"]) return this.catches["ALL"](type,name,params); + alert("Error type: " + arguments[0]+"\nDescription: " + arguments[1] ); + return null; +} + +window.dhtmlxError=new _dhtmlxError(); + + +//opera fake, while 9.0 not released +//multibrowser Xpath processor +dtmlXMLLoaderObject.prototype.doXPathOpera = function(xpathExp,docObj){ + //this is fake for Opera + var z=xpathExp.replace(/[\/]+/gi,"/").split('/'); + var obj=null; + var i=1; + + if (!z.length) return []; + if (z[0]==".") + obj=[docObj]; + else if (z[0]=="") + { + obj=this.xmlDoc.responseXML.getElementsByTagName(z[i]); + i++; + } + else return []; + + for (i; i