From 830c38a5eaf562b517f020eb795aa7566e02d399 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 28 Jan 2015 01:42:42 +0100 Subject: [PATCH] fix print --- bookmarklet.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index a813eed..55d1e8c 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,5 +1,18 @@ -version = "3.1.7"; +version = "3.1.8"; console.log("Version: " + version); + +var isDev = typeof isDev === 'undefined' || isDev ; + +hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/"; +if(isDev){ + console.log("DEVELOPMENT"); + hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/"; + isDev = false; +} + +cors = "https://cors-anywhere.herokuapp.com/"; +//$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html"); + // (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), @@ -15,7 +28,6 @@ ga('set', 'title', document.title); //ga('set', 'campaignMedium', '(none)'); // -var isDev try { // load jQuery @@ -37,17 +49,9 @@ try { printScopeDeviderToken = "Attachment"; - hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/"; - if(isDev){ - alert("Develop Version"); - hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/"; - } - resourceOrigin = hostOrigin+ "resources/"; - - cors = "https://cors-anywhere.herokuapp.com/"; - //$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html"); - console.logLevel = console.INFO; + + resourceOrigin = hostOrigin+ "resources/"; } function main(){ @@ -78,8 +82,11 @@ try { } function print(){ - ga('send', 'event', 'button', 'click', 'print', $(".card").length ); - jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print(); + var printFrame = jQuery("#card-print-dialog-content-iframe"); + var printWindow = printFrame[0].contentWindow; + var printDocument = printWindow.document; + ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length ); + printWindow.print(); } function renderCards(issueKeyList, callback) { @@ -1082,6 +1089,6 @@ try { 'exDescription': err.message, 'exFatal': true }); -} +}; + -isDev = false;