4
Copyright DHTMLX LTD. http://www.dhtmlx.com
5
You allowed to use this component or parts of it under GPL terms
6
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
9
* @desc: xmlLoader object
11
* @param: funcObject - xml parser function
12
* @param: object - jsControl object
13
* @param: async - sync/async mode (async by default)
14
* @param: rSeed - enable/disable random seed ( prevent IE caching)
17
function dtmlXMLLoaderObject(funcObject, dhtmlObject,async,rSeed){
20
if (typeof(async) != "undefined")
22
else this.async = true;
24
this.onloadAction=funcObject||null;
25
this.mainObject=dhtmlObject||null;
27
this.rSeed=rSeed||false;
31
* @desc: xml loading handler
33
* @param: dtmlObject - xmlLoader object
36
dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){
38
this.check=function (){
39
if ((dhtmlObject)&&(dhtmlObject.onloadAction!=null)){
40
if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){
41
if (!once) return; once=false; //IE 5 fix
42
dhtmlObject.onloadAction(dhtmlObject.mainObject,null,null,null,dhtmlObject);
43
if (dhtmlObject.waitCall) { dhtmlObject.waitCall(); dhtmlObject.waitCall=null; }
51
* @desc: return XML top node
52
* @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla)
54
* @returns: top XML node
57
dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName,oldObj){
58
if (this.xmlDoc.responseXML) {
59
var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName);
62
var z=this.xmlDoc.documentElement;
68
if ((_isIE)&&(!this._retry)){
69
//fall back to MS.XMLDOM
70
var xmlString=this.xmlDoc.responseText;
71
var oldObj=this.xmlDoc;
73
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
74
this.xmlDoc.async=false;
75
this.xmlDoc["loadXM"+"L"](xmlString);
77
return this.getXMLTopNode(tagName,oldObj);
79
dhtmlxError.throwError("LoadXML","Incorrect XML",[(oldObj||this.xmlDoc),this.mainObject]);
80
return document.createElement("DIV");
84
* @desc: load XML from string
86
* @param: xmlString - xml string
89
dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){
92
var z=document.createElement('div');
93
z.innerHTML = xmlString;
101
var parser = new DOMParser();
102
this.xmlDoc = parser.parseFromString(xmlString,"text/xml");
105
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
106
this.xmlDoc.async=this.async;
107
this.xmlDoc["loadXM"+"L"](xmlString);
111
this.onloadAction(this.mainObject,null,null,null,this);
112
if (this.waitCall) { this.waitCall(); this.waitCall=null; }
117
* @param: filePath - xml file path
118
* @param: postMode - send POST request
119
* @param: postVars - list of vars for post request
122
dtmlXMLLoaderObject.prototype.loadXML=function(filePath,postMode,postVars,rpc){
123
if (this.rSeed) filePath+=((filePath.indexOf("?")!=-1)?"&":"?")+"a_dhx_rSeed="+(new Date()).valueOf();
124
this.filePath=filePath;
126
if ((!_isIE)&&(window.XMLHttpRequest))
127
this.xmlDoc = new XMLHttpRequest();
130
if (document.implementation && document.implementation.createDocument)
132
this.xmlDoc = document.implementation.createDocument("", "", null);
133
this.xmlDoc.onload = new this.waitLoadFunction(this);
134
this.xmlDoc.load(filePath);
138
this.xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
143
this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);
145
this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 (" + navigator.userAgent + ")");
146
this.xmlDoc.setRequestHeader("Content-type", "text/xml");
148
if (postMode) this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');
149
this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
150
this.xmlDoc.send(null||postVars);
154
* @desc: destructor, cleans used memory
158
dtmlXMLLoaderObject.prototype.destructor=function(){
159
this.onloadAction=null;
160
this.mainObject=null;
166
* @desc: Call wrapper
168
* @param: funcObject - action handler
169
* @param: dhtmlObject - user data
170
* @returns: function handler
173
function callerFunction(funcObject,dhtmlObject){
174
this.handler=function(e){
175
if (!e) e=window.event;
176
funcObject(e,dhtmlObject);
183
* @desc: Calculate absolute position of html object
185
* @param: htmlObject - html object
188
function getAbsoluteLeft(htmlObject){
189
var xPos = htmlObject.offsetLeft;
190
var temp = htmlObject.offsetParent;
191
while (temp != null) {
192
xPos += temp.offsetLeft;
193
temp = temp.offsetParent;
198
* @desc: Calculate absolute position of html object
200
* @param: htmlObject - html object
203
function getAbsoluteTop(htmlObject) {
204
var yPos = htmlObject.offsetTop;
205
var temp = htmlObject.offsetParent;
206
while (temp != null) {
207
yPos += temp.offsetTop;
208
temp = temp.offsetParent;
215
* @desc: Convert string to it boolean representation
217
* @param: inputString - string for covertion
220
function convertStringToBoolean(inputString){ if (typeof(inputString)=="string") inputString=inputString.toLowerCase();
230
default: return false;
235
* @desc: find out what symbol to use as url param delimiters in further params
237
* @param: str - current url string
240
function getUrlSymbol(str){
241
if(str.indexOf("?")!=-1)
248
function dhtmlDragAndDropObject(){
249
if (window.dhtmlDragAndDrop) return window.dhtmlDragAndDrop;
252
this.dragStartNode=0;
253
this.dragStartObject=0;
257
window.dhtmlDragAndDrop=this;
262
dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
263
htmlNode.onmousedown=null;
264
htmlNode.dragStarter=null;
265
htmlNode.dragLanding=null;
267
dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode,dhtmlObject){
268
htmlNode.onmousedown=this.preCreateDragCopy;
269
htmlNode.dragStarter=dhtmlObject;
270
this.addDragLanding(htmlNode,dhtmlObject);
272
dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode,dhtmlObject){
273
htmlNode.dragLanding=dhtmlObject;
275
dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e)
277
if (window.dhtmlDragAndDrop.waitDrag) {
278
window.dhtmlDragAndDrop.waitDrag=0;
279
document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
280
document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
284
window.dhtmlDragAndDrop.waitDrag=1;
285
window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
286
window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
287
window.dhtmlDragAndDrop.dragStartNode=this;
288
window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
289
document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
290
document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
292
if ((e)&&(e.preventDefault)) { e.preventDefault(); return false; }
295
dhtmlDragAndDropObject.prototype.callDrag=function(e){
296
if (!e) e=window.event;
297
dragger=window.dhtmlDragAndDrop;
299
if ((e.button==0)&&(_isIE)) return dragger.stopDrag();
300
if (!dragger.dragNode) {
301
dragger.dragNode=dragger.dragStartObject._createDragNode(dragger.dragStartNode,e);
302
if (!dragger.dragNode) return dragger.stopDrag();
303
dragger.gldragNode=dragger.dragNode;
304
document.body.appendChild(dragger.dragNode);
305
document.body.onmouseup=dragger.stopDrag;
307
dragger.dragNode.pWindow=window;
308
dragger.initFrameRoute();
312
if (dragger.dragNode.parentNode!=window.document.body){
313
var grd=dragger.gldragNode;
314
if (dragger.gldragNode.old) grd=dragger.gldragNode.old;
316
//if (!document.all) dragger.calculateFramePosition();
317
grd.parentNode.removeChild(grd);
318
var oldBody=dragger.dragNode.pWindow;
319
// var oldp=dragger.dragNode.parentObject;
321
var div=document.createElement("Div");
322
div.innerHTML=dragger.dragNode.outerHTML;
323
dragger.dragNode=div.childNodes[0]; }
324
else dragger.dragNode=dragger.dragNode.cloneNode(true);
326
dragger.dragNode.pWindow=window;
327
// dragger.dragNode.parentObject=oldp;
329
dragger.gldragNode.old=dragger.dragNode;
330
document.body.appendChild(dragger.dragNode);
331
oldBody.dhtmlDragAndDrop.dragNode=dragger.dragNode;
334
dragger.dragNode.style.left=e.clientX+15+(dragger.fx?dragger.fx*(-1):0)+(document.body.scrollLeft||document.documentElement.scrollLeft)+"px";
335
dragger.dragNode.style.top=e.clientY+3+(dragger.fy?dragger.fy*(-1):0)+(document.body.scrollTop||document.documentElement.scrollTop)+"px";
336
if (!e.srcElement) var z=e.target; else z=e.srcElement;
337
dragger.checkLanding(z,e);
340
dhtmlDragAndDropObject.prototype.calculateFramePosition=function(n){
341
//this.fx = 0, this.fy = 0;
343
var el =parent.frames[window.name].frameElement.offsetParent;
346
while (el) { fx += el.offsetLeft; fy += el.offsetTop; el = el.offsetParent; }
347
if ((parent.dhtmlDragAndDrop)) { var ls=parent.dhtmlDragAndDrop.calculateFramePosition(1); fx+=ls.split('_')[0]*1; fy+=ls.split('_')[1]*1; }
348
if (n) return fx+"_"+fy;
349
else this.fx=fx; this.fy=fy;
353
dhtmlDragAndDropObject.prototype.checkLanding=function(htmlObject,e){
355
if ((htmlObject)&&(htmlObject.dragLanding)) {
356
if (this.lastLanding)
357
this.lastLanding.dragLanding._dragOut(this.lastLanding);
358
this.lastLanding=htmlObject;
359
this.lastLanding=this.lastLanding.dragLanding._dragIn(this.lastLanding,this.dragStartNode,e.clientX, e.clientY,e);
360
this.lastLanding_scr=(_isIE?e.srcElement:e.target);
363
if ((htmlObject)&&(htmlObject.tagName!="BODY")) this.checkLanding(htmlObject.parentNode,e);
365
if (this.lastLanding) this.lastLanding.dragLanding._dragOut(this.lastLanding,e.clientX, e.clientY,e); this.lastLanding=0;
366
if (this._onNotFound) this._onNotFound();
370
dhtmlDragAndDropObject.prototype.stopDrag=function(e,mode){
371
dragger=window.dhtmlDragAndDrop;
374
dragger.stopFrameRoute();
375
var temp=dragger.lastLanding;
376
dragger.lastLanding=null;
377
if (temp) temp.dragLanding._drag(dragger.dragStartNode,dragger.dragStartObject,temp,(_isIE?event.srcElement:e.target));
379
dragger.lastLanding=null;
380
if ((dragger.dragNode)&&(dragger.dragNode.parentNode==document.body)) dragger.dragNode.parentNode.removeChild(dragger.dragNode);
382
dragger.gldragNode=0;
385
dragger.dragStartNode=0;
386
dragger.dragStartObject=0;
387
document.body.onmouseup=dragger.tempDOMU;
388
document.body.onmousemove=dragger.tempDOMM;
389
dragger.tempDOMU=null;
390
dragger.tempDOMM=null;
394
dhtmlDragAndDropObject.prototype.stopFrameRoute=function(win){
396
window.dhtmlDragAndDrop.stopDrag(1,1);
398
for (var i=0; i<window.frames.length; i++)
399
if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
400
window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
401
if ((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win))
402
parent.dhtmlDragAndDrop.stopFrameRoute(window);
404
dhtmlDragAndDropObject.prototype.initFrameRoute=function(win,mode){
408
window.dhtmlDragAndDrop.preCreateDragCopy();
409
window.dhtmlDragAndDrop.dragStartNode=win.dhtmlDragAndDrop.dragStartNode;
410
window.dhtmlDragAndDrop.dragStartObject=win.dhtmlDragAndDrop.dragStartObject;
411
window.dhtmlDragAndDrop.dragNode=win.dhtmlDragAndDrop.dragNode;
412
window.dhtmlDragAndDrop.gldragNode=win.dhtmlDragAndDrop.dragNode;
413
window.document.body.onmouseup=window.dhtmlDragAndDrop.stopDrag;
415
if (((!_isIE)&&(mode))&&((!_isFF)||(_FFrv<1.8)))
416
window.dhtmlDragAndDrop.calculateFramePosition();
418
if ((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win))
419
parent.dhtmlDragAndDrop.initFrameRoute(window);
420
for (var i=0; i<window.frames.length; i++)
421
if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
422
window.frames[i].dhtmlDragAndDrop.initFrameRoute(window,((!win||mode)?1:0));
426
var _isFF=false; var _isIE=false; var _isOpera=false; var _isKHTML=false; var _isMacOS=false;
428
if (navigator.userAgent.indexOf('Macintosh') != -1) _isMacOS=true;
429
if ((navigator.userAgent.indexOf('Safari') != -1)||(navigator.userAgent.indexOf('Konqueror')!= -1))
431
else if (navigator.userAgent.indexOf('Opera') != -1){
433
_OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6,3));
435
else if(navigator.appName.indexOf("Microsoft")!=-1)
439
var _FFrv=parseFloat(navigator.userAgent.split("rv:")[1])
442
//deprecated, use global constant instead
443
//determines if current browser is IE
445
if(navigator.appName.indexOf("Microsoft")!=-1)
446
if (navigator.userAgent.indexOf('Opera') == -1)
451
//multibrowser Xpath processor
452
dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){
453
if ((_isOpera)||(_isKHTML)) return this.doXPathOpera(xpathExp,docObj);
456
if(!this.xmlDoc.nodeName)
457
docObj = this.xmlDoc.responseXML
459
docObj = this.xmlDoc;
460
return docObj.selectNodes(xpathExp);
462
var nodeObj = docObj;
464
if(!this.xmlDoc.nodeName){
465
docObj = this.xmlDoc.responseXML
467
docObj = this.xmlDoc;
470
if(docObj.nodeName.indexOf("document")!=-1){
474
docObj = docObj.ownerDocument;
477
var rowsCol = new Array();
478
var col = docObj.evaluate(xpathExp, nodeObj, null, XPathResult.ANY_TYPE,null);
479
var thisColMemb = col.iterateNext();
480
while (thisColMemb) {
481
rowsCol[rowsCol.length] = thisColMemb;
482
thisColMemb = col.iterateNext();
489
function _dhtmlxError(type,name,params){
491
this.catches=new Array();
496
_dhtmlxError.prototype.catchError=function(type,func_name){
497
this.catches[type]=func_name;
499
_dhtmlxError.prototype.throwError=function(type,name,params){
500
if (this.catches[type]) return this.catches[type](type,name,params);
501
if (this.catches["ALL"]) return this.catches["ALL"](type,name,params);
502
alert("Error type: " + arguments[0]+"\nDescription: " + arguments[1] );
506
window.dhtmlxError=new _dhtmlxError();
509
//opera fake, while 9.0 not released
510
//multibrowser Xpath processor
511
dtmlXMLLoaderObject.prototype.doXPathOpera = function(xpathExp,docObj){
512
//this is fake for Opera
513
var z=xpathExp.replace(/[\/]+/gi,"/").split('/');
517
if (!z.length) return [];
522
obj=this.xmlDoc.responseXML.getElementsByTagName(z[i].replace(/\[[^\]]*\]/g,""));
527
for (i; i<z.length; i++)
528
obj=this._getAllNamedChilds(obj,z[i]);
530
if (z[i-1].indexOf("[")!=-1)
531
obj=this._filterXPath(obj,z[i-1]);
535
dtmlXMLLoaderObject.prototype._filterXPath = function(a,b){
537
var b=b.replace(/[^\[]*\[\@/g,"").replace(/[\[\]\@]*/g,"");
538
for (var i=0; i<a.length; i++)
539
if (a[i].getAttribute(b))
544
dtmlXMLLoaderObject.prototype._getAllNamedChilds = function(a,b){
546
if (_isKHTML) b=b.toUpperCase();
547
for (var i=0; i<a.length; i++)
548
for (var j=0; j<a[i].childNodes.length; j++){
550
if (a[i].childNodes[j].tagName && a[i].childNodes[j].tagName.toUpperCase()==b)
551
c[c.length]=a[i].childNodes[j];
554
if (a[i].childNodes[j].tagName==b) c[c.length]=a[i].childNodes[j];
560
function dhtmlXHeir(a,b){
562
if (typeof(b[c])=="function") a[c]=b[c];
565
function dhtmlxEvent(el,event,handler){
566
if (el.addEventListener)
567
el.addEventListener(event,handler,false);
568
else if (el.attachEvent)
569
el.attachEvent("on"+event,handler);
572
//(c)dhtmlx ltd. www.dhtmlx.com
4
Copyright DHTMLX LTD. http://www.dhtmlx.com
5
You allowed to use this component or parts of it under GPL terms
6
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
9
get:function(url,callback){
10
var t=new dtmlXMLLoaderObject(true);
11
t.async=(arguments.length<3);
16
post:function(url,post,callback){
17
var t=new dtmlXMLLoaderObject(true);
18
t.async=(arguments.length<4);
20
t.loadXML(url,true,post)
23
getSync:function(url){
24
return this.get(url,null,true)
26
postSync:function(url,post){
27
return this.post(url,post,null,true);
32
* @desc: xmlLoader object
34
* @param: funcObject - xml parser function
35
* @param: object - jsControl object
36
* @param: async - sync/async mode (async by default)
37
* @param: rSeed - enable/disable random seed ( prevent IE caching)
40
function dtmlXMLLoaderObject(funcObject, dhtmlObject, async, rSeed){
43
if (typeof (async) != "undefined")
48
this.onloadAction=funcObject||null;
49
this.mainObject=dhtmlObject||null;
51
this.rSeed=rSeed||false;
55
* @desc: xml loading handler
57
* @param: dtmlObject - xmlLoader object
60
dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){
62
this.check=function (){
63
if ((dhtmlObject)&&(dhtmlObject.onloadAction != null)){
64
if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){
68
once=false; //IE 5 fix
69
if (typeof dhtmlObject.onloadAction == "function")
70
dhtmlObject.onloadAction(dhtmlObject.mainObject, null, null, null, dhtmlObject);
72
if (dhtmlObject.waitCall){
73
dhtmlObject.waitCall.call(this,dhtmlObject);
74
dhtmlObject.waitCall=null;
83
* @desc: return XML top node
84
* @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla)
86
* @returns: top XML node
89
dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName, oldObj){
90
if (this.xmlDoc.responseXML){
91
var temp = this.xmlDoc.responseXML.getElementsByTagName(tagName);
92
if(temp.length==0 && tagName.indexOf(":")!=-1)
93
var temp = this.xmlDoc.responseXML.getElementsByTagName((tagName.split(":"))[1]);
96
var z = this.xmlDoc.documentElement;
103
if ((_isIE)&&(!this._retry)){
104
//fall back to MS.XMLDOM
105
var xmlString = this.xmlDoc.responseText;
106
var oldObj = this.xmlDoc;
108
this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
109
this.xmlDoc.async=false;
110
this.xmlDoc["loadXM"+"L"](xmlString);
112
return this.getXMLTopNode(tagName, oldObj);
114
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
115
(oldObj||this.xmlDoc),
119
return document.createElement("DIV");
123
* @desc: load XML from string
125
* @param: xmlString - xml string
128
dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){
131
var parser = new DOMParser();
132
this.xmlDoc=parser.parseFromString(xmlString, "text/xml");
135
this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
136
this.xmlDoc.async=this.async;
137
this.xmlDoc["loadXM"+"L"](xmlString);
141
this.onloadAction(this.mainObject, null, null, null, this);
151
* @param: filePath - xml file path
152
* @param: postMode - send POST request
153
* @param: postVars - list of vars for post request
156
dtmlXMLLoaderObject.prototype.loadXML=function(filePath, postMode, postVars, rpc){
158
filePath+=((filePath.indexOf("?") != -1) ? "&" : "?")+"a_dhx_rSeed="+(new Date()).valueOf();
159
this.filePath=filePath;
161
if ((!_isIE)&&(window.XMLHttpRequest))
162
this.xmlDoc=new XMLHttpRequest();
164
if (document.implementation&&document.implementation.createDocument){
165
this.xmlDoc=document.implementation.createDocument("", "", null);
166
this.xmlDoc.onload=new this.waitLoadFunction(this);
167
this.xmlDoc.load(filePath);
170
this.xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
174
this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
175
this.xmlDoc.open(postMode ? "POST" : "GET", filePath, this.async);
178
this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 ("+navigator.userAgent+")");
179
this.xmlDoc.setRequestHeader("Content-type", "text/xml");
183
this.xmlDoc.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
185
this.xmlDoc.setRequestHeader("X-Requested-With","XMLHttpRequest");
186
this.xmlDoc.send(null||postVars);
189
(new this.waitLoadFunction(this))();
192
* @desc: destructor, cleans used memory
196
dtmlXMLLoaderObject.prototype.destructor=function(){
197
this.onloadAction=null;
198
this.mainObject=null;
203
dtmlXMLLoaderObject.prototype.xmlNodeToJSON = function(node){
205
for (var i=0; i<node.attributes.length; i++)
206
t[node.attributes[i].name]=node.attributes[i].value;
207
t["_tagvalue"]=node.firstChild?node.firstChild.nodeValue:"";
208
for (var i=0; i<node.childNodes.length; i++){
209
var name=node.childNodes[i].tagName;
211
if (!t[name]) t[name]=[];
212
t[name].push(this.xmlNodeToJSON(node.childNodes[i]));
219
* @desc: Call wrapper
221
* @param: funcObject - action handler
222
* @param: dhtmlObject - user data
223
* @returns: function handler
226
function callerFunction(funcObject, dhtmlObject){
227
this.handler=function(e){
230
funcObject(e, dhtmlObject);
237
* @desc: Calculate absolute position of html object
239
* @param: htmlObject - html object
242
function getAbsoluteLeft(htmlObject){
243
var xPos = htmlObject.offsetLeft;
244
var temp = htmlObject.offsetParent;
246
while (temp != null){
247
xPos+=temp.offsetLeft;
248
temp=temp.offsetParent;
253
* @desc: Calculate absolute position of html object
255
* @param: htmlObject - html object
258
function getAbsoluteTop(htmlObject){
259
var yPos = htmlObject.offsetTop;
260
var temp = htmlObject.offsetParent;
262
while (temp != null){
263
yPos+=temp.offsetTop;
264
temp=temp.offsetParent;
271
* @desc: Convert string to it boolean representation
273
* @param: inputString - string for covertion
276
function convertStringToBoolean(inputString){
277
if (typeof (inputString) == "string")
278
inputString=inputString.toLowerCase();
280
switch (inputString){
290
default: return false;
295
* @desc: find out what symbol to use as url param delimiters in further params
297
* @param: str - current url string
300
function getUrlSymbol(str){
301
if (str.indexOf("?") != -1)
307
function dhtmlDragAndDropObject(){
308
if (window.dhtmlDragAndDrop)
309
return window.dhtmlDragAndDrop;
313
this.dragStartNode=0;
314
this.dragStartObject=0;
318
window.dhtmlDragAndDrop=this;
323
dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
324
htmlNode.onmousedown=null;
325
htmlNode.dragStarter=null;
326
htmlNode.dragLanding=null;
328
dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode, dhtmlObject){
329
htmlNode.onmousedown=this.preCreateDragCopy;
330
htmlNode.dragStarter=dhtmlObject;
331
this.addDragLanding(htmlNode, dhtmlObject);
333
dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode, dhtmlObject){
334
htmlNode.dragLanding=dhtmlObject;
336
dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e){
337
if (e&&(e||event).button == 2)
340
if (window.dhtmlDragAndDrop.waitDrag){
341
window.dhtmlDragAndDrop.waitDrag=0;
342
document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
343
document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
347
window.dhtmlDragAndDrop.waitDrag=1;
348
window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
349
window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
350
window.dhtmlDragAndDrop.dragStartNode=this;
351
window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
352
document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
353
document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
355
if ((e)&&(e.preventDefault)){
361
dhtmlDragAndDropObject.prototype.callDrag=function(e){
364
dragger=window.dhtmlDragAndDrop;
366
if ((e.button == 0)&&(_isIE))
367
return dragger.stopDrag();
369
if (!dragger.dragNode&&dragger.waitDrag){
370
dragger.dragNode=dragger.dragStartObject._createDragNode(dragger.dragStartNode, e);
372
if (!dragger.dragNode)
373
return dragger.stopDrag();
375
dragger.gldragNode=dragger.dragNode;
376
document.body.appendChild(dragger.dragNode);
377
document.body.onmouseup=dragger.stopDrag;
379
dragger.dragNode.pWindow=window;
380
dragger.initFrameRoute();
383
if (dragger.dragNode.parentNode != window.document.body){
384
var grd = dragger.gldragNode;
386
if (dragger.gldragNode.old)
387
grd=dragger.gldragNode.old;
389
//if (!document.all) dragger.calculateFramePosition();
390
grd.parentNode.removeChild(grd);
391
var oldBody = dragger.dragNode.pWindow;
393
// var oldp=dragger.dragNode.parentObject;
395
var div = document.createElement("Div");
396
div.innerHTML=dragger.dragNode.outerHTML;
397
dragger.dragNode=div.childNodes[0];
399
dragger.dragNode=dragger.dragNode.cloneNode(true);
401
dragger.dragNode.pWindow=window;
402
// dragger.dragNode.parentObject=oldp;
404
dragger.gldragNode.old=dragger.dragNode;
405
document.body.appendChild(dragger.dragNode);
406
oldBody.dhtmlDragAndDrop.dragNode=dragger.dragNode;
409
dragger.dragNode.style.left=e.clientX+15+(dragger.fx
412
+(document.body.scrollLeft||document.documentElement.scrollLeft)+"px";
413
dragger.dragNode.style.top=e.clientY+3+(dragger.fy
416
+(document.body.scrollTop||document.documentElement.scrollTop)+"px";
422
dragger.checkLanding(z, e);
425
dhtmlDragAndDropObject.prototype.calculateFramePosition=function(n){
426
//this.fx = 0, this.fy = 0;
428
var el = parent.frames[window.name].frameElement.offsetParent;
438
if ((parent.dhtmlDragAndDrop)){
439
var ls = parent.dhtmlDragAndDrop.calculateFramePosition(1);
440
fx+=ls.split('_')[0]*1;
441
fy+=ls.split('_')[1]*1;
452
dhtmlDragAndDropObject.prototype.checkLanding=function(htmlObject, e){
453
if ((htmlObject)&&(htmlObject.dragLanding)){
454
if (this.lastLanding)
455
this.lastLanding.dragLanding._dragOut(this.lastLanding);
456
this.lastLanding=htmlObject;
457
this.lastLanding=this.lastLanding.dragLanding._dragIn(this.lastLanding, this.dragStartNode, e.clientX,
459
this.lastLanding_scr=(_isIE ? e.srcElement : e.target);
461
if ((htmlObject)&&(htmlObject.tagName != "BODY"))
462
this.checkLanding(htmlObject.parentNode, e);
464
if (this.lastLanding)
465
this.lastLanding.dragLanding._dragOut(this.lastLanding, e.clientX, e.clientY, e);
468
if (this._onNotFound)
473
dhtmlDragAndDropObject.prototype.stopDrag=function(e, mode){
474
dragger=window.dhtmlDragAndDrop;
477
dragger.stopFrameRoute();
478
var temp = dragger.lastLanding;
479
dragger.lastLanding=null;
482
temp.dragLanding._drag(dragger.dragStartNode, dragger.dragStartObject, temp, (_isIE
486
dragger.lastLanding=null;
488
if ((dragger.dragNode)&&(dragger.dragNode.parentNode == document.body))
489
dragger.dragNode.parentNode.removeChild(dragger.dragNode);
491
dragger.gldragNode=0;
494
dragger.dragStartNode=0;
495
dragger.dragStartObject=0;
496
document.body.onmouseup=dragger.tempDOMU;
497
document.body.onmousemove=dragger.tempDOMM;
498
dragger.tempDOMU=null;
499
dragger.tempDOMM=null;
503
dhtmlDragAndDropObject.prototype.stopFrameRoute=function(win){
505
window.dhtmlDragAndDrop.stopDrag(1, 1);
507
for (var i = 0; i < window.frames.length; i++)
508
if ((window.frames[i] != win)&&(window.frames[i].dhtmlDragAndDrop))
509
window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
511
if ((parent.dhtmlDragAndDrop)&&(parent != window)&&(parent != win))
512
parent.dhtmlDragAndDrop.stopFrameRoute(window);
514
dhtmlDragAndDropObject.prototype.initFrameRoute=function(win, mode){
516
window.dhtmlDragAndDrop.preCreateDragCopy();
517
window.dhtmlDragAndDrop.dragStartNode=win.dhtmlDragAndDrop.dragStartNode;
518
window.dhtmlDragAndDrop.dragStartObject=win.dhtmlDragAndDrop.dragStartObject;
519
window.dhtmlDragAndDrop.dragNode=win.dhtmlDragAndDrop.dragNode;
520
window.dhtmlDragAndDrop.gldragNode=win.dhtmlDragAndDrop.dragNode;
521
window.document.body.onmouseup=window.dhtmlDragAndDrop.stopDrag;
524
if (((!_isIE)&&(mode))&&((!_isFF)||(_FFrv < 1.8)))
525
window.dhtmlDragAndDrop.calculateFramePosition();
528
if ((parent.dhtmlDragAndDrop)&&(parent != window)&&(parent != win))
529
parent.dhtmlDragAndDrop.initFrameRoute(window);
531
for (var i = 0; i < window.frames.length; i++)
532
if ((window.frames[i] != win)&&(window.frames[i].dhtmlDragAndDrop))
533
window.frames[i].dhtmlDragAndDrop.initFrameRoute(window, ((!win||mode) ? 1 : 0));
538
var _isOpera = false;
539
var _isKHTML = false;
540
var _isMacOS = false;
542
if (navigator.userAgent.indexOf('Macintosh') != -1)
545
if ((navigator.userAgent.indexOf('Safari') != -1)||(navigator.userAgent.indexOf('Konqueror') != -1)){
546
var _KHTMLrv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Safari')+7, 5));
548
if (_KHTMLrv > 525){ //mimic FF behavior for Safari 3.1+
553
} else if (navigator.userAgent.indexOf('Opera') != -1){
555
_OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6, 3));
558
else if (navigator.appName.indexOf("Microsoft") != -1)
563
var _FFrv = parseFloat(navigator.userAgent.split("rv:")[1])
566
//deprecated, use global constant instead
567
//determines if current browser is IE
569
if (navigator.appName.indexOf("Microsoft") != -1)
570
if (navigator.userAgent.indexOf('Opera') == -1)
575
//multibrowser Xpath processor
576
dtmlXMLLoaderObject.prototype.doXPath=function(xpathExp, docObj, namespace, result_type){
578
return this.doXPathOpera(xpathExp, docObj);
582
if (!this.xmlDoc.nodeName)
583
docObj=this.xmlDoc.responseXML
588
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
589
(docObj||this.xmlDoc),
593
if (namespace != null)
594
docObj.setProperty("SelectionNamespaces", "xmlns:xsl='"+namespace+"'"); //
596
if (result_type == 'single'){
597
return docObj.selectSingleNode(xpathExp);
600
return docObj.selectNodes(xpathExp)||new Array(0);
603
var nodeObj = docObj;
606
if (!this.xmlDoc.nodeName){
607
docObj=this.xmlDoc.responseXML
615
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
616
(docObj||this.xmlDoc),
620
if (docObj.nodeName.indexOf("document") != -1){
625
docObj=docObj.ownerDocument;
627
var retType = XPathResult.ANY_TYPE;
629
if (result_type == 'single')
630
retType=XPathResult.FIRST_ORDERED_NODE_TYPE
631
var rowsCol = new Array();
632
var col = docObj.evaluate(xpathExp, nodeObj, function(pref){
636
if (retType == XPathResult.FIRST_ORDERED_NODE_TYPE){
637
return col.singleNodeValue;
639
var thisColMemb = col.iterateNext();
642
rowsCol[rowsCol.length]=thisColMemb;
643
thisColMemb=col.iterateNext();
649
function _dhtmlxError(type, name, params){
651
this.catches=new Array();
656
_dhtmlxError.prototype.catchError=function(type, func_name){
657
this.catches[type]=func_name;
659
_dhtmlxError.prototype.throwError=function(type, name, params){
660
if (this.catches[type])
661
return this.catches[type](type, name, params);
663
if (this.catches["ALL"])
664
return this.catches["ALL"](type, name, params);
666
alert("Error type: "+arguments[0]+"\nDescription: "+arguments[1]);
670
window.dhtmlxError=new _dhtmlxError();
673
//opera fake, while 9.0 not released
674
//multibrowser Xpath processor
675
dtmlXMLLoaderObject.prototype.doXPathOpera=function(xpathExp, docObj){
676
//this is fake for Opera
677
var z = xpathExp.replace(/[\/]+/gi, "/").split('/');
685
obj=[docObj]; else if (z[0] == ""){
686
obj=(this.xmlDoc.responseXML||this.xmlDoc).getElementsByTagName(z[i].replace(/\[[^\]]*\]/g, ""));
691
for (i; i < z.length; i++)obj=this._getAllNamedChilds(obj, z[i]);
693
if (z[i-1].indexOf("[") != -1)
694
obj=this._filterXPath(obj, z[i-1]);
698
dtmlXMLLoaderObject.prototype._filterXPath=function(a, b){
700
var b = b.replace(/[^\[]*\[\@/g, "").replace(/[\[\]\@]*/g, "");
702
for (var i = 0; i < a.length; i++)
703
if (a[i].getAttribute(b))
708
dtmlXMLLoaderObject.prototype._getAllNamedChilds=function(a, b){
714
for (var i = 0; i < a.length; i++)for (var j = 0; j < a[i].childNodes.length; j++){
716
if (a[i].childNodes[j].tagName&&a[i].childNodes[j].tagName.toUpperCase() == b)
717
c[c.length]=a[i].childNodes[j];
720
else if (a[i].childNodes[j].tagName == b)
721
c[c.length]=a[i].childNodes[j];
727
function dhtmlXHeir(a, b){
729
if (typeof (b[c]) == "function")
734
function dhtmlxEvent(el, event, handler){
735
if (el.addEventListener)
736
el.addEventListener(event, handler, false);
738
else if (el.attachEvent)
739
el.attachEvent("on"+event, handler);
742
//============= XSL Extension ===================================
744
dtmlXMLLoaderObject.prototype.xslDoc=null;
745
dtmlXMLLoaderObject.prototype.setXSLParamValue=function(paramName, paramValue, xslDoc){
749
if (xslDoc.responseXML)
750
xslDoc=xslDoc.responseXML;
752
this.doXPath("/xsl:stylesheet/xsl:variable[@name='"+paramName+"']", xslDoc,
753
"http:/\/www.w3.org/1999/XSL/Transform", "single");
756
item.firstChild.nodeValue=paramValue
758
dtmlXMLLoaderObject.prototype.doXSLTransToObject=function(xslDoc, xmlDoc){
762
if (xslDoc.responseXML)
763
xslDoc=xslDoc.responseXML
768
if (xmlDoc.responseXML)
769
xmlDoc=xmlDoc.responseXML
773
if (!this.XSLProcessor){
774
this.XSLProcessor=new XSLTProcessor();
775
this.XSLProcessor.importStylesheet(xslDoc);
777
var result = this.XSLProcessor.transformToDocument(xmlDoc);
779
var result = new ActiveXObject("Msxml2.DOMDocument.3.0");
780
xmlDoc.transformNodeToObject(xslDoc, result);
785
dtmlXMLLoaderObject.prototype.doXSLTransToString=function(xslDoc, xmlDoc){
786
return this.doSerialization(this.doXSLTransToObject(xslDoc, xmlDoc));
789
dtmlXMLLoaderObject.prototype.doSerialization=function(xmlDoc){
792
if (xmlDoc.responseXML)
793
xmlDoc=xmlDoc.responseXML
795
var xmlSerializer = new XMLSerializer();
796
return xmlSerializer.serializeToString(xmlDoc);
801
//(c)dhtmlx ltd. www.dhtmlx.com
b'\\ No newline at end of file'