summaryrefslogtreecommitdiffstats
path: root/codebase/sources/ext/dhtmlxscheduler_expand.js
blob: 55d855d219e31fb58e17a0ef8b061e2187827823 (plain)
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
/*
@license
dhtmlxScheduler v.4.4.0 Stardard

This software is covered by GPL license. You also can obtain Commercial or Enterprise license to use it in non-GPL project - please contact sales@dhtmlx.com. Usage without proper license is prohibited.

(c) Dinamenta, UAB.
*/
scheduler.expand = function() {
	if(!scheduler.callEvent("onBeforeExpand", []))
		return;
	var t = scheduler._obj;
	do {
		t._position = t.style.position || "";
		t.style.position = "static";
	} while ((t = t.parentNode) && t.style);
	t = scheduler._obj;
	t.style.position = "absolute";
	t._width = t.style.width;
	t._height = t.style.height;
	t.style.width = t.style.height = "100%";
	t.style.top = t.style.left = "0px";

	var top = document.body;
	top.scrollTop = 0;

	top = top.parentNode;
	if (top)
		top.scrollTop = 0;
	document.body._overflow = document.body.style.overflow || "";
	document.body.style.overflow = "hidden";
	scheduler._maximize();
	scheduler.callEvent("onExpand", []);
};
scheduler.collapse = function() {
	if(!scheduler.callEvent("onBeforeCollapse", []))
		return;
	var t = scheduler._obj;
	do {
		t.style.position = t._position;
	} while ((t = t.parentNode) && t.style);
	t = scheduler._obj;
	t.style.width = t._width;
	t.style.height = t._height;
	document.body.style.overflow = document.body._overflow;
	scheduler._maximize();
	scheduler.callEvent("onCollapse", []);
};
scheduler.attachEvent("onTemplatesReady", function() {
	var t = document.createElement("DIV");
	t.className = "dhx_expand_icon";
	scheduler.toggleIcon = t;
	scheduler._obj.appendChild(t);
	t.onclick = function() {
		if (!scheduler.expanded)
			scheduler.expand(); else
			scheduler.collapse();
	};
});
scheduler._maximize = function() {
	this.expanded = !this.expanded;
	this.toggleIcon.style.backgroundPosition = "0 " + (this.expanded ? "0" : "18") + "px";

	var directions = ['left', 'top'];
	for (var i = 0; i < directions.length; i++) {
		var margin = scheduler.xy['margin_' + directions[i]];
		var prev_margin = scheduler['_prev_margin_' + directions[i]];
		if (scheduler.xy['margin_' + directions[i]]) {
			scheduler['_prev_margin_' + directions[i]] = scheduler.xy['margin_' + directions[i]];
			scheduler.xy['margin_' + directions[i]] = 0;
		} else {
			if (prev_margin) {
				scheduler.xy['margin_' + directions[i]] = scheduler['_prev_margin_' + directions[i]];
				delete scheduler['_prev_margin_' + directions[i]];
			}
		}
	}

	if (scheduler.callEvent("onSchedulerResize", [])) {
		scheduler.update_view();
		scheduler.callEvent("onAfterSchedulerResize");
	}
};