node_modules

This commit is contained in:
saeid
2019-07-15 13:07:31 +04:30
parent d3735c6d30
commit ce1a3ebf9c
35713 changed files with 3639219 additions and 1 deletions
+61
View File
@@ -0,0 +1,61 @@
function addStyles (win, styles) {
styles.forEach(style => {
let link = win.document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', style);
win.document.getElementsByTagName('head')[0].appendChild(link);
});
}
const VueHtmlToPaper = {
install (Vue, options) {
Vue.mixin({
methods: {
$htmlToPaper (el, cb) {
let {
name,
specs,
replace,
styles
} = options;
specs = !!specs.length ? specs.join(',') : '';
const element = document.getElementById(el);
if(!element) {
alert(`Element to print #${el} not found!`);
return;
}
const url = '';
const win = window.open(url, name, specs, replace);
win.document.write(`
<html>
<head>
<title>${document.title}</title>
</head>
<body>
${element.innerHTML}
</body>
</html>
`);
addStyles(win, styles);
setTimeout(() => {
win.document.close();
win.focus();
win.print();
win.close();
cb();
}, 1000);
return true;
}
}
});
}
}
export default VueHtmlToPaper;