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 | 1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../base/schedule", "../renderer/timeline-year", "../renderer/year", "../renderer/timeline-month", "../renderer/timeline-view", "../renderer/month-agenda", "../renderer/agenda", "../renderer/month", "../renderer/work-week", "../renderer/week", "../renderer/day", "../base/constant"], function (require, exports, ej2_base_1, schedule_1, timeline_year_1, year_1, timeline_month_1, timeline_view_1, month_agenda_1, agenda_1, month_1, work_week_1, week_1, day_1, events) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Print = (function () {
function Print(parent) {
this.parent = parent;
}
Print.prototype.print = function (printOptions) {
if (ej2_base_1.isNullOrUndefined(printOptions)) {
this.printScheduler();
}
else {
this.printSchedulerWithModel(printOptions);
}
};
Print.prototype.printScheduler = function () {
var clone = this.parent.element.cloneNode(true);
clone.id = this.parent.element.id + '_print';
document.body.appendChild(clone);
var className = this.parent.currentView === 'MonthAgenda' ? '.e-appointment-wrap' : '.e-content-wrap';
var scrollableEle = this.parent.element.querySelector(className);
var links = [].slice.call(document.getElementsByTagName('head')[0].querySelectorAll('link, style'));
var reference = '';
for (var _i = 0, links_1 = links; _i < links_1.length; _i++) {
var link = links_1[_i];
reference += link.outerHTML;
}
var div = ej2_base_1.createElement('div');
clone.style.width = this.parent.element.offsetWidth + 'px';
var elementWidth = Math.round((parseInt(clone.style.width, 10)) / 100) * 100;
div.appendChild(clone);
var printWindow = window.open('', 'print', 'height=550,width=' + elementWidth + ',tabbar=no');
printWindow.document.write('<!DOCTYPE html><html><head>' + reference + '</head><body>' + div.innerHTML +
'<script>(function() { window.ready = true; })();</script></body></html>');
printWindow.document.close();
printWindow.focus();
setTimeout(function () {
if (printWindow.ready && scrollableEle) {
scrollableEle.scrollLeft = scrollableEle.scrollLeft;
scrollableEle.scrollTop = scrollableEle.scrollTop;
var headerTimeCellsScroll = printWindow.document.querySelector('.e-date-header-wrap');
if (headerTimeCellsScroll) {
headerTimeCellsScroll.scrollLeft = scrollableEle.scrollLeft;
}
var timeCellsScroll = printWindow.document.querySelector('.e-time-cells-wrap');
if (timeCellsScroll) {
timeCellsScroll.scrollTop = scrollableEle.scrollTop;
}
var contentCellScroll = printWindow.document.querySelector(className);
if (contentCellScroll) {
contentCellScroll.scrollLeft = scrollableEle.scrollLeft;
contentCellScroll.scrollTop = scrollableEle.scrollTop;
}
printWindow.print();
printWindow.close();
}
}, 500);
};
Print.prototype.printSchedulerWithModel = function (printOptions) {
var element = ej2_base_1.createElement('div', { id: this.parent.element.id + '_print', className: 'e-print-schedule' });
document.body.appendChild(element);
schedule_1.Schedule.Inject(day_1.Day, week_1.Week, work_week_1.WorkWeek, month_1.Month, agenda_1.Agenda, month_agenda_1.MonthAgenda, timeline_view_1.TimelineViews, timeline_month_1.TimelineMonth, year_1.Year, timeline_year_1.TimelineYear);
this.printInstance = new schedule_1.Schedule(this.getPrintScheduleModel(printOptions));
this.printInstance.isPrinting = true;
this.printInstance.registeredTemplate = this.parent.registeredTemplate;
this.printInstance.root = this.parent.root ? this.parent.root : this.parent;
this.printInstance.appendTo(element);
this.printInstance.on(events.print, this.contentReady, this);
this.printWindow = window.open('', 'print', 'height=' + window.outerHeight + ',width=' + window.outerWidth + ',tabbar=no');
this.printWindow.moveTo(0, 0);
this.printWindow.resizeTo(screen.availWidth, screen.availHeight);
};
Print.prototype.getPrintScheduleModel = function (printOptions) {
var printModel = {};
var scheduleProps = ['agendaDaysCount', 'calendarMode', 'cssClass', 'currentView',
'dateFormat', 'enableRtl', 'endHour', 'eventSettings', 'firstDayOfWeek',
'firstMonthOfYear', 'group', 'height', 'locale', 'maxDate', 'minDate', 'readonly',
'resources', 'rowAutoHeight', 'selectedDate', 'showHeaderBar', 'showTimeIndicator', 'showWeekNumber',
'showWeekend', 'startHour', 'timeFormat', 'timeScale', 'timezone', 'views', 'width', 'workDays', 'workHours',
'dateHeaderTemplate', 'dateRangeTemplate', 'cellHeaderTemplate', 'dayHeaderTemplate', 'monthHeaderTemplate',
'cellTemplate', 'resourceHeaderTemplate', 'headerIndentTemplate', 'actionBegin', 'actionComplete', 'actionFailure',
'created', 'dataBinding', 'dataBound', 'destroyed', 'eventRendered', 'moreEventsClick', 'navigating', 'popupOpen', 'popupClose', 'renderCell'
];
var scheduleTemplates = ['cellHeaderTemplate', 'dayHeaderTemplate', 'monthHeaderTemplate', 'cellTemplate',
'dateHeaderTemplate', 'dateRangeTemplate', 'eventTemplate', 'resourceHeaderTemplate', 'headerIndentTemplate'];
var scheduleEvents = ['actionBegin', 'actionComplete', 'actionFailure', 'created', 'dataBinding', 'dataBound',
'destroyed', 'eventRendered', 'moreEventsClick', 'navigating', 'popupOpen', 'popupClose', 'renderCell'];
var eventSettings;
var group;
var timeScale;
var views;
for (var _i = 0, scheduleProps_1 = scheduleProps; _i < scheduleProps_1.length; _i++) {
var key = scheduleProps_1[_i];
switch (key) {
case 'eventSettings': {
eventSettings = Object.assign({}, this.parent.eventSettings.properties);
eventSettings.dataSource = this.parent.eventsData;
var eventTemplate = !ej2_base_1.isNullOrUndefined(printOptions.eventSettings) &&
!ej2_base_1.isNullOrUndefined(printOptions.eventSettings.template) ? printOptions.eventSettings.template : eventSettings.template;
eventSettings.template = !this.parent.isAngular && typeof (eventTemplate) === 'function' ? null : eventTemplate;
printModel.eventSettings = eventSettings;
break;
}
case 'group':
group = ej2_base_1.isNullOrUndefined(printOptions.group) ? this.parent.group : printOptions.group;
group.headerTooltipTemplate = null;
printModel.group = group;
break;
case 'timeScale':
timeScale = ej2_base_1.isNullOrUndefined(printOptions.timeScale) ? this.parent.timeScale : printOptions.timeScale;
if (!this.parent.isAngular) {
timeScale.majorSlotTemplate = typeof (timeScale.majorSlotTemplate) === 'function' ? null : timeScale.majorSlotTemplate;
timeScale.minorSlotTemplate = typeof (timeScale.minorSlotTemplate) === 'function' ? null : timeScale.minorSlotTemplate;
}
printModel.timeScale = timeScale;
break;
case 'views':
views = ej2_base_1.isNullOrUndefined(printOptions.views) ? this.parent.views : printOptions.views;
if (!this.parent.isAngular && views && views.length > 0 && typeof (views[0]) === 'object') {
var _loop_1 = function (view) {
scheduleTemplates.forEach(function (x) {
if (!ej2_base_1.isNullOrUndefined(view["" + x])) {
view["" + x] = typeof (view["" + x]) === 'function' ? null : view["" + x];
}
});
};
for (var _a = 0, views_1 = views; _a < views_1.length; _a++) {
var view = views_1[_a];
_loop_1(view);
}
}
printModel.views = views;
break;
default:
if (scheduleTemplates.indexOf(key) > -1) {
printModel["" + key] = ej2_base_1.isNullOrUndefined(printOptions["" + key]) ?
(!this.parent.isAngular && typeof (this.parent["" + key]) === 'function' ? null : this.parent["" + key]) :
(!this.parent.isAngular && typeof (printOptions["" + key]) === 'function' ? null : printOptions["" + key]);
break;
}
if (scheduleEvents.indexOf(key) > -1) {
printModel["" + key] = printOptions["" + key];
break;
}
printModel["" + key] = ej2_base_1.isNullOrUndefined(printOptions["" + key]) ?
this.parent["" + key] : printOptions["" + key];
break;
}
}
return printModel;
};
Print.prototype.contentReady = function () {
var _this = this;
this.printWindow = ej2_base_1.print(this.printInstance.element, this.printWindow);
this.printWindow.onbeforeunload = function () {
if (_this.printInstance) {
_this.printInstance.off(events.print, _this.contentReady);
_this.printInstance.element.remove();
_this.printInstance.destroy();
_this.printInstance = null;
}
_this.printWindow = null;
};
};
Print.prototype.getModuleName = function () {
return 'print';
};
Print.prototype.destroy = function () {
this.parent = null;
};
return Print;
}());
exports.Print = Print;
});
|