1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| .factory('imprimerDiv',imprimerDiv);
function imprimerDiv(NomDeLaDiv ) {
notifier.notify('Fermez la fenêtre qui s\'ouvre pour revenir au programme');
var printContents = document.getElementById(NomDeLaDiv).innerHTML; //Récupère le contenu de la div a afficher dans le popup d impression
console.log(printContents);
var originalContents = document.body.innerHTML;
/* CODE SPECIAL POUR CHROME */
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
var popupWin = window.open('', '_blank', 'width=1200,height=1200,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no');
popupWin.window.focus();
popupWin.document.write('<!DOCTYPE html><html><head>' +
'<link rel="stylesheet" type="text/css" href="bower_components/barcodeGenerator/barcode.css" />' +
'</head><body onload="window.print()"><div class="reward-body">' + printContents + ' </div></html>');
popupWin.onbeforeunload = function (event) {
popupWin.close();
return '.\n';
};
popupWin.onabort = function (event) {
popupWin.document.close();
popupWin.close();
}
} else {
/* CODE POUR LES AUTRES NAVIGATEURS */
var popupWin = window.open('', '_blank', 'width=300,height=300');
popupWin.document.open();
popupWin.document.write('<html><head><link rel="stylesheet" type="text/css" href="bower_components/barcodeGenerator/barcode.css" /></head><body onload="window.print()">' + printContents + '</html>');
popupWin.document.close();
}
popupWin.document.close();
return true;
}; |
Partager