define(["require", "exports", "@syncfusion/ej2-base", "../utils/helper", "../model/constants"], function (require, exports, ej2_base_1, helper_1, constants_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PrintUtils = (function () {
function PrintUtils(control) {
this.control = control;
}
PrintUtils.prototype.print = function (elements) {
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);
var argsData = {
cancel: false, htmlContent: this.getHTMLContent(elements), name: constants_1.beforePrint
};
this.control.trigger(constants_1.beforePrint, argsData);
if (!argsData.cancel) {
ej2_base_1.print(argsData.htmlContent, this.printWindow);
}
};
PrintUtils.prototype.getHTMLContent = function (elements) {
var div = ej2_base_1.createElement('div');
if (elements) {
if (elements instanceof Array) {
for (var j = 0; j < elements.length; j++) {
var value = elements[j];
div.appendChild(helper_1.getElement(value).cloneNode(true));
}
}
else if (elements instanceof Element) {
div.appendChild(elements.cloneNode(true));
}
else {
div.appendChild(helper_1.getElement(elements).cloneNode(true));
}
}
else {
div.appendChild(this.control.element.cloneNode(true));
}
for (var index = 0; index < div.children.length; index++) {
var backgroundColor = (this.control.theme.indexOf('Dark') > -1 || this.control.theme.indexOf('HighContrast') > -1) ? 'rgba(0, 0, 0, 1)' : 'rgba(255, 255, 255, 1)';
var svg = div.children[index];
for (var childIndex = 0; childIndex < svg.children.length; childIndex++) {
var actualBackgroundColor = void 0;
var isSVG = false;
if (svg.id.indexOf('_stockChart_svg') > -1) {
actualBackgroundColor = svg.children[0].getAttribute('fill');
isSVG = true;
}
else if (svg.children[childIndex].id.indexOf('_svg') > -1) {
actualBackgroundColor = svg.children[childIndex].children[0].getAttribute('fill');
isSVG = true;
}
if (isSVG) {
actualBackgroundColor = actualBackgroundColor === 'transparent' ? backgroundColor : actualBackgroundColor;
svg.children[childIndex].children[0].setAttribute('fill', actualBackgroundColor);
}
}
div[index] = svg;
}
return div;
};
return PrintUtils;
}());
exports.PrintUtils = PrintUtils;
});
|