feature: create css print

This commit is contained in:
Matthieu CAILLEAUX
2021-10-14 00:08:38 +02:00
parent a4dae4877d
commit 043a7881df
2 changed files with 420 additions and 4 deletions

View File

@@ -1,5 +1,31 @@
//ActorSheet
Hooks.on(
'renderActorSheetWfrp4eCharacter',
(_app: ActorSheet, html: JQuery) => {
console.dir(_app);
addActorSheetActionButton(html, 'print', () => {
print(html);
});
}
);
Hooks.on('renderActorSheet', (_app: ActorSheet, _html: JQuery) => {
console.dir(_app);
});
function addActorSheetActionButton(
html: JQuery,
icon: string,
onClick: () => void
) {
const button = document.createElement('a');
button.classList.add('print');
button.innerHTML = `<i class="fas fa-${icon}"> </i>`;
button.addEventListener('click', () => {
onClick();
});
const header = html.find('.window-header');
const title = header.find('.window-title');
title.after(button);
}
function print(html: JQuery) {
$('.wfrp4e-print').removeClass('wfrp4e-print');
html.addClass('wfrp4e-print');
window.print();
}