From 28cdceda442bba1f70f51fb2349c58882d5ce37d Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Tue, 24 Nov 2015 20:08:49 +0100 Subject: [PATCH 01/11] Update bookmarklet.js --- bookmarklet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index fd60a84..fec7fbc 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -322,14 +322,14 @@ // substract one pixel due to rounding problems var cardMaxWidth = Math.floor(jQuery(".card", printDocument).outerWidth() / columnCount); var cardMinWidth = jQuery(".card", printDocument).css("min-width").replace("px", ""); - var scaleWidth = cardMaxWidth / cardMinWidth - (columnCount * 0.02); + var scaleWidth = cardMaxWidth / cardMinWidth; // scale vertical // substract one pixel due to rounding problems // dont know why to multiply outer height with 2 var cardMaxHeight = Math.floor(jQuery(".card", printDocument).outerHeight() * 2 / rowCount); var cardMinHeight = jQuery(".card", printDocument).css("min-height").replace("px", ""); - var scaleHeight = cardMaxHeight / cardMinHeight - (rowCount * 0.02); + var scaleHeight = cardMaxHeight / cardMinHeight; // scale down var scale = Math.min(scaleWidth, scaleHeight, 1); From 6649efdcfd2a78310e060fae708a2079f22420c2 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 07:05:34 +0100 Subject: [PATCH 02/11] Update bookmarklet.js --- bookmarklet.js | 100 +++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index fec7fbc..4df00ea 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,5 +1,5 @@ (function() { - var version = "4.2.0"; + var version = "4.2.1"; console.log("Version: " + version); var global = {}; @@ -667,9 +667,9 @@ function cardHtml(issueKey) { var page = jQuery(document.createElement('div')) .attr("id", issueKey) - .addClass("card") .html(multilineString(function() { /*! +
@@ -699,6 +699,7 @@ ©BengtBrodersen
qoomon.com
+
*/ })); @@ -725,6 +726,38 @@ body { padding: 0rem; margin: 0rem; } +.badge, .shadow { + border-style: solid; + border-color: #333; + border-top-width: 0.12rem; + border-left-width: 0.12rem; + border-bottom-width: 0.21rem; + border-right-width: 0.21rem; + border-radius: 0.25rem; +} +.badge { + // WHITESMOKE, GAINSBOROM; + background-color: #E0E0E0; +} +.hidden { + display: none; +} +.zigzag { + border-bottom-width: 0rem; +} +.zigzag::after { + position: absolute; + bottom: 0.03rem; + left:-0.16rem; + content:""; + width: 100%; + border-style:solid; + border-bottom-width: 1rem; + border-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/Tearing.png); + border-image-width: 0 0 0.7rem 0; + border-image-slice: 56 0 56 1; + border-image-repeat: round round; +} #preload { position: fixed; top: 0rem; @@ -811,7 +844,7 @@ body { top: 1.2rem; height: 1.5rem; max-width: calc(100% - 7.5rem); - min-width: 4rem; + min-width: 6.0rem; padding-left: 2.1rem; padding-right: 0.4rem; background-color: WHITESMOKE; @@ -837,35 +870,35 @@ body { top: 0rem; height: 3.0rem; width: 3.0rem; - border-radius: 50% !important; - background-color: LIGHTSEAGREEN !important; + border-radius: 50%; + background-color: LIGHTSEAGREEN; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Objects.png); background-repeat: no-repeat; background-position: center; background-size: 63%; } .issue-icon[type="story"], .issue-icon[type="user story"] { - background-color: GOLD !important; + background-color: GOLD; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bulb.png); } .issue-icon[type="bug"], .issue-icon[type="correction"] { - background-color: CRIMSON !important; + background-color: CRIMSON; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bug.png); } .issue-icon[type="epic"] { - background-color: ROYALBLUE !important; + background-color: ROYALBLUE; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Flash.png); } .issue-icon[type="task"] { - background-color: WHEAT !important; + background-color: WHEAT; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Task.png); } .issue-icon[type="new feature"] { - background-color: LIMEGREEN !important; + background-color: LIMEGREEN; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Plus.png); } .issue-icon[type="improvement"] { - background-color: CORNFLOWERBLUE !important; + background-color: CORNFLOWERBLUE; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Arrow.png); } .issue-estimate { @@ -874,7 +907,7 @@ body { top: 0.0rem; height: 1.6rem; width: 1.6rem; - border-radius: 50% !important; + border-radius: 50%; background-color: WHITESMOKE; line-height: 1.4rem; font-size: 0.9rem; @@ -898,8 +931,8 @@ body { top: 0rem; width: 2.0rem; height: 2.0rem; - border-radius: 50% !important; - background-color: LIGHTSKYBLUE !important; + border-radius: 50%; + background-color: LIGHTSKYBLUE; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Attachment.png); background-repeat: no-repeat; background-position: center; @@ -911,7 +944,7 @@ body { right:0rem; width: 2.2rem; height: 2.2rem; - border-radius: 50% !important; + border-radius: 50%; background-color: WHITESMOKE; //background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Person.png); background-repeat: no-repeat; @@ -978,45 +1011,14 @@ body { right: 0rem; width: 2.5rem; height: 2.5rem; - border-radius: 50% !important; - background-color: ORCHID !important; + border-radius: 50%; + background-color: ORCHID; background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/AlarmClock.png); background-repeat: no-repeat; background-position: center; background-size: 65%; } -.badge, .shadow { - border-style: solid; - border-color: #333; - border-top-width: 0.12rem; - border-left-width: 0.12rem; - border-bottom-width: 0.21rem; - border-right-width: 0.21rem; - border-radius: 0.25rem; -} -.badge { - // WHITESMOKE, GAINSBOROM; - background-color: #E0E0E0; -} -.hidden { - display: none; -} -.zigzag { - border-bottom-width: 0rem; -} -.zigzag::after { - position: absolute; - bottom: 0.03rem; - left:-0.16rem; - content:""; - width: 100%; - border-style:solid; - border-bottom-width: 1rem; - border-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/Tearing.png); - border-image-width: 0 0 0.7rem 0; - border-image-slice: 56 0 56 1; - border-image-repeat: round round; -} + @media print { @page { margin: 0.0mm; From e0f42bc6dc67a8429a936623b6a8d8c19697a2c1 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 07:34:17 +0100 Subject: [PATCH 03/11] Create card.html --- card.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 card.html diff --git a/card.html b/card.html new file mode 100644 index 0000000..47889ea --- /dev/null +++ b/card.html @@ -0,0 +1,31 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ ©BengtBrodersen
+ qoomon.com +
+
From 0b6a03641a034377655e3247aa381a2569a7d844 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 08:45:13 +0100 Subject: [PATCH 04/11] Update bookmarklet.js --- bookmarklet.js | 98 +++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 66 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 4df00ea..40572c1 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,11 +1,7 @@ (function() { - var version = "4.2.1"; - console.log("Version: " + version); - var global = {}; - global.isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira - || /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL) // PivotTracker - || (/.*trello.com\/.*/g.test(document.URL) && jQuery("span.js-member-name").text() == 'Bengt Brodersen'); // Trello + global.version = "4.2.1"; + global.isDev = document.scripts[document.scripts.length-1].src == ""; global.isProd = !global.isDev; window.addEventListener("error", function(event) { @@ -26,12 +22,15 @@ // wait untill all scripts loaded appendScript('https://qoomon.github.io/void', function() { - main(); + init().then(function(){ + main(); + }).catch(function(){ + alert("ERROR on init!"); + }); }); function main() { - init(); - + console.log("Run...") // determine application if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) { console.log("App: " + "Jira"); @@ -62,6 +61,8 @@ alert("Please select at least one issue."); return; } + + // open print preview jQuery("body").append(printOverlayHTML()); @@ -85,9 +86,9 @@ jQuery("#hide-due-date-checkbox").attr('checked', readCookie("card_printer_hide_due_date", 'false') == 'true'); jQuery("#hide-status-checkbox").attr('checked', readCookie("card_printer_hide_status", 'true') == 'true'); - jQuery("#card-print-dialog-title").text("Card Printer " + version + " - Loading issues..."); + jQuery("#card-print-dialog-title").text("Card Printer " + global.version + " - Loading issues..."); renderCards(issueKeyList, function() { - jQuery("#card-print-dialog-title").text("Card Printer " + version); + jQuery("#card-print-dialog-title").text("Card Printer " + global.version); //print(); }); @@ -97,6 +98,7 @@ } function init() { + console.log("Init...") addStringFunctions(); addDateFunctions(); @@ -110,6 +112,13 @@ if (global.isProd) { initGoogleAnalytics(); } + + var promises = []; + promises.push(httpGetCors(global.hostOrigin + "card.html", function(data){ + global.cardHtml = data; + console.log("foooooo: " + data); + })); + return Promise.all(promises); } function print() { @@ -141,19 +150,19 @@ var deferredList = []; jQuery.each(issueKeyList, function(index, issueKey) { - var page = cardHtml(issueKey); - page.attr("index", index); - page.hide(); - page.find('.issue-id').text(issueKey); - jQuery("body", printDocument).append(page); + var card = cardElement(issueKey); + card.attr("index", index); + card.hide(); + card.find('.issue-id').text(issueKey); + jQuery("body", printDocument).append(card); var deferred = addDeferred(deferredList); global.appFunctions.getCardData(issueKey, function(cardData) { //console.log("cardData: " + cardData); if (global.isProd) { ga('send', 'event', 'card', 'generate', cardData.type); } - fillCard(page, cardData); - page.show(); + fillCard(card, cardData); + card.show(); redrawCards(); deferred.resolve(); }); @@ -663,46 +672,11 @@ } // card layout: http://jsfiddle.net/qoomon/ykbLb2pw/76 - - function cardHtml(issueKey) { + + function cardElement(issueKey) { var page = jQuery(document.createElement('div')) .attr("id", issueKey) - .html(multilineString(function() { -/*! -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
- ©BengtBrodersen
- qoomon.com -
-
-*/ - })); - + .html(global.cardHtml); return page; } @@ -1312,16 +1286,8 @@ body { }; } - function httpGet(url){ - var response; - jQuery.ajax({ - url: 'https://jsonp.afeld.me/?url=' + url, - success: function (data) { - result = data - }, - async: false - }); - return response; + function httpGetCors(url, callback){ + return jQuery.get('https://jsonp.afeld.me/?url=' + url, callback); } From 6ea0d253f4a9dff2ede66e176731c844428e678e Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 08:51:24 +0100 Subject: [PATCH 05/11] Update bookmarklet.js --- bookmarklet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 40572c1..7839e4e 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,7 +1,7 @@ (function() { var global = {}; - global.version = "4.2.1"; - global.isDev = document.scripts[document.scripts.length-1].src == ""; + global.version = "4.2.1.1"; + global.isDev = document.currentScript == null; global.isProd = !global.isDev; window.addEventListener("error", function(event) { From b690b314febc87c7a1aa6a835f148aa9dd08b7b9 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 12:01:42 +0100 Subject: [PATCH 06/11] refactor: promises --- bookmarklet.js | 219 +++++++++++++++++++------------------------------ 1 file changed, 84 insertions(+), 135 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 7839e4e..4d03494 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -22,10 +22,10 @@ // wait untill all scripts loaded appendScript('https://qoomon.github.io/void', function() { - init().then(function(){ + init().then(function(){ main(); - }).catch(function(){ - alert("ERROR on init!"); + }).catch(function(cause){ + alert("ERROR on init!\n\n" + cause); }); }); @@ -61,8 +61,6 @@ alert("Please select at least one issue."); return; } - - // open print preview jQuery("body").append(printOverlayHTML()); @@ -87,7 +85,7 @@ jQuery("#hide-status-checkbox").attr('checked', readCookie("card_printer_hide_status", 'true') == 'true'); jQuery("#card-print-dialog-title").text("Card Printer " + global.version + " - Loading issues..."); - renderCards(issueKeyList, function() { + renderCards(issueKeyList).then(function() { jQuery("#card-print-dialog-title").text("Card Printer " + global.version); //print(); }); @@ -98,6 +96,8 @@ } function init() { + var promises = []; + console.log("Init...") addStringFunctions(); addDateFunctions(); @@ -112,8 +112,8 @@ if (global.isProd) { initGoogleAnalytics(); } - - var promises = []; + + promises.push(httpGetCors(global.hostOrigin + "card.html", function(data){ global.cardHtml = data; console.log("foooooo: " + data); @@ -133,7 +133,7 @@ printWindow.print(); } - function renderCards(issueKeyList, callback) { + function renderCards(issueKeyList) { var printFrame = jQuery("#card-print-dialog-content-iframe"); var printWindow = printFrame[0].contentWindow; @@ -148,15 +148,15 @@ console.log("load " + issueKeyList.length + " issues..."); - var deferredList = []; + var promises = []; jQuery.each(issueKeyList, function(index, issueKey) { var card = cardElement(issueKey); card.attr("index", index); card.hide(); card.find('.issue-id').text(issueKey); jQuery("body", printDocument).append(card); - var deferred = addDeferred(deferredList); - global.appFunctions.getCardData(issueKey, function(cardData) { + + promises.push(global.appFunctions.getCardData(issueKey).then(function(cardData) { //console.log("cardData: " + cardData); if (global.isProd) { ga('send', 'event', 'card', 'generate', cardData.type); @@ -164,19 +164,18 @@ fillCard(card, cardData); card.show(); redrawCards(); - deferred.resolve(); - }); + })); }); console.log("wait for issues loaded..."); - applyDeferred(deferredList, function() { + return Promise.all(promises).then(function() { console.log("...all issues loaded."); + jQuery(printWindow).load(function() { console.log("...all resources loaded."); - callback(); - }) - printDocument.close(); + }); console.log("wait for resources loaded..."); + printDocument.close(); }); } @@ -319,7 +318,7 @@ var cardCount = jQuery(".card", printDocument).length; var pageCount = Math.ceil(cardCount / (columnCount * rowCount)) - + // scale // reset scale @@ -672,7 +671,7 @@ } // card layout: http://jsfiddle.net/qoomon/ykbLb2pw/76 - + function cardElement(issueKey) { var page = jQuery(document.createElement('div')) .attr("id", issueKey) @@ -1054,16 +1053,6 @@ body { //############################################################################################################################ //############################################################################################################################ - function addDeferred(deferredList) { - var deferred = new jQuery.Deferred() - deferredList.push(deferred); - return deferred; - } - - function applyDeferred(deferredList, callback) { - jQuery.when.apply(jQuery, deferredList).done(callback); - } - function readCookie(name, defaultValue) { var cookies = document.cookie.split('; '); @@ -1285,7 +1274,7 @@ body { } }; } - + function httpGetCors(url, callback){ return jQuery.get('https://jsonp.afeld.me/?url=' + url, callback); } @@ -1325,7 +1314,7 @@ body { async: false, success: function(responseData) { console.log("responseData: " + responseData.issues); - + jQuery.each(responseData.issues, function(key, value) { jqlIssues.push(value.key); }); @@ -1334,12 +1323,12 @@ body { console.log("jqlIssues: " + jqlIssues); return jqlIssues; } - + //Browse if (/.*\/browse\/.*/g.test(document.URL)) { return [document.URL.replace(/.*\/browse\/([^?]*).*/, '$1')]; } - + //Project if (/.*\/projects\/.*/g.test(document.URL)) { return [document.URL.replace(/.*\/projects\/[^\/]*\/[^\/]*\/([^?]*).*/, '$1')]; @@ -1355,17 +1344,14 @@ body { return []; }; - module.getCardData = function(issueKey, callback) { - module.getIssueData(issueKey, function(data) { - - var issueData = {}; + module.getCardData = function(issueKey) { + var promises = []; + var issueData = {}; + promises.push(module.getIssueData(issueKey).then(function(data) { issueData.key = data.key; - issueData.type = data.fields.issuetype.name.toLowerCase(); - issueData.summary = data.fields.summary; - issueData.description = data.renderedFields.description; if (data.fields.assignee) { @@ -1381,14 +1367,13 @@ body { } issueData.hasAttachment = data.fields.attachment.length > 0; - issueData.storyPoints = data.fields.storyPoints; - issueData.epicKey = data.fields.epicLink; + if (issueData.epicKey) { - jiraFunctions.getIssueData(issueData.epicKey, function(data) { + promises.push(module.getIssueData(issueData.epicKey).then(function(data) { issueData.epicName = data.fields.epicName; - }, false); + })); } issueData.url = window.location.origin + "/browse/" + issueData.key; @@ -1400,35 +1385,30 @@ body { issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.'); } } + })); - callback(issueData); - }); + return new Promise(function(resolve, reject) { + Promise.all(promises) + .then(function(){resolve(issueData);}) + .catch(function(cause){reject(cause);}); + }); }; - module.getIssueData = function(issueKey, callback, async) { - async = typeof async !== 'undefined' ? async : true; + module.getIssueData = function(issueKey) { //https://docs.atlassian.com/jira/REST/latest/ var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names'; console.log("IssueUrl: " + url); //console.log("Issue: " + issueKey + " Loading..."); - jQuery.ajax({ - type: 'GET', - url: url, - data: {}, - dataType: 'json', - async: async, - success: function(responseData) { - //console.log("Issue: " + issueKey + " Loaded!"); - // add custom fields with field names - jQuery.each(responseData.names, function(key, value) { - if (key.startsWith("customfield_")) { - var fieldName = value.toCamelCase(); - //console.log("add new field: " + fieldName + " with value from " + key); - responseData.fields[fieldName] = responseData.fields[key]; - } - }); - callback(responseData); - }, + return jQuery.getJSON(url).then(function(responseData) { + //console.log("Issue: " + issueKey + " Loaded!"); + // add custom fields with field names + jQuery.each(responseData.names, function(key, value) { + if (key.startsWith("customfield_")) { + var fieldName = value.toCamelCase(); + //console.log("add new field: " + fieldName + " with value from " + key); + responseData.fields[fieldName] = responseData.fields[key]; + } + }); }); }; @@ -1453,17 +1433,14 @@ body { return []; }; - module.getCardData = function(issueKey, callback) { - module.getIssueData(issueKey, function(data) { - - var issueData = {}; + module.getCardData = function(issueKey) { + var promises = []; + var issueData = {}; + promises.push(module.getIssueData(issueKey, function(data) { issueData.key = data.id; - issueData.type = data.field.type[0]; - issueData.summary = data.field.summary; - issueData.description = data.field.description; if (data.field.assignee) { @@ -1492,34 +1469,27 @@ body { // } // issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key; + })); - callback(issueData); + return new Promise(function(resolve, reject) { + Promise.all(promises) + .then(function(){resolve(issueData);}) + .catch(function(cause){reject(cause);}); }); }; - module.getIssueData = function(issueKey, callback, async) { - async = typeof async !== 'undefined' ? async : true; - //https://docs.atlassian.com/jira/REST/latest/ + module.getIssueData = function(issueKey) { var url = '/youtrack/rest/issue/' + issueKey + '?'; console.log("IssueUrl: " + url); //console.log("Issue: " + issueKey + " Loading..."); - jQuery.ajax({ - type: 'GET', - url: url, - data: {}, - dataType: 'json', - async: async, - success: function(responseData) { - //console.log("Issue: " + issueKey + " Loaded!"); - jQuery.each(responseData.field, function(key, value) { - // add fields with field names - var fieldName = value.name.toCamelCase(); - //console.log("add new field: " + newFieldId + " with value from " + fieldName); - responseData.field[fieldName] = value.value; - - }); - callback(responseData); - }, + return jQuery.getJSON(url).then(function(responseData) { + //console.log("Issue: " + issueKey + " Loaded!"); + jQuery.each(responseData.field, function(key, value) { + // add fields with field names + var fieldName = value.name.toCamelCase(); + //console.log("add new field: " + newFieldId + " with value from " + fieldName); + responseData.field[fieldName] = value.value; + }); }); }; @@ -1544,17 +1514,14 @@ body { return []; }; - module.getCardData = function(issueKey, callback) { - module.getIssueData(issueKey, function(data) { - - var issueData = {}; + module.getCardData = function(issueKey) { + var promises = []; + var issueData = {}; + promises.push(module.getIssueData(issueKey, function(data) { issueData.key = data.id; - issueData.type = data.kind.toLowerCase(); - issueData.summary = data.name; - issueData.description = data.description; if (data.owned_by && data.owned_by.length > 0) { @@ -1567,7 +1534,6 @@ body { // TODO issueData.hasAttachment = false; - issueData.storyPoints = data.estimate; // TODO @@ -1579,28 +1545,21 @@ body { // } issueData.url = data.url; + })); - callback(issueData); + return new Promise(function(resolve, reject) { + Promise.all(promises) + .then(function(){resolve(issueData);}) + .catch(function(cause){reject(cause);}); }); }; module.getIssueData = function(issueKey, callback, async) { - async = typeof async !== 'undefined' ? async : true; //http://www.pivotaltracker.com/help/api var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline"; console.log("IssueUrl: " + url); //console.log("Issue: " + issueKey + " Loading..."); - jQuery.ajax({ - type: 'GET', - url: url, - data: {}, - dataType: 'json', - async: async, - success: function(responseData) { - //console.log("Issue: " + issueKey + " Loaded!"); - callback(responseData); - }, - }); + return jQuery.getJSON(url); }; return module; @@ -1618,17 +1577,16 @@ body { }; module.getCardData = function(issueKey, callback) { - module.getIssueData(issueKey, function(data) { - - var issueData = {}; + var promises = []; + var issueData = {}; + promises.push(module.getIssueData(issueKey, function(data) { issueData.key = data.idShort; // TODO get kind from label name // issueData.type = data.kind.toLowerCase(); issueData.summary = data.name; - issueData.description = data.desc; if (data.members && data.members.length > 0) { @@ -1641,30 +1599,21 @@ body { } issueData.hasAttachment = data.attachments > 0; - issueData.url = data.shortUrl; + })); - callback(issueData); + return new Promise(function(resolve, reject) { + Promise.all(promises) + .then(function(){resolve(issueData);}) + .catch(function(cause){reject(cause);}); }); }; module.getIssueData = function(issueKey, callback, async) { - async = typeof async !== 'undefined' ? async : true; - //http://www.pivotaltracker.com/help/api var url = "https://trello.com/1/cards/" + issueKey + "?members=true"; console.log("IssueUrl: " + url); //console.log("Issue: " + issueKey + " Loading..."); - jQuery.ajax({ - type: 'GET', - url: url, - data: {}, - dataType: 'json', - async: async, - success: function(responseData) { - //console.log("Issue: " + issueKey + " Loaded!"); - callback(responseData); - }, - }); + return jQuery.getJSON(url); }; return module; From 4bdee03fe79c8d0c34fb85813fe27f2d12f0735c Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 12:09:32 +0100 Subject: [PATCH 07/11] extract card.css --- bookmarklet.js | 336 ++----------------------------------------------- card.css | 321 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 328 insertions(+), 329 deletions(-) create mode 100644 card.css diff --git a/bookmarklet.js b/bookmarklet.js index 4d03494..e41591b 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -25,7 +25,7 @@ init().then(function(){ main(); }).catch(function(cause){ - alert("ERROR on init!\n\n" + cause); + alert("ERROR on init!\n\n" + JSON.stringify(cause,2,2)); }); }); @@ -113,11 +113,14 @@ initGoogleAnalytics(); } - promises.push(httpGetCors(global.hostOrigin + "card.html", function(data){ global.cardHtml = data; - console.log("foooooo: " + data); })); + + promises.push(httpGetCors(global.hostOrigin + "card.css", function(data){ + global.cardCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin); + })); + return Promise.all(promises); } @@ -682,332 +685,7 @@ function cardCss() { var result = jQuery(document.createElement('style')) .attr("type", "text/css") - .html(multilineString(function() { -/*! -* { - box-sizing: border-box; - overflow: hidden; -} -html { - background: WHITE; - padding: 0rem; - margin: 0rem; - font-size: 1.3cm; - overflow-y: scroll; -} -body { - padding: 0rem; - margin: 0rem; -} -.badge, .shadow { - border-style: solid; - border-color: #333; - border-top-width: 0.12rem; - border-left-width: 0.12rem; - border-bottom-width: 0.21rem; - border-right-width: 0.21rem; - border-radius: 0.25rem; -} -.badge { - // WHITESMOKE, GAINSBOROM; - background-color: #E0E0E0; -} -.hidden { - display: none; -} -.zigzag { - border-bottom-width: 0rem; -} -.zigzag::after { - position: absolute; - bottom: 0.03rem; - left:-0.16rem; - content:""; - width: 100%; - border-style:solid; - border-bottom-width: 1rem; - border-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/Tearing.png); - border-image-width: 0 0 0.7rem 0; - border-image-slice: 56 0 56 1; - border-image-repeat: round round; -} -#preload { - position: fixed; - top: 0rem; - left: 100%; -} -.author { - color: DIMGREY; - position: absolute; - top:0.35rem; - left:calc(50% - 2rem); - font-size: 0.6rem; - overflow:visible; - line-height: 0.38rem; -} -.author > span { - position: relative; - left: 0.23rem; - font-size: 0.6em; - text-align: center; -} -.card { - position: relative; - float:left; - height: 100%; - width: 100%; - padding: 0.5cm; - min-width:14.5rem; - min-height:10.0rem; - border-color: LightGray; - border-style: dotted; - border-width: 0.03cm; -} -.card-content { - position: relative; - height: 100%; - // find .card-header; - padding-top: 2rem; - // find .card-footer; - padding-bottom: 1.3rem; -} -.card-body { - position: relative; - height: 100%; - margin-left: 0.4rem; - margin-right: 0.4rem; - padding-top: 1.1rem; - padding-bottom: 1.1rem; - padding-left: 0.4rem; - padding-right: 0.4rem; - background: WHITE; -} -.card-header { - position: absolute; - top: 0rem; - height: 4.2rem; - width: 100%; -} -.card-footer { - position: absolute; - bottom: 0rem; - height: 2.2rem; - width: 100%; -} -.issue-summary { - font-weight: bold; - font-size: 0.9rem; -} -.issue-description { - margin-top: 0.1rem; - display: block; - font-size: 0.6rem; - line-height: 0.62rem; - overflow: hidden; -} -.issue-description p:first-of-type { - margin-top: 0rem; -} -.issue-description p:last-of-type { - margin-bottom: 0rem; -} -.issue-id { - position: absolute; - left: 1rem; - top: 1.2rem; - height: 1.5rem; - max-width: calc(100% - 7.5rem); - min-width: 6.0rem; - padding-left: 2.1rem; - padding-right: 0.4rem; - background-color: WHITESMOKE; - line-height: 1.3rem; - font-size: 0.8rem; - font-weight: bold; - text-align: center; - white-space: nowrap; - direction: rtl; -} -.issue-id-fadeout { - position: absolute; - left: 2.4rem; - top: 1.2rem; - width: 1.2rem; - height: 1.3rem; - z-index: 0; - background: linear-gradient(to left, rgba(224, 224, 224, 0) 0%, rgba(224, 224, 224, 1) 60%); -} -.issue-icon { - position: absolute; - left: 0rem; - top: 0rem; - height: 3.0rem; - width: 3.0rem; - border-radius: 50%; - background-color: LIGHTSEAGREEN; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Objects.png); - background-repeat: no-repeat; - background-position: center; - background-size: 63%; -} -.issue-icon[type="story"], .issue-icon[type="user story"] { - background-color: GOLD; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bulb.png); -} -.issue-icon[type="bug"], .issue-icon[type="correction"] { - background-color: CRIMSON; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bug.png); -} -.issue-icon[type="epic"] { - background-color: ROYALBLUE; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Flash.png); -} -.issue-icon[type="task"] { - background-color: WHEAT; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Task.png); -} -.issue-icon[type="new feature"] { - background-color: LIMEGREEN; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Plus.png); -} -.issue-icon[type="improvement"] { - background-color: CORNFLOWERBLUE; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Arrow.png); -} -.issue-estimate { - position: absolute; - left: 2.5rem; - top: 0.0rem; - height: 1.6rem; - width: 1.6rem; - border-radius: 50%; - background-color: WHITESMOKE; - line-height: 1.4rem; - font-size: 0.9rem; - font-weight: bold; - text-align: center; -} -.issue-qr-code { - position: absolute; - left:0rem; - top: 0rem; - width: 2.2rem; - height: 2.2rem; - background-image: url(https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=blog.qoomon.com); - background-repeat: no-repeat; - background-size: cover; - background-position: center; -} -.issue-attachment { - position: absolute; - left:2.5rem; - top: 0rem; - width: 2.0rem; - height: 2.0rem; - border-radius: 50%; - background-color: LIGHTSKYBLUE; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Attachment.png); - background-repeat: no-repeat; - background-position: center; - background-size: 70%; -} -.issue-assignee { - position: absolute; - top:0rem; - right:0rem; - width: 2.2rem; - height: 2.2rem; - border-radius: 50%; - background-color: WHITESMOKE; - //background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Person.png); - background-repeat: no-repeat; - background-position: center; - background-size: cover; - //-webkit-filter: contrast(200%) grayscale(100%); - //filter: contrast(200%) grayscale(100%); - text-align: center; - font-weight: bold; - font-size: 1.4rem; - line-height: 1.9rem; -} -.issue-epic-box { - position: absolute; - right:2.5rem; - top: 0rem; - width: auto; - min-width: 2rem; - width: auto; - max-width: calc(100% - 7.5rem); - height: auto; - max-height: 2.2rem; - padding-top: 0.1rem; - padding-bottom: 0.2rem; - padding-left: 0.3rem; - padding-right: 0.3rem; - text-align: left; - font-size: 0.5rem; - line-height: 0.55rem; -} -.issue-epic-id { - font-size: 0.5rem; - font-weight: bold; - max-width: 1rem; -} -.issue-epic-name { - margin-left: 0.1rem; - font-size: 0.6rem; - font-weight: bold; -} -.issue-due-date-box { - position: absolute; - right: 0rem; - top: 0rem; - overflow: visible !important; -} -.issue-due-date { - position: absolute; - top: 1.3rem; - right: 1rem; - width: 5.3rem; - min-width: 2.8rem; - height: 1.3rem; - padding-left: 0.2rem; - padding-right: 1.4rem; - text-align: center; - font-weight: bold; - font-size: 0.7rem; - line-height: 1.0rem; -} -.issue-due-icon { - position: absolute; - top: 0.5rem; - right: 0rem; - width: 2.5rem; - height: 2.5rem; - border-radius: 50%; - background-color: ORCHID; - background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/AlarmClock.png); - background-repeat: no-repeat; - background-position: center; - background-size: 65%; -} - -@media print { - @page { - margin: 0.0mm; - padding: 0.0mm; - } - html { - -webkit-print-color-adjust:exact; - print-color-adjust: exact; - } - .card { - page-break-inside: avoid; - } -} -} -*/ - }).replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin)); + .html(global.cardCss); return result; } diff --git a/card.css b/card.css new file mode 100644 index 0000000..92c5ba2 --- /dev/null +++ b/card.css @@ -0,0 +1,321 @@ +* { + box-sizing: border-box; + overflow: hidden; +} +html { + background: WHITE; + padding: 0rem; + margin: 0rem; + font-size: 1.3cm; + overflow-y: scroll; +} +body { + padding: 0rem; + margin: 0rem; +} +.badge, .shadow { + border-style: solid; + border-color: #333; + border-top-width: 0.12rem; + border-left-width: 0.12rem; + border-bottom-width: 0.21rem; + border-right-width: 0.21rem; + border-radius: 0.25rem; +} +.badge { + // WHITESMOKE, GAINSBOROM; + background-color: #E0E0E0; +} +.hidden { + display: none; +} +.zigzag { + border-bottom-width: 0rem; +} +.zigzag::after { + position: absolute; + bottom: 0.03rem; + left:-0.16rem; + content:""; + width: 100%; + border-style:solid; + border-bottom-width: 1rem; + border-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/Tearing.png); + border-image-width: 0 0 0.7rem 0; + border-image-slice: 56 0 56 1; + border-image-repeat: round round; +} +#preload { + position: fixed; + top: 0rem; + left: 100%; +} +.author { + color: DIMGREY; + position: absolute; + top:0.35rem; + left:calc(50% - 2rem); + font-size: 0.6rem; + overflow:visible; + line-height: 0.38rem; +} +.author > span { + position: relative; + left: 0.23rem; + font-size: 0.6em; + text-align: center; +} +.card { + position: relative; + float:left; + height: 100%; + width: 100%; + padding: 0.5cm; + min-width:14.5rem; + min-height:10.0rem; + border-color: LightGray; + border-style: dotted; + border-width: 0.03cm; +} +.card-content { + position: relative; + height: 100%; + // find .card-header; + padding-top: 2rem; + // find .card-footer; + padding-bottom: 1.3rem; +} +.card-body { + position: relative; + height: 100%; + margin-left: 0.4rem; + margin-right: 0.4rem; + padding-top: 1.1rem; + padding-bottom: 1.1rem; + padding-left: 0.4rem; + padding-right: 0.4rem; + background: WHITE; +} +.card-header { + position: absolute; + top: 0rem; + height: 4.2rem; + width: 100%; +} +.card-footer { + position: absolute; + bottom: 0rem; + height: 2.2rem; + width: 100%; +} +.issue-summary { + font-weight: bold; + font-size: 0.9rem; +} +.issue-description { + margin-top: 0.1rem; + display: block; + font-size: 0.6rem; + line-height: 0.62rem; + overflow: hidden; +} +.issue-description p:first-of-type { + margin-top: 0rem; +} +.issue-description p:last-of-type { + margin-bottom: 0rem; +} +.issue-id { + position: absolute; + left: 1rem; + top: 1.2rem; + height: 1.5rem; + max-width: calc(100% - 7.5rem); + min-width: 6.0rem; + padding-left: 2.1rem; + padding-right: 0.4rem; + background-color: WHITESMOKE; + line-height: 1.3rem; + font-size: 0.8rem; + font-weight: bold; + text-align: center; + white-space: nowrap; + direction: rtl; +} +.issue-id-fadeout { + position: absolute; + left: 2.4rem; + top: 1.2rem; + width: 1.2rem; + height: 1.3rem; + z-index: 0; + background: linear-gradient(to left, rgba(224, 224, 224, 0) 0%, rgba(224, 224, 224, 1) 60%); +} +.issue-icon { + position: absolute; + left: 0rem; + top: 0rem; + height: 3.0rem; + width: 3.0rem; + border-radius: 50%; + background-color: LIGHTSEAGREEN; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Objects.png); + background-repeat: no-repeat; + background-position: center; + background-size: 63%; +} +.issue-icon[type="story"], .issue-icon[type="user story"] { + background-color: GOLD; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bulb.png); +} +.issue-icon[type="bug"], .issue-icon[type="correction"] { + background-color: CRIMSON; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Bug.png); +} +.issue-icon[type="epic"] { + background-color: ROYALBLUE; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Flash.png); +} +.issue-icon[type="task"] { + background-color: WHEAT; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Task.png); +} +.issue-icon[type="new feature"] { + background-color: LIMEGREEN; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Plus.png); +} +.issue-icon[type="improvement"] { + background-color: CORNFLOWERBLUE; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Arrow.png); +} +.issue-estimate { + position: absolute; + left: 2.5rem; + top: 0.0rem; + height: 1.6rem; + width: 1.6rem; + border-radius: 50%; + background-color: WHITESMOKE; + line-height: 1.4rem; + font-size: 0.9rem; + font-weight: bold; + text-align: center; +} +.issue-qr-code { + position: absolute; + left:0rem; + top: 0rem; + width: 2.2rem; + height: 2.2rem; + background-image: url(https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=blog.qoomon.com); + background-repeat: no-repeat; + background-size: cover; + background-position: center; +} +.issue-attachment { + position: absolute; + left:2.5rem; + top: 0rem; + width: 2.0rem; + height: 2.0rem; + border-radius: 50%; + background-color: LIGHTSKYBLUE; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Attachment.png); + background-repeat: no-repeat; + background-position: center; + background-size: 70%; +} +.issue-assignee { + position: absolute; + top:0rem; + right:0rem; + width: 2.2rem; + height: 2.2rem; + border-radius: 50%; + background-color: WHITESMOKE; + //background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/Person.png); + background-repeat: no-repeat; + background-position: center; + background-size: cover; + //-webkit-filter: contrast(200%) grayscale(100%); + //filter: contrast(200%) grayscale(100%); + text-align: center; + font-weight: bold; + font-size: 1.4rem; + line-height: 1.9rem; +} +.issue-epic-box { + position: absolute; + right:2.5rem; + top: 0rem; + width: auto; + min-width: 2rem; + width: auto; + max-width: calc(100% - 7.5rem); + height: auto; + max-height: 2.2rem; + padding-top: 0.1rem; + padding-bottom: 0.2rem; + padding-left: 0.3rem; + padding-right: 0.3rem; + text-align: left; + font-size: 0.5rem; + line-height: 0.55rem; +} +.issue-epic-id { + font-size: 0.5rem; + font-weight: bold; + max-width: 1rem; +} +.issue-epic-name { + margin-left: 0.1rem; + font-size: 0.6rem; + font-weight: bold; +} +.issue-due-date-box { + position: absolute; + right: 0rem; + top: 0rem; + overflow: visible !important; +} +.issue-due-date { + position: absolute; + top: 1.3rem; + right: 1rem; + width: 5.3rem; + min-width: 2.8rem; + height: 1.3rem; + padding-left: 0.2rem; + padding-right: 1.4rem; + text-align: center; + font-weight: bold; + font-size: 0.7rem; + line-height: 1.0rem; +} +.issue-due-icon { + position: absolute; + top: 0.5rem; + right: 0rem; + width: 2.5rem; + height: 2.5rem; + border-radius: 50%; + background-color: ORCHID; + background-image: url(https://qoomon.github.io/Jira-Issue-Card-Printer/resources/icons/AlarmClock.png); + background-repeat: no-repeat; + background-position: center; + background-size: 65%; +} + +@media print { + @page { + margin: 0.0mm; + padding: 0.0mm; + } + html { + -webkit-print-color-adjust:exact; + print-color-adjust: exact; + } + .card { + page-break-inside: avoid; + } +} From 46f908bab0a111c6868f76344b52a801af08d93a Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 12:17:08 +0100 Subject: [PATCH 08/11] minor fixes --- bookmarklet.js | 5 +++-- card.css | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index e41591b..bdcad85 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,6 +1,7 @@ (function() { var global = {}; global.version = "4.2.1.1"; + global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer"; global.isDev = document.currentScript == null; global.isProd = !global.isDev; @@ -25,7 +26,7 @@ init().then(function(){ main(); }).catch(function(cause){ - alert("ERROR on init!\n\n" + JSON.stringify(cause,2,2)); + alert("ERROR on init! Please create an issue at " + global.issueTrackingUrl); }); }); @@ -45,7 +46,7 @@ console.log("App: " + "YouTrack"); global.appFunctions = youTrackFunctions; } else { - alert("Unsupported app.Please create an issue at https://github.com/qoomon/Jira-Issue-Card-Printer"); + alert("Unsupported app. Please create an issue at " + global.issueTrackingUrl); return; } diff --git a/card.css b/card.css index 92c5ba2..13d3572 100644 --- a/card.css +++ b/card.css @@ -145,9 +145,9 @@ body { .issue-id-fadeout { position: absolute; left: 2.4rem; - top: 1.2rem; + top: 1.3rem; width: 1.2rem; - height: 1.3rem; + height: 1.2rem; z-index: 0; background: linear-gradient(to left, rgba(224, 224, 224, 0) 0%, rgba(224, 224, 224, 1) 60%); } From ea190a7cfc774a8add9435caee66f58ebc2131b0 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 12:56:03 +0100 Subject: [PATCH 09/11] extract print preview html and css --- bookmarklet.js | 187 +++++++--------------------------------------- printPreview.css | 107 ++++++++++++++++++++++++++ printPreview.html | 29 +++++++ 3 files changed, 162 insertions(+), 161 deletions(-) create mode 100644 printPreview.css create mode 100644 printPreview.html diff --git a/bookmarklet.js b/bookmarklet.js index bdcad85..3801625 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -64,8 +64,8 @@ } // open print preview - jQuery("body").append(printOverlayHTML()); - jQuery("#card-print-overlay").prepend(printOverlayStyle()); + jQuery("body").append(printPreviewElement()); + jQuery("#card-print-overlay").prepend(printOverlayStyleElement()); var printFrame = jQuery("#card-print-dialog-content-iframe"); var printWindow = printFrame[0].contentWindow; @@ -122,6 +122,14 @@ global.cardCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin); })); + promises.push(httpGetCors(global.hostOrigin + "printPreview.html", function(data){ + global.printPreviewHtml = data + })); + + promises.push(httpGetCors(global.hostOrigin + "printPreview.css", function(data){ + global.printPreviewCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin); + })); + return Promise.all(promises); } @@ -138,6 +146,7 @@ } function renderCards(issueKeyList) { + var promises = []; var printFrame = jQuery("#card-print-dialog-content-iframe"); var printWindow = printFrame[0].contentWindow; @@ -146,13 +155,12 @@ printDocument.open(); printDocument.write(""); - jQuery("head", printDocument).append(cardCss()); + jQuery("head", printDocument).append(cardElementStyle()); jQuery("body", printDocument).append("
"); jQuery("#preload", printDocument).append("
"); console.log("load " + issueKeyList.length + " issues..."); - var promises = []; jQuery.each(issueKeyList, function(index, issueKey) { var card = cardElement(issueKey); card.attr("index", index); @@ -166,12 +174,12 @@ ga('send', 'event', 'card', 'generate', cardData.type); } fillCard(card, cardData); - card.show(); redrawCards(); + card.show(); })); }); - console.log("wait for issues loaded..."); + console.log("wait for issues loaded..."); return Promise.all(promises).then(function() { console.log("...all issues loaded."); @@ -399,40 +407,8 @@ // http://www.cssdesk.com/T9hXg - function printOverlayHTML() { - var result = jQuery(document.createElement('div')) - .attr("id", "card-print-overlay") - .html(multilineString(function() { -/*! -
-
-
Card Printer
-
- - - -
-
-
- -
- -
-*/ - })); + function printPreviewElement() { + var result = jQuery('
').html(global.printPreviewHtml).contents(); // info result.find("#report-issue").click(function(event) { @@ -536,154 +512,43 @@ }); result.click(function(event) { - if (event.target == this) { - closePrintPreview(); - } + if (event.target == this) { + closePrintPreview(); + } return true; }); jQuery(document).keyup(function(e) { - if (e.keyCode == 27) { // esc + if (e.keyCode == 27) { // ESC closePrintPreview(); } }); // prevent background scrolling result.scroll(function(event) { - return false; + return false; }); return result; } - function printOverlayStyle() { + function printOverlayStyleElement() { var result = jQuery(document.createElement('style')) .attr("id", "card-print-overlay-style") .attr("type", "text/css") - .html(multilineString(function() { -/*! -#card-print-overlay { - position: fixed; - height: 100%; - width: 100%; - top: 0; - left: 0; - background:rgba(0, 0, 0, 0.5); - - box-sizing: border-box; - word-wrap:break-word; - z-index: 99999; - -} - -#card-print-dialog { - position: relative; - - top: 60px; - right:0px; - left:0px; - - height: calc(100% - 120px); - width: 1000px; - margin: auto; - - border-style: solid; - border-color: #cccccc; - border-width: 1px; - -webkit-border-radius: 4px; - border-radius: 4px; - - overflow: hidden; -} - -#card-print-dialog-header { - position: relative; - background: #f0f0f0; - height: 25px; - - border-bottom: 1px solid #cccccc; - - padding: 15px 20px 15px 20px; -} - -#card-print-dialog-content { - position: relative; - background: white; - height: calc(100% - 106px); - width: 100%; - - overflow: hidden; -} - -#card-print-dialog-content-iframe { - position: relative; - height: 100%; - width: 100%; - - overflow: hidden; - border:none; -} - -#card-print-dialog-footer { - position: relative; - background: #f0f0f0; - border-top: 1px solid #cccccc; - height: 30px; - padding: 10px; - text-align: right; -} - -#buttons { - position: relative; - float: right; - display: inline-block; - height 30px; -} - -#info { - position: relative; - float: right; - display: inline-block; - height 30px; -} -#info-line { - padding-left: 3rem; - padding-right: 3rem; -} - -#card-print-dialog-title{ - position: relative; - float: left; - color: rgb(51, 51, 51); - display: block; - font-family: Arial, sans-serif; - font-size: 20px; - font-weight: normal; - height: 30px; - line-height: 30px; -} -.cancel{ - cursor: pointer; - font-size: 14px; - display: inline-block; - padding: 5px 10px; - vertical-align: baseline; -} -*/ - })); + .html(global.printPreviewCss); return result; } // card layout: http://jsfiddle.net/qoomon/ykbLb2pw/76 function cardElement(issueKey) { - var page = jQuery(document.createElement('div')) + var result = jQuery('
').html(global.cardHtml).contents() .attr("id", issueKey) - .html(global.cardHtml); - return page; + return result; } - function cardCss() { + function cardElementStyle() { var result = jQuery(document.createElement('style')) .attr("type", "text/css") .html(global.cardCss); diff --git a/printPreview.css b/printPreview.css new file mode 100644 index 0000000..cdd60b5 --- /dev/null +++ b/printPreview.css @@ -0,0 +1,107 @@ +#card-print-overlay { + position: fixed; + height: 100%; + width: 100%; + top: 0; + left: 0; + background:rgba(0, 0, 0, 0.5); + + box-sizing: border-box; + word-wrap:break-word; + z-index: 99999; + +} + +#card-print-dialog { + position: relative; + + top: 60px; + right:0px; + left:0px; + + height: calc(100% - 120px); + width: 1000px; + margin: auto; + + border-style: solid; + border-color: #cccccc; + border-width: 1px; + -webkit-border-radius: 4px; + border-radius: 4px; + + overflow: hidden; +} + +#card-print-dialog-header { + position: relative; + background: #f0f0f0; + height: 25px; + + border-bottom: 1px solid #cccccc; + + padding: 15px 20px 15px 20px; +} + +#card-print-dialog-content { + position: relative; + background: white; + height: calc(100% - 106px); + width: 100%; + + overflow: hidden; +} + +#card-print-dialog-content-iframe { + position: relative; + height: 100%; + width: 100%; + + overflow: hidden; + border:none; +} + +#card-print-dialog-footer { + position: relative; + background: #f0f0f0; + border-top: 1px solid #cccccc; + height: 30px; + padding: 10px; + text-align: right; +} + +#buttons { + position: relative; + float: right; + display: inline-block; + height 30px; +} + +#info { + position: relative; + float: right; + display: inline-block; + height 30px; +} +#info-line { + padding-left: 3rem; + padding-right: 3rem; +} + +#card-print-dialog-title{ + position: relative; + float: left; + color: rgb(51, 51, 51); + display: block; + font-family: Arial, sans-serif; + font-size: 20px; + font-weight: normal; + height: 30px; + line-height: 30px; +} +.cancel{ + cursor: pointer; + font-size: 14px; + display: inline-block; + padding: 5px 10px; + vertical-align: baseline; +} diff --git a/printPreview.html b/printPreview.html new file mode 100644 index 0000000..0172fa3 --- /dev/null +++ b/printPreview.html @@ -0,0 +1,29 @@ +
+
+
+
Card Printer
+
+ + + +
+
+
+ +
+ +
+
From 54fc5ec1126b94ca855a4e242a5d035215c43a15 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 18:17:12 +0100 Subject: [PATCH 10/11] no message --- bookmarklet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 3801625..f70427c 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -114,19 +114,19 @@ initGoogleAnalytics(); } - promises.push(httpGetCors(global.hostOrigin + "card.html", function(data){ + promises.push(httpGetCors(global.hostOrigin + "card.html").then(function(data){ global.cardHtml = data; })); - promises.push(httpGetCors(global.hostOrigin + "card.css", function(data){ + promises.push(httpGetCors(global.hostOrigin + "card.css").then(function(data){ global.cardCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin); })); - promises.push(httpGetCors(global.hostOrigin + "printPreview.html", function(data){ + promises.push(httpGetCors(global.hostOrigin + "printPreview.html").then(function(data){ global.printPreviewHtml = data })); - promises.push(httpGetCors(global.hostOrigin + "printPreview.css", function(data){ + promises.push(httpGetCors(global.hostOrigin + "printPreview.css").then(function(data){ global.printPreviewCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin); })); From d483b39234f6a95e178b2da9e2c39fd8040f892b Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 25 Nov 2015 18:17:44 +0100 Subject: [PATCH 11/11] dumb version to 4.2.2 --- bookmarklet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookmarklet.js b/bookmarklet.js index f70427c..ad043b6 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,6 +1,6 @@ (function() { var global = {}; - global.version = "4.2.1.1"; + global.version = "4.2.2"; global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer"; global.isDev = document.currentScript == null; global.isProd = !global.isDev;