| @@ -20,7 +20,8 @@ const contracts = () => | |||
| new Param("br-landscapetable",["table"]), | |||
| new Param("br-transformrotate",["div", "table"]), | |||
| new Param("br-isolatedlandscape",["div", "table"]), | |||
| new Param("br-hidechildren",["div"]) | |||
| new Param("br-hidechildren",["div"]), | |||
| new Param("br-root",["div"]) | |||
| ]; | |||
| } | |||
| @@ -5,15 +5,15 @@ | |||
| } | |||
| @media print { | |||
| .header-show { | |||
| position: fixed; | |||
| /* position: fixed; | |||
| z-index: 9999; | |||
| left:0; | |||
| top: 0; | |||
| top: 0; */ | |||
| } | |||
| table { page-break-after:auto } | |||
| tr { page-break-inside:avoid; page-break-after:auto } | |||
| td { page-break-inside:avoid; page-break-after:auto } | |||
| thead { page-break-inside: auto; } | |||
| thead { display:table-header-group } | |||
| /* display:table-header-group - Da bude na svakoj stranici */ | |||
| tfoot { display:table-footer-group } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| import {Transform} from "./transform"; | |||
| import $ from "jquery"; | |||
| export class IsolationTransform extends Transform { | |||
| constructor(param){ | |||
| super(param); | |||
| } | |||
| execute(){ | |||
| const targets = $(`[isolation="true"]`); | |||
| for(let i = 0; i < targets.length; i++){ | |||
| targets.removeAttr("isolation"); | |||
| } | |||
| $(this.object).attr("isolation", "true"); | |||
| } | |||
| rolback(){ | |||
| $(this.object).show(); | |||
| } | |||
| } | |||
| @@ -41,7 +41,7 @@ | |||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | |||
| const bytes = new Uint8Array(newBlob); | |||
| //console.log(bytes); | |||
| modifyPdf(bytes); | |||
| //modifyPdf(bytes); | |||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | |||
| if (window.navigator && window.navigator.msSaveOrOpenBlob) { | |||
| window.navigator.msSaveOrOpenBlob(newBlob); | |||
| @@ -0,0 +1,112 @@ | |||
| import { Transform } from "./transform"; | |||
| import $ from 'jquery'; | |||
| export class RootTransformation extends Transform | |||
| { | |||
| constructor(param){ | |||
| super(param); | |||
| this.before = {}; | |||
| } | |||
| execute(){ | |||
| let array = []; | |||
| this.before = $('#root'); | |||
| // const v = $(':eq(0)'); // za root element | |||
| const va = $('div.fade').children().toArray(); // gledamo div-fade kao root | |||
| let i = 1, temp = 0; | |||
| const divRootElement = document.createElement('div'); | |||
| divRootElement.className = 'root'; | |||
| const divElementPageBreak = document.createElement('div'); | |||
| divElementPageBreak.style.pageBreakBefore = "always"; | |||
| va.forEach(element => { | |||
| // 59.338582677165356 is sum of default top and bottom print margins | |||
| // 842 is height in pixels for A4 format | |||
| const razlika = element.clientHeight + temp - (i * 842 - 59.338582677165356); | |||
| if (razlika < 0) { | |||
| temp += element.clientHeight; | |||
| divRootElement.append(element); | |||
| console.log(temp); | |||
| } | |||
| else if (razlika === 0) { | |||
| i++; | |||
| temp = 0; | |||
| divRootElement.append(divElementPageBreak); | |||
| console.log(temp); | |||
| } | |||
| else { | |||
| if (element.hasChildNodes && element.childNodes.length === 1) { | |||
| const node = element.childNodes[0]; | |||
| if (node.hasChildNodes && node.childNodes.length === 1) { | |||
| const subNode = node.childNodes[0]; | |||
| if (subNode.hasChildNodes) { | |||
| const nodes = subNode.childNodes; | |||
| for (let j = 0; j < nodes.length; j++) { | |||
| const razlikaNodes = nodes[j].clientHeight + temp - (i * 842 - 59.338582677165356); | |||
| if (razlikaNodes < 0) { | |||
| temp += nodes[j].clientHeight; | |||
| console.log("bez apenda" + temp); | |||
| console.log(nodes[j]); | |||
| // divRootElement.append(nodes[j]); | |||
| array.push(nodes[j]); | |||
| } | |||
| else if (razlikaNodes === 0) { | |||
| i++; | |||
| temp = 0; | |||
| divRootElement.append(nodes[j]); | |||
| console.log(temp); | |||
| } | |||
| else { | |||
| if (nodes[j].hasChildNodes && nodes[j].childNodes.length > 1) { | |||
| const subNodes = nodes[j].childNodes; | |||
| for (let k = 0; k < subNodes.length; k++) { | |||
| const razlikaSubNodes = subNodes[k].clientHeight + temp - (i * 842 - 59.338582677165356); | |||
| if (razlikaSubNodes < 0) { | |||
| temp += subNodes[k].clientHeight; | |||
| divRootElement.append(subNodes[k]); | |||
| console.log(temp); | |||
| } | |||
| else { | |||
| i++; | |||
| temp = 0; | |||
| divRootElement.append(divElementPageBreak); | |||
| console.log(temp); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| else if (element.hasChildNodes && element.childNodes.length > 1) { | |||
| const nodes = element.childNodes; | |||
| for (let i = 0; i < nodes.length; i++) { | |||
| if (nodes[i].clientHeight + temp < (i * 842 - 59.338582677165356)) { | |||
| temp += nodes[i].clientHeight; | |||
| divRootElement.append(nodes[i]); | |||
| console.log(temp); | |||
| } | |||
| else { | |||
| i++; | |||
| temp = 0; | |||
| console.log("bez apenda" + temp); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }); | |||
| $('#root').empty(); | |||
| $('#root').append(divRootElement); | |||
| array.forEach(element => { | |||
| console.log(element); | |||
| }); | |||
| console.log(divRootElement); | |||
| } | |||
| rolback(){ | |||
| $('#root').empty(); | |||
| $('#root').append(this.before); | |||
| } | |||
| } | |||
| @@ -10,7 +10,7 @@ export class ShowNumberRowsTransformation extends Transform | |||
| execute(){ | |||
| const rows = this.value; | |||
| const count = ($(this.object).find("tbody")).children('tr').length; | |||
| $this.object.find("tbody").each(function () { | |||
| $(this.object).find("tbody").each(function () { | |||
| for(let i=rows;i<count;i++) | |||
| { | |||
| $(this).find('tr').eq(i).hide(); | |||
| @@ -23,7 +23,7 @@ export class ShowNumberRowsTransformation extends Transform | |||
| $this.object.find("tbody").each(function () { | |||
| for(let i=rows;i<count;i++) | |||
| { | |||
| $(this).find('tr').eq(i).hide(); | |||
| $(this).find('tr').eq(i).show(); | |||
| } | |||
| }); | |||
| }; | |||
| @@ -4,12 +4,15 @@ export class Transform{ | |||
| this.object = param.object; | |||
| this.selectors = param.selectors; | |||
| this.selector = this.object.tagName; | |||
| try{ | |||
| const arrayCode = this.object.getAttribute("code").split('-'); | |||
| if(arrayCode.length > 2) | |||
| { | |||
| this.value = arrayCode[2]; | |||
| } | |||
| } | |||
| catch{} | |||
| } | |||
| validate(){ | |||
| return (this.selectors.indexOf(this.selector.toLowerCase()) > -1); | |||
| }; | |||
| @@ -12,6 +12,8 @@ import { HeaderFirstPageOnlyTransform } from "./transformations/header-transform | |||
| import { TransformRotate } from "./transformations/transform-rotate"; | |||
| import { IsolatedLandscapeTransformation } from "./transformations/isolated-landscape-transformation"; | |||
| import { Hidechildren } from "./transformations/hide-children/hide-children"; | |||
| import { IsolationTransform } from "./transformations/isolation-transform"; | |||
| import { RootTransformation } from "./transformations/root-transformation"; | |||
| export class TransformsFactory { | |||
| produce(code, object, selectors) { | |||
| @@ -48,6 +50,10 @@ export class TransformsFactory { | |||
| return new IsolatedLandscapeTransformation(param); | |||
| case "br-hidechildren": | |||
| return new Hidechildren(param); | |||
| case "br-root": | |||
| return new RootTransformation(param); | |||
| case "isolate": | |||
| return new IsolationTransform(param); | |||
| } | |||
| return null; | |||