Переглянути джерело

Hide children transformation

master
Igor_Budimski 4 роки тому
джерело
коміт
d00891b4cd

+ 1
- 0
src/parameters/contracts.js Переглянути файл

@@ -19,6 +19,7 @@ const contracts = () =>
new Param("br-headerfirstpageonly",["table"]),
new Param("br-landscapetable",["table"]),
new Param("br-transformrotate",["div", "table"]),
new Param("br-hidechildren",["div"])
];
}


+ 5
- 0
src/transformations/hide-children/hide-child.css Переглянути файл

@@ -0,0 +1,5 @@
@media print{
.hide-child{
display: none !important;
}
}

+ 35
- 0
src/transformations/hide-children/hide-children.js Переглянути файл

@@ -0,0 +1,35 @@
import './hide-child.css';
import { Transform } from "../transform";
import $ from 'jquery';

export class Hidechildren extends Transform {
constructor(param) {
super(param);
this.object = param.object;
this.children = this.object.children;
this.class = null;
}

execute() {
for (var i = 0; i < this.children.length; i++) {
if (this.children[i].attributes.code) {
if (this.children[i].attributes.code.value !== "keep") {
$(this.children[i]).addClass('hide-child');
}
}else{
$(this.children[i]).addClass('hide-child');
}
}
this.class = this.object.parentElement.attributes.class.value;
$(this.object.parentElement).removeClass();
}

rolback() {
for (var i = 0; i < this.children.length; i++) {
$(this.children[i]).removeClass('hide-child');
if (this.class) {
$(this.object.parentElement).addClass(this.class);
}
}
}
}

+ 3
- 0
src/transforms-factory.js Переглянути файл

@@ -10,6 +10,7 @@ import { LandscapeTableTransform } from "./transformations/layout-table-transfor
import { HeaderEveryPageTransform } from "./transformations/header-transformations/header-every-page-transformation";
import { HeaderFirstPageOnlyTransform } from "./transformations/header-transformations/header-first-page-only-transformation";
import { TransformRotate } from "./transformations/transform-rotate";
import { Hidechildren } from "./transformations/hide-children/hide-children";

export class TransformsFactory {
produce(code, object, selectors) {
@@ -42,6 +43,8 @@ export class TransformsFactory {
return new HeaderFirstPageOnlyTransform(param);
case "br-transformrotate":
return new TransformRotate(param);
case "br-hidechildren":
return new Hidechildren(param);
}

return null;

Завантаження…
Відмінити
Зберегти