all files / treemap/model/ print.js

100% Statements 38/38
93.55% Branches 29/31
100% Functions 9/9
100% Lines 38/38
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     11× 11× 11× 11×     11× 11× 10×       11× 11×                                 11×   943×        
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 Print = (function () {
        function Print(control) {
        }
        Print.prototype.print = function (treeMap, elements) {
            var printWindow = window.open('', 'print', 'height=' + window.outerHeight + ',width=' + window.outerWidth + ',tabbar=no');
            printWindow.moveTo(0, 0);
            printWindow.resizeTo(screen.availWidth, screen.availHeight);
            var argsData = {
                cancel: false, htmlContent: this.getHTMLContent(treeMap, elements), name: constants_1.beforePrint
            };
            treeMap.trigger(constants_1.beforePrint, argsData, function () {
                if (!argsData.cancel) {
                    ej2_base_1.print(argsData.htmlContent, printWindow);
                }
            });
        };
        Print.prototype.getHTMLContent = function (treeMap, elements) {
            var div = ej2_base_1.createElement('div');
            if (elements) {
                if (elements instanceof Array) {
                    elements.forEach(function (value) {
                        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 {
                var exportElement = treeMap.element.cloneNode(true);
                var backgroundElement = exportElement.getElementsByTagName('svg')[0];
                Eif (!ej2_base_1.isNullOrUndefined(backgroundElement)) {
                    backgroundElement = backgroundElement.childNodes[0];
                    Eif (!ej2_base_1.isNullOrUndefined(backgroundElement)) {
                        var backgroundColor = backgroundElement.getAttribute('fill');
                        if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
                            treeMap.theme === 'Fluent2')
                            && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
                            backgroundElement.setAttribute('fill', 'rgba(255,255,255, 1)');
                        }
                        else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
                            treeMap.theme === 'Fluent2Dark' || treeMap.theme === 'Fluent2HighContrast')
                            && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
                            backgroundElement.setAttribute('fill', 'rgba(0, 0, 0, 1)');
                        }
                    }
                }
                div.appendChild(exportElement);
            }
            return div;
        };
        Print.prototype.getModuleName = function () {
            return 'Print';
        };
        Print.prototype.destroy = function () { };
        return Print;
    }());
    exports.Print = Print;
});