-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathdhtmlxscheduler.js
9191 lines (8007 loc) · 261 KB
/
dhtmlxscheduler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
@license
dhtmlxScheduler v.5.3.14 Standard
To use dhtmlxScheduler in non-GPL projects (and get Pro version of the product), please obtain Commercial/Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxScheduler/#licensing or contact us at [email protected]
(c) XB Software Ltd.
*/
(function () {
if (!window.dhtmlx) {
window.dhtmlx = function (obj) {
for (var a in obj) dhtmlx[a] = obj[a];
return dhtmlx; //simple singleton
};
}
dhtmlx.extend_api = function (name, map, ext) {
var t = window[name];
if (!t) return; //component not defined
window[name] = function (obj) {
var that;
if (obj && typeof obj == "object" && !obj.tagName) {
that = t.apply(this, (map._init ? map._init(obj) : arguments));
//global settings
for (var a in dhtmlx)
if (map[a]) this[map[a]](dhtmlx[a]);
//local settings
for (var a in obj) {
if (map[a]) this[map[a]](obj[a]);
else if (a.indexOf("on") === 0) {
this.attachEvent(a, obj[a]);
}
}
} else
that = t.apply(this, arguments);
if (map._patch) map._patch(this);
return that || this;
};
window[name].prototype = t.prototype;
if (ext)
dhtmlXHeir(window[name].prototype, ext);
};
// TODO: remove
window.dhtmlxAjax = {
get: function (url, callback) {
var t = new dtmlXMLLoaderObject(true);
t.async = (arguments.length < 3);
t.waitCall = callback;
t.loadXML(url);
return t;
},
post: function (url, post, callback) {
var t = new dtmlXMLLoaderObject(true);
t.async = (arguments.length < 4);
t.waitCall = callback;
t.loadXML(url, true, post);
return t;
},
getSync: function (url) {
return this.get(url, null, true);
},
postSync: function (url, post) {
return this.post(url, post, null, true);
}
};
// TODO: remove
/**
* @desc: xmlLoader object
* @type: private
* @param: funcObject - xml parser function
* @param: object - jsControl object
* @param: async - sync/async mode (async by default)
* @param: rSeed - enable/disable random seed ( prevent IE caching)
* @topic: 0
*/
function dtmlXMLLoaderObject(funcObject, dhtmlObject, async, rSeed) {
this.xmlDoc = "";
if (typeof (async) != "undefined")
this.async = async;
else
this.async = true;
this.onloadAction = funcObject || null;
this.mainObject = dhtmlObject || null;
this.waitCall = null;
this.rSeed = rSeed || false;
return this;
}
window.dtmlXMLLoaderObject = dtmlXMLLoaderObject;
dtmlXMLLoaderObject.count = 0;
/**
* @desc: xml loading handler
* @type: private
* @param: dtmlObject - xmlLoader object
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.waitLoadFunction = function (dhtmlObject) {
var once = true;
this.check = function () {
if ((dhtmlObject) && (dhtmlObject.onloadAction)) {
if ((!dhtmlObject.xmlDoc.readyState) || (dhtmlObject.xmlDoc.readyState == 4)) {
if (!once)
return;
once = false; //IE 5 fix
dtmlXMLLoaderObject.count++;
if (typeof dhtmlObject.onloadAction == "function")
dhtmlObject.onloadAction(dhtmlObject.mainObject, null, null, null, dhtmlObject);
if (dhtmlObject.waitCall) {
dhtmlObject.waitCall.call(this, dhtmlObject);
dhtmlObject.waitCall = null;
}
}
}
};
return this.check;
};
/**
* @desc: return XML top node
* @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla)
* @type: private
* @returns: top XML node
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.getXMLTopNode = function (tagName, oldObj) {
var z;
if (this.xmlDoc.responseXML) {
var temp = this.xmlDoc.responseXML.getElementsByTagName(tagName);
if (temp.length === 0 && tagName.indexOf(":") != -1)
var temp = this.xmlDoc.responseXML.getElementsByTagName((tagName.split(":"))[1]);
z = temp[0];
} else
z = this.xmlDoc.documentElement;
if (z) {
this._retry = false;
return z;
}
if (!this._retry && _isIE) {
this._retry = true;
var oldObj = this.xmlDoc;
this.loadXMLString(this.xmlDoc.responseText.replace(/^[\s]+/, ""), true);
return this.getXMLTopNode(tagName, oldObj);
}
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
(oldObj || this.xmlDoc),
this.mainObject
]);
return document.createElement("div");
};
/**
* @desc: load XML from string
* @type: private
* @param: xmlString - xml string
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.loadXMLString = function (xmlString, silent) {
if (!_isIE) {
var parser = new DOMParser();
this.xmlDoc = parser.parseFromString(xmlString, "text/xml");
} else {
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
this.xmlDoc.async = this.async;
this.xmlDoc.onreadystatechange = function () { };
this.xmlDoc["loadXM" + "L"](xmlString);
}
if (silent)
return;
if (this.onloadAction)
this.onloadAction(this.mainObject, null, null, null, this);
if (this.waitCall) {
this.waitCall();
this.waitCall = null;
}
};
/**
* @desc: load XML
* @type: private
* @param: filePath - xml file path
* @param: postMode - send POST request
* @param: postVars - list of vars for post request
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.loadXML = function (filePath, postMode, postVars, rpc) {
if (this.rSeed)
filePath += ((filePath.indexOf("?") != -1) ? "&" : "?") + "a_dhx_rSeed=" + (new Date()).valueOf();
this.filePath = filePath;
if ((!_isIE) && (window.XMLHttpRequest))
this.xmlDoc = new XMLHttpRequest();
else {
this.xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
}
if (this.async)
this.xmlDoc.onreadystatechange = new this.waitLoadFunction(this);
if (typeof postMode == "string")
this.xmlDoc.open(postMode, filePath, this.async);
else
this.xmlDoc.open(postMode ? "POST" : "GET", filePath, this.async);
if (rpc) {
this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 (" + navigator.userAgent + ")");
this.xmlDoc.setRequestHeader("Content-type", "text/xml");
}
else if (postMode)
this.xmlDoc.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
this.xmlDoc.setRequestHeader("X-Requested-With", "XMLHttpRequest");
this.xmlDoc.send(null || postVars);
if (!this.async)
(new this.waitLoadFunction(this))();
};
/**
* @desc: destructor, cleans used memory
* @type: private
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.destructor = function () {
this._filterXPath = null;
this._getAllNamedChilds = null;
this._retry = null;
this.async = null;
this.rSeed = null;
this.filePath = null;
this.onloadAction = null;
this.mainObject = null;
this.xmlDoc = null;
this.doXPath = null;
this.doXPathOpera = null;
this.doXSLTransToObject = null;
this.doXSLTransToString = null;
this.loadXML = null;
this.loadXMLString = null;
// this.waitLoadFunction = null;
this.doSerialization = null;
this.xmlNodeToJSON = null;
this.getXMLTopNode = null;
this.setXSLParamValue = null;
return null;
};
dtmlXMLLoaderObject.prototype.xmlNodeToJSON = function (node) {
var t = {};
for (var i = 0; i < node.attributes.length; i++)
t[node.attributes[i].name] = node.attributes[i].value;
t["_tagvalue"] = node.firstChild ? node.firstChild.nodeValue : "";
for (var i = 0; i < node.childNodes.length; i++) {
var name = node.childNodes[i].tagName;
if (name) {
if (!t[name]) t[name] = [];
t[name].push(this.xmlNodeToJSON(node.childNodes[i]));
}
}
return t;
};
function dhtmlDragAndDropObject() {
if (window.dhtmlDragAndDrop)
return window.dhtmlDragAndDrop;
this.lastLanding = 0;
this.dragNode = 0;
this.dragStartNode = 0;
this.dragStartObject = 0;
this.tempDOMU = null;
this.tempDOMM = null;
this.waitDrag = 0;
window.dhtmlDragAndDrop = this;
return this;
}
window.dhtmlDragAndDropObject = dhtmlDragAndDropObject;
dhtmlDragAndDropObject.prototype.removeDraggableItem = function (htmlNode) {
htmlNode.onmousedown = null;
htmlNode.dragStarter = null;
htmlNode.dragLanding = null;
};
dhtmlDragAndDropObject.prototype.addDraggableItem = function (htmlNode, dhtmlObject) {
htmlNode.onmousedown = this.preCreateDragCopy;
htmlNode.dragStarter = dhtmlObject;
this.addDragLanding(htmlNode, dhtmlObject);
};
dhtmlDragAndDropObject.prototype.addDragLanding = function (htmlNode, dhtmlObject) {
htmlNode.dragLanding = dhtmlObject;
};
dhtmlDragAndDropObject.prototype.preCreateDragCopy = function (e) {
if ((e || window.event) && (e || event).button == 2)
return;
if (window.dhtmlDragAndDrop.waitDrag) {
window.dhtmlDragAndDrop.waitDrag = 0;
document.body.onmouseup = window.dhtmlDragAndDrop.tempDOMU;
document.body.onmousemove = window.dhtmlDragAndDrop.tempDOMM;
return false;
}
if (window.dhtmlDragAndDrop.dragNode)
window.dhtmlDragAndDrop.stopDrag(e);
window.dhtmlDragAndDrop.waitDrag = 1;
window.dhtmlDragAndDrop.tempDOMU = document.body.onmouseup;
window.dhtmlDragAndDrop.tempDOMM = document.body.onmousemove;
window.dhtmlDragAndDrop.dragStartNode = this;
window.dhtmlDragAndDrop.dragStartObject = this.dragStarter;
document.body.onmouseup = window.dhtmlDragAndDrop.preCreateDragCopy;
document.body.onmousemove = window.dhtmlDragAndDrop.callDrag;
window.dhtmlDragAndDrop.downtime = new Date().valueOf();
if ((e) && (e.preventDefault)) {
e.preventDefault();
return false;
}
return false;
};
dhtmlDragAndDropObject.prototype.callDrag = function (e) {
if (!e)
e = window.event;
var dragger = window.dhtmlDragAndDrop;
if ((new Date()).valueOf() - dragger.downtime < 100) return;
//if ((e.button == 0)&&(_isIE))
// return dragger.stopDrag();
if (!dragger.dragNode) {
if (dragger.waitDrag) {
dragger.dragNode = dragger.dragStartObject._createDragNode(dragger.dragStartNode, e);
if (!dragger.dragNode)
return dragger.stopDrag();
dragger.dragNode.onselectstart = function () { return false; };
dragger.gldragNode = dragger.dragNode;
document.body.appendChild(dragger.dragNode);
document.body.onmouseup = dragger.stopDrag;
dragger.waitDrag = 0;
dragger.dragNode.pWindow = window;
dragger.initFrameRoute();
}
else return dragger.stopDrag(e, true);
}
if (dragger.dragNode.parentNode != window.document.body && dragger.gldragNode) {
var grd = dragger.gldragNode;
if (dragger.gldragNode.old)
grd = dragger.gldragNode.old;
//if (!document.all) dragger.calculateFramePosition();
grd.parentNode.removeChild(grd);
var oldBody = dragger.dragNode.pWindow;
if (grd.pWindow && grd.pWindow.dhtmlDragAndDrop.lastLanding)
grd.pWindow.dhtmlDragAndDrop.lastLanding.dragLanding._dragOut(grd.pWindow.dhtmlDragAndDrop.lastLanding);
// var oldp=dragger.dragNode.parentObject;
if (_isIE) {
var div = document.createElement("div");
div.innerHTML = dragger.dragNode.outerHTML;
dragger.dragNode = div.childNodes[0];
} else
dragger.dragNode = dragger.dragNode.cloneNode(true);
dragger.dragNode.pWindow = window;
// dragger.dragNode.parentObject=oldp;
dragger.gldragNode.old = dragger.dragNode;
document.body.appendChild(dragger.dragNode);
oldBody.dhtmlDragAndDrop.dragNode = dragger.dragNode;
}
dragger.dragNode.style.left = e.clientX + 15 +
(dragger.fx ? dragger.fx * (-1) : 0) +
(document.body.scrollLeft || document.documentElement.scrollLeft) + "px";
dragger.dragNode.style.top = e.clientY + 3 +
(dragger.fy ? dragger.fy * (-1) : 0) +
(document.body.scrollTop || document.documentElement.scrollTop) + "px";
var z;
if (!e.srcElement)
z = e.target;
else
z = e.srcElement;
dragger.checkLanding(z, e);
};
dhtmlDragAndDropObject.prototype.calculateFramePosition = function (n) {
//this.fx = 0, this.fy = 0;
if (window.name) {
var el = parent.frames[window.name].frameElement.offsetParent;
var fx = 0;
var fy = 0;
while (el) {
fx += el.offsetLeft;
fy += el.offsetTop;
el = el.offsetParent;
}
if ((parent.dhtmlDragAndDrop)) {
var ls = parent.dhtmlDragAndDrop.calculateFramePosition(1);
fx += ls.split('_')[0] * 1;
fy += ls.split('_')[1] * 1;
}
if (n)
return fx + "_" + fy;
else
this.fx = fx;
this.fy = fy;
}
return "0_0";
};
dhtmlDragAndDropObject.prototype.checkLanding = function (htmlObject, e) {
if ((htmlObject) && (htmlObject.dragLanding)) {
if (this.lastLanding)
this.lastLanding.dragLanding._dragOut(this.lastLanding);
this.lastLanding = htmlObject;
this.lastLanding = this.lastLanding.dragLanding._dragIn(this.lastLanding, this.dragStartNode, e.clientX,
e.clientY, e);
this.lastLanding_scr = (_isIE ? e.srcElement : e.target);
} else {
if ((htmlObject) && (htmlObject.tagName != "BODY"))
this.checkLanding(htmlObject.parentNode, e);
else {
if (this.lastLanding)
this.lastLanding.dragLanding._dragOut(this.lastLanding, e.clientX, e.clientY, e);
this.lastLanding = 0;
if (this._onNotFound)
this._onNotFound();
}
}
};
dhtmlDragAndDropObject.prototype.stopDrag = function (e, mode) {
var dragger = window.dhtmlDragAndDrop;
if (!mode) {
dragger.stopFrameRoute();
var temp = dragger.lastLanding;
dragger.lastLanding = null;
if (temp)
temp.dragLanding._drag(dragger.dragStartNode, dragger.dragStartObject, temp,
(_isIE ? event.srcElement : e.target));
}
dragger.lastLanding = null;
if ((dragger.dragNode) && (dragger.dragNode.parentNode == document.body))
dragger.dragNode.parentNode.removeChild(dragger.dragNode);
dragger.dragNode = 0;
dragger.gldragNode = 0;
dragger.fx = 0;
dragger.fy = 0;
dragger.dragStartNode = 0;
dragger.dragStartObject = 0;
document.body.onmouseup = dragger.tempDOMU;
document.body.onmousemove = dragger.tempDOMM;
dragger.tempDOMU = null;
dragger.tempDOMM = null;
dragger.waitDrag = 0;
};
dhtmlDragAndDropObject.prototype.stopFrameRoute = function (win) {
if (win)
window.dhtmlDragAndDrop.stopDrag(1, 1);
for (var i = 0; i < window.frames.length; i++) {
try {
if ((window.frames[i] != win) && (window.frames[i].dhtmlDragAndDrop))
window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
} catch (e) { }
}
try {
if ((parent.dhtmlDragAndDrop) && (parent != window) && (parent != win))
parent.dhtmlDragAndDrop.stopFrameRoute(window);
} catch (e) { }
};
dhtmlDragAndDropObject.prototype.initFrameRoute = function (win, mode) {
if (win) {
window.dhtmlDragAndDrop.preCreateDragCopy();
window.dhtmlDragAndDrop.dragStartNode = win.dhtmlDragAndDrop.dragStartNode;
window.dhtmlDragAndDrop.dragStartObject = win.dhtmlDragAndDrop.dragStartObject;
window.dhtmlDragAndDrop.dragNode = win.dhtmlDragAndDrop.dragNode;
window.dhtmlDragAndDrop.gldragNode = win.dhtmlDragAndDrop.dragNode;
window.document.body.onmouseup = window.dhtmlDragAndDrop.stopDrag;
window.waitDrag = 0;
if (((!_isIE) && (mode)) && ((!_isFF) || (_FFrv < 1.8)))
window.dhtmlDragAndDrop.calculateFramePosition();
}
try {
if ((parent.dhtmlDragAndDrop) && (parent != window) && (parent != win))
parent.dhtmlDragAndDrop.initFrameRoute(window);
} catch (e) { }
for (var i = 0; i < window.frames.length; i++) {
try {
if ((window.frames[i] != win) && (window.frames[i].dhtmlDragAndDrop))
window.frames[i].dhtmlDragAndDrop.initFrameRoute(window, ((!win || mode) ? 1 : 0));
} catch (e) { }
}
};
var _isFF = false;
var _isIE = false;
var _isOpera = false;
var _isKHTML = false;
var _isMacOS = false;
var _isChrome = false;
var _FFrv = false;
var _KHTMLrv = false;
var _OperaRv = false;
if (navigator.userAgent.indexOf('Macintosh') != -1)
_isMacOS = true;
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
_isChrome = true;
if ((navigator.userAgent.indexOf('Safari') != -1) || (navigator.userAgent.indexOf('Konqueror') != -1)) {
_KHTMLrv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Safari') + 7, 5));
if (_KHTMLrv > 525) { //mimic FF behavior for Safari 3.1+
_isFF = true;
_FFrv = 1.9;
} else
_isKHTML = true;
} else if (navigator.userAgent.indexOf('Opera') != -1) {
_isOpera = true;
_OperaRv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera') + 6, 3));
}
else if (navigator.appName.indexOf("Microsoft") != -1) {
_isIE = true;
if ((navigator.appVersion.indexOf("MSIE 8.0") != -1 || navigator.appVersion.indexOf("MSIE 9.0") != -1 || navigator.appVersion.indexOf("MSIE 10.0") != -1) && document.compatMode != "BackCompat") {
_isIE = 8;
}
} else if (navigator.appName == 'Netscape' && navigator.userAgent.indexOf("Trident") != -1) {
//ie11
_isIE = 8;
} else {
_isFF = true;
_FFrv = parseFloat(navigator.userAgent.split("rv:")[1]);
}
//multibrowser Xpath processor
dtmlXMLLoaderObject.prototype.doXPath = function (xpathExp, docObj, namespace, result_type) {
if (_isKHTML || (!_isIE && !window.XPathResult))
return this.doXPathOpera(xpathExp, docObj);
if (_isIE) { //IE
if (!docObj)
if (!this.xmlDoc.nodeName)
docObj = this.xmlDoc.responseXML;
else
docObj = this.xmlDoc;
if (!docObj)
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
(docObj || this.xmlDoc),
this.mainObject
]);
if (namespace)
docObj.setProperty("SelectionNamespaces", "xmlns:xsl='" + namespace + "'"); //
if (result_type == 'single') {
return docObj.selectSingleNode(xpathExp);
}
else {
return docObj.selectNodes(xpathExp) || new Array(0);
}
} else { //Mozilla
var nodeObj = docObj;
if (!docObj) {
if (!this.xmlDoc.nodeName) {
docObj = this.xmlDoc.responseXML;
}
else {
docObj = this.xmlDoc;
}
}
if (!docObj)
dhtmlxError.throwError("LoadXML", "Incorrect XML", [
(docObj || this.xmlDoc),
this.mainObject
]);
if (docObj.nodeName.indexOf("document") != -1) {
nodeObj = docObj;
}
else {
nodeObj = docObj;
docObj = docObj.ownerDocument;
}
var retType = XPathResult.ANY_TYPE;
if (result_type == 'single')
retType = XPathResult.FIRST_ORDERED_NODE_TYPE;
var rowsCol = [];
var col = docObj.evaluate(xpathExp, nodeObj, function (pref) {
return namespace;
}, retType, null);
if (retType == XPathResult.FIRST_ORDERED_NODE_TYPE) {
return col.singleNodeValue;
}
var thisColMemb = col.iterateNext();
while (thisColMemb) {
rowsCol[rowsCol.length] = thisColMemb;
thisColMemb = col.iterateNext();
}
return rowsCol;
}
};
function _dhtmlxError(type, name, params) {
if (!this.catches)
this.catches = [];
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);
window.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 || this.xmlDoc).getElementsByTagName(z[i].replace(/\[[^\]]*\]/g, ""));
i++;
} else
return [];
for (i; i < z.length; i++)obj = this._getAllNamedChilds(obj, z[i]);
if (z[i - 1].indexOf("[") != -1)
obj = this._filterXPath(obj, z[i - 1]);
return obj;
};
dtmlXMLLoaderObject.prototype._filterXPath = function (a, b) {
var c = [];
var b = b.replace(/[^\[]*\[\@/g, "").replace(/[\[\]\@]*/g, "");
for (var i = 0; i < a.length; i++)
if (a[i].getAttribute(b))
c[c.length] = a[i];
return c;
};
dtmlXMLLoaderObject.prototype._getAllNamedChilds = function (a, b) {
var c = [];
if (_isKHTML)
b = b.toUpperCase();
for (var i = 0; i < a.length; i++)for (var j = 0; j < a[i].childNodes.length; j++) {
if (_isKHTML) {
if (a[i].childNodes[j].tagName && a[i].childNodes[j].tagName.toUpperCase() == b)
c[c.length] = a[i].childNodes[j];
}
else if (a[i].childNodes[j].tagName == b)
c[c.length] = a[i].childNodes[j];
}
return c;
};
function dhtmlXHeir(a, b) {
for (var c in b)
if (typeof (b[c]) == "function")
a[c] = b[c];
return a;
}
if (typeof (window.dhtmlxEvent) == 'undefined') {
window.dhtmlxEvent = function dhtmlxEvent(el, event, handler) {
if (el.addEventListener)
el.addEventListener(event, handler, false);
else if (el.attachEvent)
el.attachEvent("on" + event, handler);
};
}
//============= XSL Extension ===================================
dtmlXMLLoaderObject.prototype.xslDoc = null;
dtmlXMLLoaderObject.prototype.setXSLParamValue = function (paramName, paramValue, xslDoc) {
if (!xslDoc)
xslDoc = this.xslDoc;
if (xslDoc.responseXML)
xslDoc = xslDoc.responseXML;
var item =
this.doXPath("/xsl:stylesheet/xsl:variable[@name='" + paramName + "']", xslDoc,
"http:/\/www.w3.org/1999/XSL/Transform", "single");
if (item)
item.firstChild.nodeValue = paramValue;
};
dtmlXMLLoaderObject.prototype.doXSLTransToObject = function (xslDoc, xmlDoc) {
if (!xslDoc)
xslDoc = this.xslDoc;
if (xslDoc.responseXML)
xslDoc = xslDoc.responseXML;
if (!xmlDoc)
xmlDoc = this.xmlDoc;
if (xmlDoc.responseXML)
xmlDoc = xmlDoc.responseXML;
var result;
//Mozilla
if (!_isIE) {
if (!this.XSLProcessor) {
this.XSLProcessor = new XSLTProcessor();
this.XSLProcessor.importStylesheet(xslDoc);
}
result = this.XSLProcessor.transformToDocument(xmlDoc);
} else {
result = new ActiveXObject("Msxml2.DOMDocument.3.0");
try {
xmlDoc.transformNodeToObject(xslDoc, result);
} catch (e) {
result = xmlDoc.transformNode(xslDoc);
}
}
return result;
};
dtmlXMLLoaderObject.prototype.doXSLTransToString = function (xslDoc, xmlDoc) {
var res = this.doXSLTransToObject(xslDoc, xmlDoc);
if (typeof (res) == "string")
return res;
return this.doSerialization(res);
};
dtmlXMLLoaderObject.prototype.doSerialization = function (xmlDoc) {
if (!xmlDoc)
xmlDoc = this.xmlDoc;
if (xmlDoc.responseXML)
xmlDoc = xmlDoc.responseXML;
if (!_isIE) {
var xmlSerializer = new XMLSerializer();
return xmlSerializer.serializeToString(xmlDoc);
} else
return xmlDoc.xml;
};
/**
* @desc:
* @type: private
*/
window.dhtmlxEventable = function (obj) {
obj.attachEvent = function (name, catcher, callObj) {
name = 'ev_' + name.toLowerCase();
if (!this[name])
this[name] = new this.eventCatcher(callObj || this);
return (name + ':' + this[name].addEvent(catcher)); //return ID (event name & event ID)
};
obj.callEvent = function (name, arg0) {
name = 'ev_' + name.toLowerCase();
if (this[name])
return this[name].apply(this, arg0);
return true;
};
obj.checkEvent = function (name) {
return (!!this['ev_' + name.toLowerCase()]);
};
obj.eventCatcher = function (obj) {
var dhx_catch = [];
var z = function () {
var res = true;
for (var i = 0; i < dhx_catch.length; i++) {
if (dhx_catch[i]) {
var zr = dhx_catch[i].apply(obj, arguments);
res = res && zr;
}
}
return res;
};
z.addEvent = function (ev) {
if (typeof (ev) != "function")
ev = eval(ev);
if (ev)
return dhx_catch.push(ev) - 1;
return false;
};
z.removeEvent = function (id) {
dhx_catch[id] = null;
};
return z;
};
obj.detachEvent = function (id) {
if (id) {
var list = id.split(':');//get EventName and ID
this[list[0]].removeEvent(list[1]); //remove event
}
};
obj.detachAllEvents = function () {
for (var name in this) {
if (name.indexOf("ev_") === 0) {
this.detachEvent(name);
this[name] = null;
}
}
};
obj = null;
};
if(!window.dhtmlx)
window.dhtmlx = {};
(function(){
var _dhx_msg_cfg = null;
function callback(config, result){
setTimeout(function(){
if(!config.box) return;
var usercall = config.callback;
modality(false);
config.box.parentNode.removeChild(config.box);
dhtmlx.callEvent("onAfterMessagePopup", [config.box]);
_dhx_msg_cfg = config.box = null;
if (usercall)
usercall(result);
},1);
}
function modal_key(e){
if (_dhx_msg_cfg){
e = e||event;
var code = e.which||event.keyCode;
var preventDefault = false;
if (dhtmlx.message.keyboard){
if (code == 13 || code == 32){
// default behavior is to confirm/submit popup on space/enter
// if browser focus is set on button element - do button click instead of default behavior
var target = e.target || e.srcElement;
if(scheduler._getClassName(target).indexOf("dhtmlx_popup_button") > -1 && target.click){
target.click();
}else{
callback(_dhx_msg_cfg, true);
preventDefault = true;
}
}
if (code == 27){
callback(_dhx_msg_cfg, false);
preventDefault = true;
}
}
if(preventDefault){
if (e.preventDefault)
e.preventDefault();
return !(e.cancelBubble = true);
}
return;
}
}
if (document.attachEvent)
document.attachEvent("onkeydown", modal_key);
else
document.addEventListener("keydown", modal_key, true);
function modality(mode){
if(!modality.cover){
modality.cover = document.createElement("div");
//necessary for IE only
modality.cover.onkeydown = modal_key;
modality.cover.className = "dhx_modal_cover";
document.body.appendChild(modality.cover);
}
var height = document.body.scrollHeight;
modality.cover.style.display = mode?"inline-block":"none";
}
function button(text, result, css){
var buttonAriaAttrs = scheduler._waiAria.messageButtonAttrString(text);
// css - for locale-independent class name
var className = css ? css : (text || "");
var button_css = "dhtmlx_"+(className).toLowerCase().replace(/ /g, "_")+"_button"; // dhtmlx_ok_button, dhtmlx_click_me_button
return "<div "+buttonAriaAttrs+"class='dhtmlx_popup_button "+button_css+"' result='"+result+"' ><div>"+text+"</div></div>";
}
function info(text){
if (!t.area){
t.area = document.createElement("div");
t.area.className = "dhtmlx_message_area";
t.area.style[t.position]="5px";
document.body.appendChild(t.area);
}
t.hide(text.id);
var message = document.createElement("div");
message.innerHTML = "<div>"+text.text+"</div>";
message.className = "dhtmlx-info dhtmlx-" + text.type;
message.onclick = function(){
t.hide(text.id);
text = null;
};
scheduler._waiAria.messageInfoAttr(message);
if (t.position == "bottom" && t.area.firstChild)
t.area.insertBefore(message,t.area.firstChild);
else
t.area.appendChild(message);
if (text.expire > 0)
t.timers[text.id]=window.setTimeout(function(){
t.hide(text.id);
}, text.expire);
t.pull[text.id] = message;
message = null;
return text.id;
}
function _boxStructure(config, ok, cancel){
var box = document.createElement("div");
box.className = " dhtmlx_modal_box dhtmlx-"+config.type;
box.setAttribute("dhxbox", 1);