feature: create css print
This commit is contained in:
34
src/main.ts
34
src/main.ts
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user