All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.pdf-exporter.js.starter.js Maven / Gradle / Ivy

Go to download

This Polarion extension provides possibility to convert Polarion Documents to PDF files. This is an alternative to native Polarion's solution.

There is a newer version: 7.0.1
Show newest version
const TOOLBAR_HTML = `
    
Export to PDF
`; const ALTERNATE_TOOLBAR_HTML = `
`; const PdfExporterStarter = { timestampParam: `?timestamp=${Date.now()}`, injectAll: function () { this.injectStyles("pdf-exporter-styles", `/polarion/pdf-exporter/css/pdf-exporter.css${this.timestampParam}`); this.injectStyles("pdf-micromodal-styles", `/polarion/pdf-exporter/css/micromodal.css${this.timestampParam}`); this.injectScript("ExportParams-script", `/polarion/pdf-exporter/js/modules/ExportParams.js${this.timestampParam}`, "module") .then(() => { Promise.all([ this.injectScript("ExportContext-script", `/polarion/pdf-exporter/js/modules/ExportContext.js${this.timestampParam}`, "module"), this.injectScript("common-script", `/polarion/pdf-exporter/ui/generic/js/common.js${this.timestampParam}`), this.injectScript("pdf-micromodal-script", `/polarion/pdf-exporter/js/micromodal.min.js${this.timestampParam}`), this.injectScript("export-common-script", `/polarion/pdf-exporter/js/export-common.js${this.timestampParam}`) ]).then(() => { this.injectScript("pdf-exporter-script", `/polarion/pdf-exporter/js/pdf-exporter.js${this.timestampParam}`); this.injectScript("bulk-pdf-exporter-script", `/polarion/pdf-exporter/js/bulk-pdf-exporter.js${this.timestampParam}`); }); }); }, injectStyles: function (id, stylesPath) { if (!top.document.getElementById(id)) { const styleElement = document.createElement("link"); styleElement.id = id; styleElement.rel = "stylesheet"; styleElement.type = "text/css"; styleElement.href = stylesPath; top.document.head.appendChild(styleElement); } }, injectScript: function (id, componentScriptPath, type = "text/javascript") { return new Promise((resolve) => { if (!top.document.getElementById(id)) { const scriptElement = document.createElement("script"); scriptElement.id = id; scriptElement.setAttribute("src", componentScriptPath); scriptElement.setAttribute("type", type); top.document.head.appendChild(scriptElement); } resolve(); }); }, injectToolbar: function (params) { if (params?.alternate) { const toolbarParent = top.document.querySelector('div.polarion-content-container div.polarion-Container div.polarion-dle-Container > div.polarion-dle-Wrapper > div.polarion-dle-RpcPanel > div.polarion-dle-MainDockPanel div.polarion-rte-ToolbarPanelWrapper table.polarion-dle-ToolbarPanel tr'); const toolbarContainer = document.createElement('td'); toolbarContainer.innerHTML = ALTERNATE_TOOLBAR_HTML.replaceAll("{TIMESTAMP_PARAM}", this.timestampParam); toolbarParent.insertBefore(toolbarContainer, toolbarParent.querySelector('td[width="100%"]')); } else { const documentFrame = top.document.querySelector('div.polarion-content-container div.polarion-Container div.polarion-dle-Container>div.polarion-dle-Wrapper>div.polarion-dle-RpcPanel>div.polarion-dle-MainDockPanel div.polarion-dle-SplitPanel:last-child .polarion-dle-RichTextArea'); const toolbarContainer = document.createElement('div'); toolbarContainer.classList.add("dleToolBarContainer"); toolbarContainer.style.marginRight = "14px"; toolbarContainer.innerHTML = TOOLBAR_HTML.replaceAll("{TIMESTAMP_PARAM}", this.timestampParam); documentFrame.parentNode.parentNode.prepend(toolbarContainer); } }, } PdfExporterStarter.injectAll();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy