From 5c1bc72d2d6a4dc2a5031bd42f29d3907715ba09 Mon Sep 17 00:00:00 2001
From: Bengt Brodersen
Date: Wed, 13 May 2015 17:55:59 +0200
Subject: [PATCH 01/19] no message
---
bookmarklet.js | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/bookmarklet.js b/bookmarklet.js
index 2e6f25b..95fba1c 100644
--- a/bookmarklet.js
+++ b/bookmarklet.js
@@ -91,6 +91,7 @@
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
renderCards(issueKeyList, function(){
jQuery("#card-print-dialog-title").text("Card Print");
+ print();
});
}
@@ -104,11 +105,14 @@
//jQuery("html", printDocument).css("font-size", + 0.5 +"cm");
+ var orientationCSS = jQuery('')
+ // jQuery("head",printDocument).append(orientationCSS);
+
printWindow.matchMedia("print").addListener(function() {
jQuery(".page",printDocument).each(function(position, page) {
- // jQuery(page).css("width","50%");
- // jQuery(page).css("height","50%");
- // jQuery(page).css("float","left");
+ jQuery(page).css("width","calc( 50% - 1cm )");
+ jQuery(page).css("height","calc( 50% - 1cm )");
+ jQuery(page).css("float","left");
var height = jQuery(page).height()
- jQuery(page).find(".card-header").outerHeight()
@@ -122,6 +126,18 @@
jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp+"");
});
});
+
+ jQuery(".page:odd",printDocument).each(function(position, page) {
+ jQuery(page).css("margin-left","2cm");
+ });
+ jQuery(".page:nth-child(4n+3)",printDocument).each(function(position, page) {
+ jQuery(page).css("margin-top","2cm");
+ });
+
+ jQuery(".page:nth-child(4n+4)",printDocument).each(function(position, page) {
+ jQuery(page).css("margin-top","2cm");
+ });
+
printWindow.print();
}
From 77f8f19faee309f572c0cba3a0ca86932b83e8cf Mon Sep 17 00:00:00 2001
From: Bengt Brodersen
Date: Fri, 15 May 2015 16:27:35 +0200
Subject: [PATCH 02/19] separate app functions into objects
---
bookmarklet.js | 2277 +++++++++++++++++++++++++-----------------------
1 file changed, 1179 insertions(+), 1098 deletions(-)
diff --git a/bookmarklet.js b/bookmarklet.js
index 95fba1c..255cf4e 100644
--- a/bookmarklet.js
+++ b/bookmarklet.js
@@ -1,1105 +1,900 @@
- (function () {
- var version = "3.4.0";
+(function() {
+ var version = "3.5.0";
console.log("Version: " + version);
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
- || /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL); // PivotTracker
+ || /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL); // PivotTracker
var hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/";
- if(isDev){
- console.log("DEVELOPMENT");
- hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
+ if (isDev) {
+ console.log("DEVELOPMENT");
+ hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
} else {
- //cors = "https://cors-anywhere.herokuapp.com/";
- //$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
+ //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),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ //
+ (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),
+ m = s.getElementsByTagName(o)[0];
+ a.async = 1;
+ a.src = g;
+ m.parentNode.insertBefore(a, m)
+ })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
- ga('create', 'UA-50840116-3', {'alwaysSendReferrer': true});
- ga('set', 'page', '/cardprinter');
+ ga('create', 'UA-50840116-3', {
+ 'alwaysSendReferrer': true
+ });
+ ga('set', 'page', '/cardprinter');
}
try {
- // load jQuery
- if (window.jQuery === undefined) {
- appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
- }
+ // load jQuery
+ if (window.jQuery === undefined) {
+ appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
+ }
- // wait untill all scripts loaded
- appendScript('https://qoomon.github.io/void', function(){
- init();
- main();
- });
+ // wait untill all scripts loaded
+ appendScript('https://qoomon.github.io/void', function() {
+ init();
+ main();
+ });
} catch (err) {
- console.log(err.message);
- if(!isDev){
- ga('send', 'exception', {
- 'exDescription': err.message,
- 'exFatal': true
+ console.log(err.message);
+ if (!isDev) {
+ ga('send', 'exception', {
+ 'exDescription': err.message,
+ 'exFatal': true
+ });
+ }
+ }
+
+ function init() {
+ addJQueryFunctions();
+ addConsoleFunctions();
+ addStringFunctions();
+ addDateFunctions();
+
+ printScopeDeviderToken = "Attachment";
+
+ console.logLevel = console.INFO;
+
+ resourceOrigin = hostOrigin + "resources/";
+
+ appFunctions = {};
+ if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
+ appFunctions = jiraFunctions;
+ } else if (/.*\pivotaltracker.com\/.*/g.test(document.URL)) {
+ appFunctions = pivotalTrackerFunctions
+ }
+ }
+
+ function main() {
+ //preconditions
+ if (jQuery("#card-print-overlay").length > 0) {
+ alert("Print Card already opened!");
+ return;
+ }
+
+ var issueKeyList = appFunctions.getSelectedIssueKeyList();
+
+ if (issueKeyList.length <= 0) {
+ alert("Please select at least one issue.");
+ return;
+ }
+
+ // open print preview
+ jQuery("body").append(printOverlayHTML);
+ jQuery("#card-print-overlay").prepend(printOverlayStyle);
+
+ if (!isDev) {
+ ga('send', 'pageview');
+ }
+
+ jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
+ renderCards(issueKeyList, function() {
+ jQuery("#card-print-dialog-title").text("Card Print");
+ print();
});
- }
}
- function init(){
- addJQueryFunctions();
- addConsoleFunctions();
- addStringFunctions();
- addDateFunctions();
+ function print() {
+ var printFrame = jQuery("#card-print-dialog-content-iframe");
+ var printWindow = printFrame[0].contentWindow;
+ var printDocument = printWindow.document;
+ if (!isDev) {
+ ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length);
+ }
- printScopeDeviderToken = "Attachment";
+ //jQuery("html", printDocument).css("font-size", + 0.5 +"cm");
- console.logLevel = console.INFO;
+ var orientationCSS = jQuery('')
+ // jQuery("head",printDocument).append(orientationCSS);
- resourceOrigin = hostOrigin+ "resources/";
+ printWindow.matchMedia("print").addListener(function() {
+ jQuery(".page", printDocument).each(function(position, page) {
+ jQuery(page).css("width", "calc( 50% - 1cm )");
+ jQuery(page).css("height", "calc( 50% - 1cm )");
+ jQuery(page).css("float", "left");
- APP_JIRA='APP_JIRA'
- APP_PIVOTAL_TRACKER='APP_PIVOTAL_TRACKER'
- issueTracker = 'UNKNOWN'
- if( jQuery("meta[name='application-name'][ content='JIRA']").length > 0){
- issueTracker = APP_JIRA
- } else if( /.*\pivotaltracker.com\/.*/g.test(document.URL)){
- issueTracker = APP_PIVOTAL_TRACKER
- }
- }
-
- function main(){
- //preconditions
- if(jQuery("#card-print-overlay").length > 0){
- alert("Print Card already opened!");
- return;
- }
-
- var issueKeyList = getSelectedIssueKeyList();
-
- if(issueKeyList.length <= 0){
- alert("Please select at least one issue.");
- return;
- }
-
- // open print preview
- jQuery("body").append(printOverlayHTML);
- jQuery("#card-print-overlay").prepend(printOverlayStyle);
-
- if(!isDev){
- ga('send', 'pageview');
- }
-
- jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
- renderCards(issueKeyList, function(){
- jQuery("#card-print-dialog-title").text("Card Print");
- print();
- });
- }
-
- function print(){
- var printFrame = jQuery("#card-print-dialog-content-iframe");
- var printWindow = printFrame[0].contentWindow;
- var printDocument = printWindow.document;
- if(!isDev){
- ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length );
- }
-
- //jQuery("html", printDocument).css("font-size", + 0.5 +"cm");
-
- var orientationCSS = jQuery('')
- // jQuery("head",printDocument).append(orientationCSS);
-
- printWindow.matchMedia("print").addListener(function() {
- jQuery(".page",printDocument).each(function(position, page) {
- jQuery(page).css("width","calc( 50% - 1cm )");
- jQuery(page).css("height","calc( 50% - 1cm )");
- jQuery(page).css("float","left");
-
- var height = jQuery(page).height()
- - jQuery(page).find(".card-header").outerHeight()
- - jQuery(page).find(".card-footer").outerHeight()
- - jQuery(page).find(".content-header").outerHeight()
- - 40;
- jQuery(page).find(".description").css("max-height", height+"px");
- var lineHeight = jQuery(page).find(".description").css("line-height");
- lineHeight = lineHeight.substring(0, lineHeight.length - 2);
- var lineClamp = Math.floor(height / lineHeight);
- jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp+"");
+ var height = jQuery(page).height() - jQuery(page).find(".card-header").outerHeight() - jQuery(page).find(".card-footer").outerHeight() - jQuery(page).find(".content-header").outerHeight() - 40;
+ jQuery(page).find(".description").css("max-height", height + "px");
+ var lineHeight = jQuery(page).find(".description").css("line-height");
+ lineHeight = lineHeight.substring(0, lineHeight.length - 2);
+ var lineClamp = Math.floor(height / lineHeight);
+ jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp + "");
+ });
});
- });
- jQuery(".page:odd",printDocument).each(function(position, page) {
- jQuery(page).css("margin-left","2cm");
- });
- jQuery(".page:nth-child(4n+3)",printDocument).each(function(position, page) {
- jQuery(page).css("margin-top","2cm");
- });
+ jQuery(".page:odd", printDocument).each(function(position, page) {
+ jQuery(page).css("margin-left", "2cm");
+ });
+ jQuery(".page:nth-child(4n+3)", printDocument).each(function(position, page) {
+ jQuery(page).css("margin-top", "2cm");
+ });
- jQuery(".page:nth-child(4n+4)",printDocument).each(function(position, page) {
- jQuery(page).css("margin-top","2cm");
- });
+ jQuery(".page:nth-child(4n+4)", printDocument).each(function(position, page) {
+ jQuery(page).css("margin-top", "2cm");
+ });
- printWindow.print();
+ printWindow.print();
}
- function hideDescription(hide){
- var printFrame = jQuery("#card-print-dialog-content-iframe");
- var printWindow = printFrame[0].contentWindow;
- var printDocument = printWindow.document;
- if(hide){
- jQuery(".description", printDocument).hide();
- } else {
- jQuery(".description", printDocument).show();
- }
+ function hideDescription(hide) {
+ var printFrame = jQuery("#card-print-dialog-content-iframe");
+ var printWindow = printFrame[0].contentWindow;
+ var printDocument = printWindow.document;
+ if (hide) {
+ jQuery(".description", printDocument).hide();
+ } else {
+ jQuery(".description", printDocument).show();
+ }
- resizeIframe(printFrame);
+ resizeIframe(printFrame);
}
- function endableMultiCardPage(enable){
- var printFrame = jQuery("#card-print-dialog-content-iframe");
- var printWindow = printFrame[0].contentWindow;
- var printDocument = printWindow.document;
- if(enable){
- jQuery(".page", printDocument).addClass("multiCardPage");
- } else {
- jQuery(".page", printDocument).removeClass("multiCardPage");
- }
+ function endableMultiCardPage(enable) {
+ var printFrame = jQuery("#card-print-dialog-content-iframe");
+ var printWindow = printFrame[0].contentWindow;
+ var printDocument = printWindow.document;
+ if (enable) {
+ jQuery(".page", printDocument).addClass("multiCardPage");
+ } else {
+ jQuery(".page", printDocument).removeClass("multiCardPage");
+ }
}
function renderCards(issueKeyList, callback) {
- var printFrame = jQuery("#card-print-dialog-content-iframe");
- var printWindow = printFrame[0].contentWindow;
- var printDocument = printWindow.document;
+ var printFrame = jQuery("#card-print-dialog-content-iframe");
+ var printWindow = printFrame[0].contentWindow;
+ var printDocument = printWindow.document;
- printDocument.open();
- printDocument.write("");
+ printDocument.open();
+ printDocument.write("");
- jQuery("head", printDocument).append(printPanelPageCSS());
- jQuery("head", printDocument).append(printPanelCardCSS());
+ jQuery("head", printDocument).append(printPanelPageCSS());
+ jQuery("head", printDocument).append(printPanelCardCSS());
- console.logInfo("load " + issueKeyList.length + " issues...");
+ console.logInfo("load " + issueKeyList.length + " issues...");
- var deferredList = [];
- jQuery.each(issueKeyList,function(index, issueKey) {
- var page = newPage(issueKey);
- page.attr("index",index);
- page.hide();
- page.find('.key').text(issueKey);
- jQuery("body", printDocument).append(page);
- var deferred = addDeferred(deferredList);
- getCardData(issueKey, function(cardData) {
- console.logDebug("cardData: " + cardData);
- if(!isDev){
- ga('send', 'event', 'task', 'generate', 'card', cardData.type );
- }
- fillCard(page, cardData);
- page.show();
- resizeIframe(printFrame);
- deferred.resolve();
+ var deferredList = [];
+ jQuery.each(issueKeyList, function(index, issueKey) {
+ var page = newPage(issueKey);
+ page.attr("index", index);
+ page.hide();
+ page.find('.key').text(issueKey);
+ jQuery("body", printDocument).append(page);
+ var deferred = addDeferred(deferredList);
+ appFunctions.getCardData(issueKey, function(cardData) {
+ console.logDebug("cardData: " + cardData);
+ if (!isDev) {
+ ga('send', 'event', 'task', 'generate', 'card', cardData.type);
+ }
+ fillCard(page, cardData);
+ page.show();
+ resizeIframe(printFrame);
+ deferred.resolve();
+ });
});
- });
- console.logInfo("wait for issues loaded...");
+ console.logInfo("wait for issues loaded...");
- applyDeferred(deferredList,function() {
- console.logInfo("...all issues loaded.");
- jQuery(printWindow).load(function(){
- console.logInfo("...all resources loaded.");
- callback();
- })
- printDocument.close();
- console.logInfo("wait for resources loaded...");
- });
- }
-
- function closePrintPreview(){
- jQuery("#card-print-overlay").remove();
- jQuery("#card-print-overlay-style").remove();
- }
-
- function getSelectedIssueKeyList() {
- switch(issueTracker) {
- case APP_JIRA:
- return getSelectedIssueKeyListJira();
- case APP_PIVOTAL_TRACKER:
- return getSelectedIssueKeyListPivotalTracker();
- }
- }
-
- function getSelectedIssueKeyListJira() {
-
- //Browse
- if (/.*\/browse\/.*/g.test(document.URL)) {
- return jQuery("a[data-issue-key][id='key-val']").map(function() {
- return jQuery(this).attr('data-issue-key');
- });
- }
-
- // RapidBoard
- if (/.*\/secure\/RapidBoard.jspa.*/g.test(document.URL)) {
- return jQuery('div[data-issue-key].ghx-selected').map(function() {
- return jQuery(this).attr('data-issue-key');
- });
- }
-
- return [];
- }
-
- function getSelectedIssueKeyListPivotalTracker() {
- //Single Story
- if (/.*\/stories\/.*/g.test(document.URL)) {
- return [document.URL.replace(/.*\/stories\/(.*)\??/,'$1')];
- }
-
- // Board
- if (/.*\/projects\/.*/g.test(document.URL)) {
- return jQuery('.story[data-id]:has(.selected)').map(function() {
- return jQuery(this).attr('data-id');
- });
- }
-
- return [];
- }
-
- function getCardData(issueKey, callback){
- switch(issueTracker) {
- case APP_JIRA:
- return getCardDataJira(issueKey, callback);
- case APP_PIVOTAL_TRACKER:
- return getCardDataPivotalTracker(issueKey, callback);
- }
-
- }
-
- function getCardDataJira(issueKey, callback) {
- getIssueDataJira(issueKey,function(data){
-
- var issueData = {};
-
- 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 ) {
- issueData.assignee = data.fields.assignee.displayName;
- var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
- if(avatarUrl.indexOf("ownerId=") >= 0){
- issueData.avatarUrl = avatarUrl;
- }
- }
-
- if ( data.fields.duedate ) {
- issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
- }
-
- issueData.hasAttachment = data.fields.attachment.length > 0;
- if(issueData.description){
- var printScope = issueData.description.indexOf(printScopeDeviderToken);
- if (printScope >= 0) {
- issueData.description = issueData.description.substring(0, printScope);
- issueData.hasAttachment = true;
- }
- }
-
- issueData.storyPoints = data.fields.storyPoints;
-
- issueData.epicKey = data.fields.epicLink;
- if ( issueData.epicKey ) {
- getIssueDataJira(issueData.epicKey , function(data) {
- issueData.epicName = data.fields.epicName;
- }, false);
- }
-
- issueData.url = window.location.origin + "/browse/" + issueData.key;
-
- //check for lrs
- if(true){
- console.logInfo("Apply LRS Specifics");
- //Desired-Date
- if ( data.fields.desiredDate ) {
- issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
- }
- }
-
- callback(issueData);
+ applyDeferred(deferredList, function() {
+ console.logInfo("...all issues loaded.");
+ jQuery(printWindow).load(function() {
+ console.logInfo("...all resources loaded.");
+ callback();
+ })
+ printDocument.close();
+ console.logInfo("wait for resources loaded...");
});
}
- function getCardDataPivotalTracker(issueKey, callback) {
- getIssueDataPivotalTracker(issueKey,function(data){
-
- var issueData = {};
-
- issueData.key = data.id;
-
- issueData.type = data.kind.toLowerCase();
-
- issueData.summary = data.name;
-
- issueData.description = data.description;
- if(issueData.description){
- issueData.description = "
"+issueData.description
- }
-
- if ( data.owned_by && data.owned_by.length > 0 ) {
- issueData.assignee = data.owner_ids[0].name;
- }
-
- if ( data.deadline ) {
- issueData.dueDate = new Date(data.deadline).format('D d.m.');
- }
-
- issueData.hasAttachment = false;
- if(issueData.description){
- var printScope = issueData.description.indexOf(printScopeDeviderToken);
- if (printScope >= 0) {
- issueData.description = issueData.description.substring(0, printScope);
- issueData.hasAttachment = true;
- }
- }
-
- issueData.storyPoints = data.estimate;
-
-// TODO
- // issueData.epicKey = data.fields.epicLink;
- // if ( issueData.epicKey ) {
- // getIssueDataPivotalTracker(issueData.epicKey , function(data) {
- // issueData.epicName = data.fields.epicName;
- // }, false);
- // }
-
- issueData.url = data.url;
-
- callback(issueData);
- });
- }
-
- function getIssueDataJira(issueKey, callback, async) {
- async = typeof async !== 'undefined' ? async : true;
- //https://docs.atlassian.com/jira/REST/latest/
- var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
- console.logDebug("IssueUrl: " + url);
- console.logDebug("Issue: " + issueKey + " Loading...");
- jQuery.ajax({
- type: 'GET',
- url: url,
- data: {},
- dataType: 'json',
- async: async,
- success: function(responseData){
- console.logDebug("Issue: " + issueKey + " Loaded!");
- // add custom fields with field names
- jQuery.each(responseData.names, function(key, value) {
- if(key.startsWith("customfield_")){
- var newFieldId = value.toCamelCase();
- console.logTrace("add new field: " + newFieldId +" with value from "+ key);
- responseData.fields[value.toCamelCase()] = responseData.fields[key];
- }
- });
- callback(responseData);
- },
- });
- }
-
- function getIssueDataPivotalTracker(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.logDebug("IssueUrl: " + url);
- console.logDebug("Issue: " + issueKey + " Loading...");
- jQuery.ajax({
- type: 'GET',
- url: url,
- data: {},
- dataType: 'json',
- async: async,
- success: function(responseData){
- console.logDebug("Issue: " + issueKey + " Loaded!");
- callback(responseData);
- },
- });
+ function closePrintPreview() {
+ jQuery("#card-print-overlay").remove();
+ jQuery("#card-print-overlay-style").remove();
}
function fillCard(card, data) {
- //Key
- card.find('.key').text(data.key);
+ //Key
+ card.find('.key').text(data.key);
- //Type
- card.find(".card").attr("type", data.type);
+ //Type
+ card.find(".card").attr("type", data.type);
- //Summary
- card.find('.summary').text(data.summary);
+ //Summary
+ card.find('.summary').text(data.summary);
- //Description
- card.find('.description').html(data.description);
+ //Description
+ card.find('.description').html(data.description);
- //Assignee
- if ( data.assignee ) {
- if(data.avatarUrl){
- card.find(".assignee").css("background-image", "url('" + data.avatarUrl + "')");
+ //Assignee
+ if (data.assignee) {
+ if (data.avatarUrl) {
+ card.find(".assignee").css("background-image", "url('" + data.avatarUrl + "')");
+ } else {
+ card.find(".assignee").text(data.assignee[0].toUpperCase());
+ }
} else {
- card.find(".assignee").text(data.assignee[0].toUpperCase());
+ card.find(".assignee").addClass("hidden");
}
- } else {
- card.find(".assignee").addClass("hidden");
- }
- //Due-Date
- if ( data.dueDate ) {
- card.find(".due-date").text(data.dueDate);
- } else {
- card.find(".due").addClass("hidden");
- }
+ //Due-Date
+ if (data.dueDate) {
+ card.find(".due-date").text(data.dueDate);
+ } else {
+ card.find(".due").addClass("hidden");
+ }
- //Attachment
- if ( data.hasAttachment ) {
- } else{
- card.find('.attachment').addClass('hidden');
- }
+ //Attachment
+ if (data.hasAttachment) {} else {
+ card.find('.attachment').addClass('hidden');
+ }
- //Story Points
- if (data.storyPoints) {
- card.find(".estimate").text(data.storyPoints);
- } else {
- card.find(".estimate").addClass("hidden");
- }
+ //Story Points
+ if (data.storyPoints) {
+ card.find(".estimate").text(data.storyPoints);
+ } else {
+ card.find(".estimate").addClass("hidden");
+ }
- //Epic
- if ( data.epicKey ) {
- card.find(".epic-key").text(data.epicKey);
- card.find(".epic-name").text(data.epicName);
- } else {
- card.find(".epic").addClass("hidden");
- }
+ //Epic
+ if (data.epicKey) {
+ card.find(".epic-key").text(data.epicKey);
+ card.find(".epic-name").text(data.epicName);
+ } else {
+ card.find(".epic").addClass("hidden");
+ }
- //QR-Code
- var qrCodeUrl = 'https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=' + encodeURIComponent(data.url);
- card.find(".qr-code").css("background-image", "url('" + qrCodeUrl + "')");
+ //QR-Code
+ var qrCodeUrl = 'https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=' + encodeURIComponent(data.url);
+ card.find(".qr-code").css("background-image", "url('" + qrCodeUrl + "')");
}
//############################################################################################################################
- //############################################################################################################################
- //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
- // http://www.cssdesk.com/T9hXg
+ // http://www.cssdesk.com/T9hXg
- function printOverlayHTML(){
+ function printOverlayHTML() {
var result = jQuery(document.createElement('div'))
- .attr("id","card-print-overlay")
- .html(multilineString(function() {
- /*!
-
- */
- }));
+ .attr("id", "card-print-overlay")
+ .html(multilineString(function() {
+ /*!
+
+ */
+ }));
// info
result.find("#report-issue")
- .click(function(event){
- window.open('https://github.com/qoomon/Jira-Issue-Card-Printer/issues');
- return false;
- });
+ .click(function(event) {
+ window.open('https://github.com/qoomon/Jira-Issue-Card-Printer/issues');
+ return false;
+ });
result.find("#about")
- .click(function(event){
- window.open('http://qoomon.blogspot.de/2014/01/jira-issue-card-printer-bookmarklet.html');
- return false;
- });
+ .click(function(event) {
+ window.open('http://qoomon.blogspot.de/2014/01/jira-issue-card-printer-bookmarklet.html');
+ return false;
+ });
// enable multe card page
result.find("#multi-card-page-checkbox")
- .click(function() {
- endableMultiCardPage(this.checked);
- return true;
- });
+ .click(function() {
+ endableMultiCardPage(this.checked);
+ return true;
+ });
// hide description
result.find("#hide-description-checkbox")
- .click(function() {
- hideDescription(this.checked);
- return true;
- });
+ .click(function() {
+ hideDescription(this.checked);
+ return true;
+ });
// scale card
result.find("#card-scale-range").on("input", function() {
- var printFrame = jQuery("#card-print-dialog-content-iframe");
- var printWindow = printFrame[0].contentWindow;
- var printDocument = printWindow.document;
- jQuery("html", printDocument).css("font-size", jQuery(this).val() +"cm");
- resizeIframe(printFrame);
+ var printFrame = jQuery("#card-print-dialog-content-iframe");
+ var printWindow = printFrame[0].contentWindow;
+ var printDocument = printWindow.document;
+ jQuery("html", printDocument).css("font-size", jQuery(this).val() + "cm");
+ resizeIframe(printFrame);
});
// print
result.find("#card-print-dialog-print")
- .click(function(event){
- print();
- return false;
- });
+ .click(function(event) {
+ print();
+ return false;
+ });
// closePrintPreview
result.find("#card-print-dialog-cancel")
- .click(function(event){
- closePrintPreview();
- return false;
- });
+ .click(function(event) {
+ closePrintPreview();
+ return false;
+ });
result.click(function(event) {
- if( event.target == this ){
- closePrintPreview();
- }
- return true;
+ if (event.target == this) {
+ closePrintPreview();
+ }
+ return true;
});
jQuery(document).keyup(function(e) {
- if (e.keyCode == 27) { // esc
- closePrintPreview();
- }
+ if (e.keyCode == 27) { // esc
+ closePrintPreview();
+ }
});
// prevent background scrolling
result.scroll(function(event) {
- return false;
+ return false;
});
return result;
- }
+ }
- function printOverlayStyle(){
- 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);
+ function printOverlayStyle() {
+ 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;
+ box-sizing: border-box;
+ word-wrap:break-word;
+ z-index: 99999;
- }
+ }
- #card-print-dialog {
- position: relative;
+ #card-print-dialog {
+ position: relative;
- top: 60px;
- right:0px;
- left:0px;
+ top: 60px;
+ right:0px;
+ left:0px;
- height: calc(100% - 120px);
- width: 1000px;
- margin: auto;
+ height: calc(100% - 120px);
+ width: 1000px;
+ margin: auto;
- border-style: solid;
- border-color: #cccccc;
- border-width: 1px;
- -webkit-border-radius: 4px;
- border-radius: 4px;
+ border-style: solid;
+ border-color: #cccccc;
+ border-width: 1px;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
- overflow: hidden;
- }
+ overflow: hidden;
+ }
- #card-print-dialog-header {
- position: relative;
- background: #f0f0f0;
- height: 25px;
+ #card-print-dialog-header {
+ position: relative;
+ background: #f0f0f0;
+ height: 25px;
- border-bottom: 1px solid #cccccc;
+ border-bottom: 1px solid #cccccc;
- padding: 15px 20px 15px 20px;
- }
+ padding: 15px 20px 15px 20px;
+ }
- #card-print-dialog-content {
- position: relative;
- background: white;
- height: calc(100% - 106px);
- width: 100%;
+ #card-print-dialog-content {
+ position: relative;
+ background: white;
+ height: calc(100% - 106px);
+ width: 100%;
- overflow-y: scroll;
- }
+ overflow-y: scroll;
+ }
- #card-print-dialog-content-iframe {
- position: relative;
- height: 100%;
- width: 100%;
+ #card-print-dialog-content-iframe {
+ position: relative;
+ height: 100%;
+ width: 100%;
- border:none;
- }
+ border:none;
+ }
- #card-print-dialog-footer {
- position: relative;
- background: #f0f0f0;
- border-top: 1px solid #cccccc;
- height: 30px;
- padding: 10px;
- text-align: right;
- }
+ #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;
- }
+ #buttons {
+ position: relative;
+ float: right;
+ display: inline-block;
+ height 30px;
+ }
- #info {
- position: relative;
- float: right;
- display: inline-block;
- height 30px;
- }
+ #info {
+ position: relative;
+ float: right;
+ display: inline-block;
+ height 30px;
+ }
- #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;
- }
- */
- }));
- return result;
- }
+ #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;
+ }
+ */
+ }));
+ return result;
+ }
- function printPanelPageCSS(){
+ function printPanelPageCSS() {
var result = jQuery(document.createElement('style'))
- .attr("id", "printPanelPageStyle")
- .attr("type", "text/css")
- .html(multilineString(function() {
- /*!
- HTML {
- font-size: 1.0cm;
- overflow: hidden;
- }
- .page {
- position: relative;
- overflow: auto;
- margin-left: auto;
- margin-right: auto;
- padding: 1.0cm;
- margin: 1.0cm;
- width: auto;
- height: auto;
- page-break-after: always;
- page-break-inside: avoid;
+ .attr("id", "printPanelPageStyle")
+ .attr("type", "text/css")
+ .html(multilineString(function() {
+ /*!
+ HTML {
+ font-size: 1.0cm;
+ overflow: hidden;
+ }
+ .page {
+ position: relative;
+ overflow: auto;
+ margin-left: auto;
+ margin-right: auto;
+ padding: 1.0cm;
+ margin: 1.0cm;
+ width: auto;
+ height: auto;
+ page-break-after: always;
+ page-break-inside: avoid;
- background:white;
+ background:white;
- -webkit-box-shadow: 0px 0px 7px 3px rgba(31,31,31,0.4);
- box-shadow: 0px 0px 7px 3px rgba(31,31,31,0.4);
+ -webkit-box-shadow: 0px 0px 7px 3px rgba(31,31,31,0.4);
+ box-shadow: 0px 0px 7px 3px rgba(31,31,31,0.4);
- border-style: solid;
- border-color: #bfbfbf;
- border-width: 0.05cm;
- -webkit-border-radius: 0.1cm;
- border-radius: 0.1cm;
+ border-style: solid;
+ border-color: #bfbfbf;
+ border-width: 0.05cm;
+ -webkit-border-radius: 0.1cm;
+ border-radius: 0.1cm;
- overflow: hidden;
- }
+ overflow: hidden;
+ }
- @media print {
+ @media print {
- .page {
- background: white;
- border-style: none;
- padding: 0.0cm;
- margin: 0.0cm;
+ .page {
+ background: white;
+ border-style: none;
+ padding: 0.0cm;
+ margin: 0.0cm;
- -webkit-box-shadow: none;
- box-shadow: none;
+ -webkit-box-shadow: none;
+ box-shadow: none;
- -webkit-print-color-adjust:exact;
- print-color-adjust: exact;
- }
-
- .multiCardPage {
- height: auto;
- margin-bottom: 1.0cm;
- page-break-after: avoid;
- }
-
- .page:last-of-type {
- page-break-after: avoid;
- }
-
- }
- */
- }));
-
- return result;
+ -webkit-print-color-adjust:exact;
+ print-color-adjust: exact;
}
+ .multiCardPage {
+ height: auto;
+ margin-bottom: 1.0cm;
+ page-break-after: avoid;
+ }
- // http://www.cssdesk.com/scHcP
+ .page:last-of-type {
+ page-break-after: avoid;
+ }
- function newPage(issueKey){
+ }
+ */
+ }));
+
+ return result;
+ }
+
+
+ // http://www.cssdesk.com/scHcP
+
+ function newPage(issueKey) {
var page = jQuery(document.createElement('div'))
- .attr("id",issueKey)
- .addClass("page")
- .addClass("singleCardPage")
- .html(multilineString(function() {
- /*!
-
-
qoomon.com
-
Bengt Brodersen
-
-
-
-
-
- */
- }));
+ .attr("id", issueKey)
+ .addClass("page")
+ .addClass("singleCardPage")
+ .html(multilineString(function() {
+ /*!
+
+
qoomon.com
+
Bengt Brodersen
+
+
+
+
+
+ */
+ }));
return page;
- }
+ }
- function printPanelCardCSS(){
+ function printPanelCardCSS() {
var result = jQuery(document.createElement('style'))
- .attr("type", "text/css")
- .html(multilineString(function() {
- /*!
- * {
- color: black;
- font-family:"Droid Serif";
- }
- body {
- margin: 0;
- }
- .hidden {
- visibility: hidden;
- }
- .card-header:after,
- .card-footer:after {
- content:" ";
- display: block;
- clear: both;
- height:0
- }
- .card-border,
- .badge,
- .shadow {
- border-style: solid;
- border-color: #2f2f2f;
- border-top-width: 0.14rem;
- border-left-width: 0.14rem;
- border-bottom-width: 0.24rem;
- border-right-width: 0.24rem;
- -webkit-border-radius: 0.25rem;
- border-radius: 0.25rem;
- }
- .circular {
- -webkit-border-radius: 50%;
- border-radius: 50%;
- }
- .badge {
- width: 3.2rem;
- height: 3.2rem;
- background: #d0d0d0;
- }
- .card {
- position: relative;
- min-width: 17.0rem;
- max-height: 100%;
- overflow: hidden;
- }
- .author{
- line-height: 0.8rem;
- }
- .author-page {
- z-index: 999;
- position: absolute;
- top:2.5rem;
- right:0.55rem;
- font-size: 0.45rem;
- -webkit-transform-origin: 100% 100%;
- transform-origin: 100% 100%;
- -webkit-transform: rotate(-90deg);
- transform: rotate(-90deg);
- }
- .author-name {
- z-index: 0;
- position: absolute;
- top:3.26rem;
- right:-2.6rem;
- font-size: 0.35rem;
- -webkit-transform-origin: 0% 0%;
- transform-origin: 0% 0%;
- -webkit-transform: rotate(90deg);
- transform: rotate(90deg);
- }
- .card-border {
- position: absolute;
- top:2.0rem;
- left:0.4rem;
- right:0.4rem;
- height: calc(100% - 4.0rem);
- background: #ffffff;
+ .attr("type", "text/css")
+ .html(multilineString(function() {
+ /*!
+ * {
+ color: black;
+ font-family:"Droid Serif";
+ }
+ body {
+ margin: 0;
+ }
+ .hidden {
+ visibility: hidden;
+ }
+ .card-header:after,
+ .card-footer:after {
+ content:" ";
+ display: block;
+ clear: both;
+ height:0
+ }
+ .card-border,
+ .badge,
+ .shadow {
+ border-style: solid;
+ border-color: #2f2f2f;
+ border-top-width: 0.14rem;
+ border-left-width: 0.14rem;
+ border-bottom-width: 0.24rem;
+ border-right-width: 0.24rem;
+ -webkit-border-radius: 0.25rem;
+ border-radius: 0.25rem;
+ }
+ .circular {
+ -webkit-border-radius: 50%;
+ border-radius: 50%;
+ }
+ .badge {
+ width: 3.2rem;
+ height: 3.2rem;
+ background: #d0d0d0;
+ }
+ .card {
+ position: relative;
+ min-width: 17.0rem;
+ max-height: 100%;
+ overflow: hidden;
+ }
+ .author{
+ line-height: 0.8rem;
+ }
+ .author-page {
+ z-index: 999;
+ position: absolute;
+ top:2.5rem;
+ right:0.55rem;
+ font-size: 0.45rem;
+ -webkit-transform-origin: 100% 100%;
+ transform-origin: 100% 100%;
+ -webkit-transform: rotate(-90deg);
+ transform: rotate(-90deg);
+ }
+ .author-name {
+ z-index: 0;
+ position: absolute;
+ top:3.26rem;
+ right:-2.6rem;
+ font-size: 0.35rem;
+ -webkit-transform-origin: 0% 0%;
+ transform-origin: 0% 0%;
+ -webkit-transform: rotate(90deg);
+ transform: rotate(90deg);
+ }
+ .card-border {
+ position: absolute;
+ top:2.0rem;
+ left:0.4rem;
+ right:0.4rem;
+ height: calc(100% - 4.0rem);
+ background: #ffffff;
- }
- .card-header {
- position: relative;
- }
- .card-content {
- position: relative;
- margin-top: 0.3rem;
- margin-left: 1.0rem;
- margin-right: 1.1rem;
- margin-bottom: 0.2rem;
- min-height: 1.2rem;
- }
- .content-header {
- position: relative;
- font-size: 1.1rem;
- line-height: 1.1rem;
- //margin-bottom: 0.6rem;
- }
- .card-footer {
- position: relative;
- }
- .summary {
- font-weight: bold;
- }
- .description {
- display: block;
- font-size: 0.6rem;
- line-height: 0.6rem;
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- }
- .key {
- position: absolute;
- float: left;
- width: auto;
- min-width: 4.4rem;
- height: 1.35rem;
- left: 3.0rem;
- margin-top: 1.2rem;
- padding-left: 0.7rem;
- padding-right: 0.4rem;
- text-align: center;
- font-weight: bold;
- font-size: 1.0rem;
- line-height: 1.5rem;
- }
- .type-icon {
- position: relative;
- float: left;
- background-color: GREENYELLOW;
- background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Objects.png);
- background-repeat: no-repeat;
- -webkit-background-size: 70%;
- background-size: 70%;
- background-position: center;
- z-index: 1;
- }
+ }
+ .card-header {
+ position: relative;
+ }
+ .card-content {
+ position: relative;
+ margin-top: 0.3rem;
+ margin-left: 1.0rem;
+ margin-right: 1.1rem;
+ margin-bottom: 0.2rem;
+ min-height: 1.2rem;
+ }
+ .content-header {
+ position: relative;
+ font-size: 1.1rem;
+ line-height: 1.1rem;
+ //margin-bottom: 0.6rem;
+ }
+ .card-footer {
+ position: relative;
+ }
+ .summary {
+ font-weight: bold;
+ }
+ .description {
+ display: block;
+ font-size: 0.6rem;
+ line-height: 0.6rem;
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ }
+ .key {
+ position: absolute;
+ float: left;
+ width: auto;
+ min-width: 4.4rem;
+ height: 1.35rem;
+ left: 3.0rem;
+ margin-top: 1.2rem;
+ padding-left: 0.7rem;
+ padding-right: 0.4rem;
+ text-align: center;
+ font-weight: bold;
+ font-size: 1.0rem;
+ line-height: 1.5rem;
+ }
+ .type-icon {
+ position: relative;
+ float: left;
+ background-color: GREENYELLOW;
+ background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Objects.png);
+ background-repeat: no-repeat;
+ -webkit-background-size: 70%;
+ background-size: 70%;
+ background-position: center;
+ z-index: 1;
+ }
- .card[type="story"] .type-icon {
- background-color: GOLD;
- background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bulb.png);
- }
- .card[type="bug"] .type-icon {
- background-color: CRIMSON;
- background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bug.png);
- }
- .card[type="epic"] .type-icon {
- background-color: ROYALBLUE;
- background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Flash.png);
- }
+ .card[type="story"] .type-icon {
+ background-color: GOLD;
+ background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bulb.png);
+ }
+ .card[type="bug"] .type-icon {
+ background-color: CRIMSON;
+ background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bug.png);
+ }
+ .card[type="epic"] .type-icon {
+ background-color: ROYALBLUE;
+ background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Flash.png);
+ }
- .estimate {
- position: relative;
- float: left;
- left: -0.65rem;
- top:-1.5rem;
- height: 1.1rem;
- width: 1.1rem;
- text-align: center;
- font-weight: bold;
- font-size: 0.9rem;
- line-height: 1.15rem;
- margin-top:1.5rem;
- z-index: 999;
- }
+ .estimate {
+ position: relative;
+ float: left;
+ left: -0.65rem;
+ top:-1.5rem;
+ height: 1.1rem;
+ width: 1.1rem;
+ text-align: center;
+ font-weight: bold;
+ font-size: 0.9rem;
+ line-height: 1.15rem;
+ margin-top:1.5rem;
+ z-index: 999;
+ }
- .due {
- position: relative;
- float: right;
- }
- .due-icon {
- position: relative;
- float:right;
- width: 2.5rem;
- height: 2.5rem;
- margin-top: 0.4rem;
- background-color: MEDIUMPURPLE;
- background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/AlarmClock.png);
- background-repeat: no-repeat;
- -webkit-background-size: 65%;
- background-size: 65%;
- background-position: center;
- z-index: 1;
- }
- .due-date {
- position: relative;
- float: right;
- right: -0.6rem;
- width: auto;
- min-width: 2.8rem;
- height: auto;
- margin-top: 1.3rem;
- padding-top: 0.2rem;
- padding-bottom: 0.2rem;
- padding-left: 0.3rem;
- padding-right: 0.6rem;
- text-align: center;
- font-weight: bold;
- font-size: 0.7rem;
- line-height: 0.7rem;
- }
- .attachment {
- position: relative;
- float: left;
- margin-left: 0.6rem;
- width: 2.1rem;
- height: 2.1rem;
- background-color: LIGHTSKYBLUE;
- background-image: url(https://images.weserv.nl/?url=www.iconsdb.com/icons/download/color/2f2f2f/attach-256.png);
- background-repeat: no-repeat;
- -webkit-background-size: 70%;
- background-size: 70%;
- background-position: center;
+ .due {
+ position: relative;
+ float: right;
+ }
+ .due-icon {
+ position: relative;
+ float:right;
+ width: 2.5rem;
+ height: 2.5rem;
+ margin-top: 0.4rem;
+ background-color: MEDIUMPURPLE;
+ background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/AlarmClock.png);
+ background-repeat: no-repeat;
+ -webkit-background-size: 65%;
+ background-size: 65%;
+ background-position: center;
+ z-index: 1;
+ }
+ .due-date {
+ position: relative;
+ float: right;
+ right: -0.6rem;
+ width: auto;
+ min-width: 2.8rem;
+ height: auto;
+ margin-top: 1.3rem;
+ padding-top: 0.2rem;
+ padding-bottom: 0.2rem;
+ padding-left: 0.3rem;
+ padding-right: 0.6rem;
+ text-align: center;
+ font-weight: bold;
+ font-size: 0.7rem;
+ line-height: 0.7rem;
+ }
+ .attachment {
+ position: relative;
+ float: left;
+ margin-left: 0.6rem;
+ width: 2.1rem;
+ height: 2.1rem;
+ background-color: LIGHTSKYBLUE;
+ background-image: url(https://images.weserv.nl/?url=www.iconsdb.com/icons/download/color/2f2f2f/attach-256.png);
+ background-repeat: no-repeat;
+ -webkit-background-size: 70%;
+ background-size: 70%;
+ background-position: center;
- }
- .assignee {
- position: relative;
- float: right;
- width: 2.1rem;
- height: 2.1rem;
- text-align: center;
- font-weight: bold;
- font-size: 1.8rem;
- line-height: 2.2rem;
- background-image: url(https://images.weserv.nl/?url=www.iconsdb.com/icons/download/color/aaaaaa/contacts-256.png);
- background-repeat: no-repeat;
- -webkit-background-size: cover;
- background-size: cover;
- -webkit-background-size: 100%;
- background-size: 100%;
- -webkit-filter: contrast(150%) grayscale(100%);
- filter: contrast(150%) grayscale(100%);
- background-position: center;
- }
- .qr-code {
- position: relative;
- float: left;
- width: 2.1rem;
- height: 2.1rem;
- background-image: url(https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=blog.qoomon.com);
- background-repeat: no-repeat;
- -webkit-background-size: cover;
- background-size: cover;
- background-position: center;
- }
- .epic {
- width: auto;
- height: auto;
- position: relative;
- float:right;
- margin-right:0.6rem;
- padding-top: 0.2rem;
- padding-bottom: 0.2rem;
- padding-left: 0.3rem;
- padding-right: 0.3rem;
- text-align: left;
- font-size: 0.7rem;
- line-height: 0.7rem;
- max-width: calc( 100% - 10.2rem);
- }
- .epic-key {
- }
- .epic-name {
- font-weight: bold;
- }
- */
- }).replace(/{RESOURCE_ORIGIN}/g, resourceOrigin));
+ }
+ .assignee {
+ position: relative;
+ float: right;
+ width: 2.1rem;
+ height: 2.1rem;
+ text-align: center;
+ font-weight: bold;
+ font-size: 1.8rem;
+ line-height: 2.2rem;
+ background-image: url(https://images.weserv.nl/?url=www.iconsdb.com/icons/download/color/aaaaaa/contacts-256.png);
+ background-repeat: no-repeat;
+ -webkit-background-size: cover;
+ background-size: cover;
+ -webkit-background-size: 100%;
+ background-size: 100%;
+ -webkit-filter: contrast(150%) grayscale(100%);
+ filter: contrast(150%) grayscale(100%);
+ background-position: center;
+ }
+ .qr-code {
+ position: relative;
+ float: left;
+ width: 2.1rem;
+ height: 2.1rem;
+ background-image: url(https://chart.googleapis.com/chart?cht=qr&chs=256x256&chld=L|1&chl=blog.qoomon.com);
+ background-repeat: no-repeat;
+ -webkit-background-size: cover;
+ background-size: cover;
+ background-position: center;
+ }
+ .epic {
+ width: auto;
+ height: auto;
+ position: relative;
+ float:right;
+ margin-right:0.6rem;
+ padding-top: 0.2rem;
+ padding-bottom: 0.2rem;
+ padding-left: 0.3rem;
+ padding-right: 0.3rem;
+ text-align: left;
+ font-size: 0.7rem;
+ line-height: 0.7rem;
+ max-width: calc( 100% - 10.2rem);
+ }
+ .epic-key {
+ }
+ .epic-name {
+ font-weight: bold;
+ }
+ */
+ }).replace(/{RESOURCE_ORIGIN}/g, resourceOrigin));
return result;
- }
+ }
- //############################################################################################################################
- //############################################################################################################################
- //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
- function appendScript(url, callback){
+ function appendScript(url, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
@@ -1111,204 +906,490 @@
script.onload = callback;
head.appendChild(script);
- }
+ }
- //############################################################################################################################
- //############################################################################################################################
- //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
- function addDeferred(deferredList){
+ function addDeferred(deferredList) {
var deferred = new jQuery.Deferred()
deferredList.push(deferred);
return deferred;
- }
+ }
- function applyDeferred(deferredList, callback){
+ function applyDeferred(deferredList, callback) {
jQuery.when.apply(jQuery, deferredList).done(callback);
- }
+ }
- //############################################################################################################################
- //############################################################################################################################
- //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
- function addJQueryFunctions() {
+ function addJQueryFunctions() {
//jQuery Extention
- jQuery.expr[':']['is'] = function(node, index, props){
- return node.textContent == props[3];
+ jQuery.expr[':']['is'] = function(node, index, props) {
+ return node.textContent == props[3];
}
- }
+ }
- function addConsoleFunctions() {
+ function addConsoleFunctions() {
console.ERROR = 0;
- console.WARN = 1;
- console.INFO = 2;
+ console.WARN = 1;
+ console.INFO = 2;
console.DEBUG = 3;
console.TRACE = 4;
- console.logLevel = console.INFO ;
+ console.logLevel = console.INFO;
- console.logError = function(msg){
- if(console.logLevel >= console.ERROR ) {
- console.log("ERROR: " + msg);
- }
+ console.logError = function(msg) {
+ if (console.logLevel >= console.ERROR) {
+ console.log("ERROR: " + msg);
+ }
}
- console.logWarn = function(msg){
- if(console.logLevel >= console.WARN ) {
- console.log("WARN: " + msg);
- }
+ console.logWarn = function(msg) {
+ if (console.logLevel >= console.WARN) {
+ console.log("WARN: " + msg);
+ }
}
- console.logInfo = function(msg){
- if(console.logLevel >= console.INFO ) {
- console.log("INFO: " + msg);
- }
+ console.logInfo = function(msg) {
+ if (console.logLevel >= console.INFO) {
+ console.log("INFO: " + msg);
+ }
}
- console.logDebug = function(msg){
- if(console.logLevel >= console.DEBUG ) {
- console.log("DEBUG: " + msg);
- }
+ console.logDebug = function(msg) {
+ if (console.logLevel >= console.DEBUG) {
+ console.log("DEBUG: " + msg);
+ }
}
- console.logTrace = function(msg){
- if(console.logLevel >= console.TRACE ) {
- console.log("TRACE: " + msg);
- }
+ console.logTrace = function(msg) {
+ if (console.logLevel >= console.TRACE) {
+ console.log("TRACE: " + msg);
+ }
}
- }
+ }
- function addStringFunctions() {
+ function addStringFunctions() {
//trim string - remove leading and trailing whitespaces
if (!String.prototype.trim) {
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/g, '');
- };
+ String.prototype.trim = function() {
+ return this.replace(/^\s+|\s+$/g, '');
+ };
}
if (!String.prototype.startsWith) {
- String.prototype.startsWith = function (str){
- return this.slice(0, str.length) == str;
- };
+ String.prototype.startsWith = function(str) {
+ return this.slice(0, str.length) == str;
+ };
}
if (!String.prototype.endsWith) {
- String.prototype.endsWith = function (str){
- return this.slice(-str.length) == str;
- };
+ String.prototype.endsWith = function(str) {
+ return this.slice(-str.length) == str;
+ };
}
if (!String.prototype.toCamelCase) {
- String.prototype.toCamelCase = function() {
- // remove all characters that should not be in a variable name
- // as well underscores an numbers from the beginning of the string
- var s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
- // uppercase letters preceeded by a hyphen or a space
- s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function(a,b,c) {
- return c.toUpperCase();
- });
- // uppercase letters following numbers
- s = s.replace(/([0-9]+)([a-zA-Z])/g, function(a,b,c) {
- return b + c.toUpperCase();
- });
- return s;
- }
+ String.prototype.toCamelCase = function() {
+ // remove all characters that should not be in a variable name
+ // as well underscores an numbers from the beginning of the string
+ var s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
+ // uppercase letters preceeded by a hyphen or a space
+ s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function(a, b, c) {
+ return c.toUpperCase();
+ });
+ // uppercase letters following numbers
+ s = s.replace(/([0-9]+)([a-zA-Z])/g, function(a, b, c) {
+ return b + c.toUpperCase();
+ });
+ return s;
+ }
}
- }
+ }
- function addDateFunctions() {
+ function addDateFunctions() {
Date.prototype.format = function(format) {
- var returnStr = '';
- var replace = Date.replaceChars;
- for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
- returnStr += curChar;
- }
- else if (replace[curChar]) {
- returnStr += replace[curChar].call(this);
- } else if (curChar != "\\"){
- returnStr += curChar;
- }
- }
- return returnStr;
- };
-
- Date.replaceChars = {
- shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
- longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
- shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
- longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
-
- // Day
- d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
- D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
- j: function() { return this.getDate(); },
- l: function() { return Date.replaceChars.longDays[this.getDay()]; },
- N: function() { return this.getDay() + 1; },
- S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
- w: function() { return this.getDay(); },
- z: function() { var d = new Date(this.getFullYear(),0,1); return Math.ceil((this - d) / 86400000); }, // Fixed now
- // Week
- W: function() { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); }, // Fixed now
- // Month
- F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
- m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
- M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
- n: function() { return this.getMonth() + 1; },
- t: function() { var d = new Date(); return new Date(d.getFullYear(), d.getMonth(), 0).getDate() }, // Fixed now, gets #days of date
- // Year
- L: function() { var year = this.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); }, // Fixed now
- o: function() { var d = new Date(this.valueOf()); d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now
- Y: function() { return this.getFullYear(); },
- y: function() { return ('' + this.getFullYear()).substr(2); },
- // Time
- a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
- A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
- B: function() { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTreminutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); }, // Fixed now
- g: function() { return this.getHours() % 12 || 12; },
- G: function() { return this.getHours(); },
- h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
- H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
- i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
- s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
- u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m; },
- // Timezone
- e: function() { return "Not Yet Supported"; },
- I: function() {
- var DST = null;
- for (var i = 0; i < 12; ++i) {
- var d = new Date(this.getFullYear(), i, 1);
- var offset = d.getTimezoneOffset();
- if (DST === null) DST = offset;
- else if (offset < DST) { DST = offset; break; }
- else if (offset > DST) break;
+ var returnStr = '';
+ var replace = Date.replaceChars;
+ for (var i = 0; i < format.length; i++) {
+ var curChar = format.charAt(i);
+ if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
+ returnStr += curChar;
+ } else if (replace[curChar]) {
+ returnStr += replace[curChar].call(this);
+ } else if (curChar != "\\") {
+ returnStr += curChar;
+ }
}
- return (this.getTimezoneOffset() == DST) | 0;
- },
- O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
- P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; }, // Fixed now
- T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
- Z: function() { return -this.getTimezoneOffset() * 60; },
- // Full Date/Time
- c: function() { return this.format("Y-m-d\\TH:i:sP"); }, // Fixed now
- r: function() { return this.toString(); },
- U: function() { return this.getTimep() / 1000; }
+ return returnStr;
};
- }
- function multilineString(commentFunction) {
+ Date.replaceChars = {
+ shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
+ shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+ longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
+
+ // Day
+ d: function() {
+ return (this.getDate() < 10 ? '0' : '') + this.getDate();
+ },
+ D: function() {
+ return Date.replaceChars.shortDays[this.getDay()];
+ },
+ j: function() {
+ return this.getDate();
+ },
+ l: function() {
+ return Date.replaceChars.longDays[this.getDay()];
+ },
+ N: function() {
+ return this.getDay() + 1;
+ },
+ S: function() {
+ return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th')));
+ },
+ w: function() {
+ return this.getDay();
+ },
+ z: function() {
+ var d = new Date(this.getFullYear(), 0, 1);
+ return Math.ceil((this - d) / 86400000);
+ }, // Fixed now
+ // Week
+ W: function() {
+ var d = new Date(this.getFullYear(), 0, 1);
+ return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7);
+ }, // Fixed now
+ // Month
+ F: function() {
+ return Date.replaceChars.longMonths[this.getMonth()];
+ },
+ m: function() {
+ return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1);
+ },
+ M: function() {
+ return Date.replaceChars.shortMonths[this.getMonth()];
+ },
+ n: function() {
+ return this.getMonth() + 1;
+ },
+ t: function() {
+ var d = new Date();
+ return new Date(d.getFullYear(), d.getMonth(), 0).getDate()
+ }, // Fixed now, gets #days of date
+ // Year
+ L: function() {
+ var year = this.getFullYear();
+ return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0));
+ }, // Fixed now
+ o: function() {
+ var d = new Date(this.valueOf());
+ d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3);
+ return d.getFullYear();
+ }, //Fixed now
+ Y: function() {
+ return this.getFullYear();
+ },
+ y: function() {
+ return ('' + this.getFullYear()).substr(2);
+ },
+ // Time
+ a: function() {
+ return this.getHours() < 12 ? 'am' : 'pm';
+ },
+ A: function() {
+ return this.getHours() < 12 ? 'AM' : 'PM';
+ },
+ B: function() {
+ return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTreminutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24);
+ }, // Fixed now
+ g: function() {
+ return this.getHours() % 12 || 12;
+ },
+ G: function() {
+ return this.getHours();
+ },
+ h: function() {
+ return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12);
+ },
+ H: function() {
+ return (this.getHours() < 10 ? '0' : '') + this.getHours();
+ },
+ i: function() {
+ return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes();
+ },
+ s: function() {
+ return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds();
+ },
+ u: function() {
+ var m = this.getMilliseconds();
+ return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m;
+ },
+ // Timezone
+ e: function() {
+ return "Not Yet Supported";
+ },
+ I: function() {
+ var DST = null;
+ for (var i = 0; i < 12; ++i) {
+ var d = new Date(this.getFullYear(), i, 1);
+ var offset = d.getTimezoneOffset();
+ if (DST === null) DST = offset;
+ else if (offset < DST) {
+ DST = offset;
+ break;
+ } else if (offset > DST) break;
+ }
+ return (this.getTimezoneOffset() == DST) | 0;
+ },
+ O: function() {
+ return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00';
+ },
+ P: function() {
+ return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00';
+ }, // Fixed now
+ T: function() {
+ var m = this.getMonth();
+ this.setMonth(0);
+ var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1');
+ this.setMonth(m);
+ return result;
+ },
+ Z: function() {
+ return -this.getTimezoneOffset() * 60;
+ },
+ // Full Date/Time
+ c: function() {
+ return this.format("Y-m-d\\TH:i:sP");
+ }, // Fixed now
+ r: function() {
+ return this.toString();
+ },
+ U: function() {
+ return this.getTimep() / 1000;
+ }
+ };
+ }
+
+ function multilineString(commentFunction) {
return commentFunction.toString()
- .replace(/^[^\/]+\/\*!?/, '')
- .replace(/\*\/[^\/]+$/, '');
- }
+ .replace(/^[^\/]+\/\*!?/, '')
+ .replace(/\*\/[^\/]+$/, '');
+ }
- function resizeIframe(iframe) {
+ function resizeIframe(iframe) {
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
- }
+ }
- })();
+ // APP Specific Functions
+ //############################################################################################################################
+ //############################################################################################################################
+ //############################################################################################################################
+
+ var jiraFunctions = {
+
+ getSelectedIssueKeyList: function() {
+ //Browse
+ if (/.*\/browse\/.*/g.test(document.URL)) {
+ return jQuery("a[data-issue-key][id='key-val']").map(function() {
+ return jQuery(this).attr('data-issue-key');
+ });
+ }
+
+ // RapidBoard
+ if (/.*\/secure\/RapidBoard.jspa.*/g.test(document.URL)) {
+ return jQuery('div[data-issue-key].ghx-selected').map(function() {
+ return jQuery(this).attr('data-issue-key');
+ });
+ }
+
+ return [];
+ },
+
+ getCardData: function(issueKey, callback) {
+ jiraFunctions.getIssueData(issueKey, function(data) {
+
+ var issueData = {};
+
+ 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) {
+ issueData.assignee = data.fields.assignee.displayName;
+ var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
+ if (avatarUrl.indexOf("ownerId=") >= 0) {
+ issueData.avatarUrl = avatarUrl;
+ }
+ }
+
+ if (data.fields.duedate) {
+ issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
+ }
+
+ issueData.hasAttachment = data.fields.attachment.length > 0;
+ if (issueData.description) {
+ var printScope = issueData.description.indexOf(printScopeDeviderToken);
+ if (printScope >= 0) {
+ issueData.description = issueData.description.substring(0, printScope);
+ issueData.hasAttachment = true;
+ }
+ }
+
+ issueData.storyPoints = data.fields.storyPoints;
+
+ issueData.epicKey = data.fields.epicLink;
+ if (issueData.epicKey) {
+ jiraFunctions.getIssueData(issueData.epicKey, function(data) {
+ issueData.epicName = data.fields.epicName;
+ }, false);
+ }
+
+ issueData.url = window.location.origin + "/browse/" + issueData.key;
+
+ //check for lrs
+ if (true) {
+ console.logInfo("Apply LRS Specifics");
+ //Desired-Date
+ if (data.fields.desiredDate) {
+ issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
+ }
+ }
+
+ callback(issueData);
+ });
+ },
+
+ getIssueData: function(issueKey, callback, async) {
+ async = typeof async !== 'undefined' ? async : true;
+ //https://docs.atlassian.com/jira/REST/latest/
+ var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
+ console.logDebug("IssueUrl: " + url);
+ console.logDebug("Issue: " + issueKey + " Loading...");
+ jQuery.ajax({
+ type: 'GET',
+ url: url,
+ data: {},
+ dataType: 'json',
+ async: async,
+ success: function(responseData) {
+ console.logDebug("Issue: " + issueKey + " Loaded!");
+ // add custom fields with field names
+ jQuery.each(responseData.names, function(key, value) {
+ if (key.startsWith("customfield_")) {
+ var newFieldId = value.toCamelCase();
+ console.logTrace("add new field: " + newFieldId + " with value from " + key);
+ responseData.fields[value.toCamelCase()] = responseData.fields[key];
+ }
+ });
+ callback(responseData);
+ },
+ });
+ }
+ }
+
+ var pivotalTrackerFunctions = {
+
+ getSelectedIssueKeyList: function() {
+ //Single Story
+ if (/.*\/stories\/.*/g.test(document.URL)) {
+ return [document.URL.replace(/.*\/stories\/(.*)\??/, '$1')];
+ }
+
+ // Board
+ if (/.*\/projects\/.*/g.test(document.URL)) {
+ return jQuery('.story[data-id]:has(.selected)').map(function() {
+ return jQuery(this).attr('data-id');
+ });
+ }
+
+ return [];
+ },
+
+ getCardData: function(issueKey, callback) {
+ pivotalTrackerFunctions.getIssueData(issueKey, function(data) {
+
+ var issueData = {};
+
+ issueData.key = data.id;
+
+ issueData.type = data.kind.toLowerCase();
+
+ issueData.summary = data.name;
+
+ issueData.description = data.description;
+ if (issueData.description) {
+ issueData.description = "" + issueData.description
+ }
+
+ if (data.owned_by && data.owned_by.length > 0) {
+ issueData.assignee = data.owner_ids[0].name;
+ }
+
+ if (data.deadline) {
+ issueData.dueDate = new Date(data.deadline).format('D d.m.');
+ }
+
+ issueData.hasAttachment = false;
+ if (issueData.description) {
+ var printScope = issueData.description.indexOf(printScopeDeviderToken);
+ if (printScope >= 0) {
+ issueData.description = issueData.description.substring(0, printScope);
+ issueData.hasAttachment = true;
+ }
+ }
+
+ issueData.storyPoints = data.estimate;
+
+ // TODO
+ // issueData.epicKey = data.fields.epicLink;
+ // if ( issueData.epicKey ) {
+ // getIssueDataPivotalTracker(issueData.epicKey , function(data) {
+ // issueData.epicName = data.fields.epicName;
+ // }, false);
+ // }
+
+ issueData.url = data.url;
+
+ callback(issueData);
+ });
+ },
+
+ 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.logDebug("IssueUrl: " + url);
+ console.logDebug("Issue: " + issueKey + " Loading...");
+ jQuery.ajax({
+ type: 'GET',
+ url: url,
+ data: {},
+ dataType: 'json',
+ async: async,
+ success: function(responseData) {
+ console.logDebug("Issue: " + issueKey + " Loaded!");
+ callback(responseData);
+ },
+ });
+ }
+ }
+
+
+
+})();
From ca41bae99dfbe926b9708a7af2b22c113f4466ba Mon Sep 17 00:00:00 2001
From: Bengt Brodersen
Date: Fri, 15 May 2015 17:20:26 +0200
Subject: [PATCH 03/19] wip quad layout
---
bookmarklet.js | 206 ++++++++++++++++++++-----------------------------
1 file changed, 83 insertions(+), 123 deletions(-)
diff --git a/bookmarklet.js b/bookmarklet.js
index 255cf4e..f7f8cab 100644
--- a/bookmarklet.js
+++ b/bookmarklet.js
@@ -2,37 +2,23 @@
var version = "3.5.0";
console.log("Version: " + version);
- var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
- || /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL); // PivotTracker
-
- var hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/";
- if (isDev) {
- console.log("DEVELOPMENT");
- hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
- } else {
- //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),
- m = s.getElementsByTagName(o)[0];
- a.async = 1;
- a.src = g;
- m.parentNode.insertBefore(a, m)
- })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
-
- ga('create', 'UA-50840116-3', {
- 'alwaysSendReferrer': true
- });
- ga('set', 'page', '/cardprinter');
- }
-
try {
+ var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
+ || /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL); // PivotTracker
+ var isProd = !isDev;
+
+ if (isProd){
+ //cors = "https://cors-anywhere.herokuapp.com/";
+ //$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
+ initGoogleAnalytics();
+ }
+
+ var hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/";
+ if (isDev) {
+ console.log("DEVELOPMENT");
+ hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
+ }
+
// load jQuery
if (window.jQuery === undefined) {
appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
@@ -43,9 +29,10 @@
init();
main();
});
+
} catch (err) {
console.log(err.message);
- if (!isDev) {
+ if (isProd) {
ga('send', 'exception', {
'exDescription': err.message,
'exFatal': true
@@ -54,18 +41,14 @@
}
function init() {
- addJQueryFunctions();
- addConsoleFunctions();
addStringFunctions();
addDateFunctions();
- printScopeDeviderToken = "Attachment";
+ var printScopeDeviderToken = "Attachment";
- console.logLevel = console.INFO;
+ var resourceOrigin = hostOrigin + "resources/";
- resourceOrigin = hostOrigin + "resources/";
-
- appFunctions = {};
+ var appFunctions = {};
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
appFunctions = jiraFunctions;
} else if (/.*\pivotaltracker.com\/.*/g.test(document.URL)) {
@@ -91,7 +74,7 @@
jQuery("body").append(printOverlayHTML);
jQuery("#card-print-overlay").prepend(printOverlayStyle);
- if (!isDev) {
+ if (isProd) {
ga('send', 'pageview');
}
@@ -106,7 +89,7 @@
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
- if (!isDev) {
+ if (isProd) {
ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length);
}
@@ -116,7 +99,19 @@
// jQuery("head",printDocument).append(orientationCSS);
printWindow.matchMedia("print").addListener(function() {
+ var htmlWidth = jQuery("html", printDocument).css("font-size").replace("cm", "") * jQuery("html", printDocument).width() / 2;
+ var cardMinWidth = jQuery(".card", printDocument).css("min-width").replace("px", "");
+
+ var cardScale = htmlWidth / cardMinWidth;
+
+ console.log("htmlWidth: " + htmlWidth);
+ console.log("cardMinWidth: " + cardMinWidth);
+ console.log("cardScale: " + cardScale);
+
+ jQuery("html", printDocument).css("font-size",cardScale+"cm");
+
jQuery(".page", printDocument).each(function(position, page) {
+
jQuery(page).css("width", "calc( 50% - 1cm )");
jQuery(page).css("height", "calc( 50% - 1cm )");
jQuery(page).css("float", "left");
@@ -136,7 +131,6 @@
jQuery(".page:nth-child(4n+3)", printDocument).each(function(position, page) {
jQuery(page).css("margin-top", "2cm");
});
-
jQuery(".page:nth-child(4n+4)", printDocument).each(function(position, page) {
jQuery(page).css("margin-top", "2cm");
});
@@ -180,7 +174,7 @@
jQuery("head", printDocument).append(printPanelPageCSS());
jQuery("head", printDocument).append(printPanelCardCSS());
- console.logInfo("load " + issueKeyList.length + " issues...");
+ console.log("load " + issueKeyList.length + " issues...");
var deferredList = [];
jQuery.each(issueKeyList, function(index, issueKey) {
@@ -191,8 +185,8 @@
jQuery("body", printDocument).append(page);
var deferred = addDeferred(deferredList);
appFunctions.getCardData(issueKey, function(cardData) {
- console.logDebug("cardData: " + cardData);
- if (!isDev) {
+ //console.log("cardData: " + cardData);
+ if (isProd) {
ga('send', 'event', 'task', 'generate', 'card', cardData.type);
}
fillCard(page, cardData);
@@ -201,16 +195,16 @@
deferred.resolve();
});
});
- console.logInfo("wait for issues loaded...");
+ console.log("wait for issues loaded...");
applyDeferred(deferredList, function() {
- console.logInfo("...all issues loaded.");
+ console.log("...all issues loaded.");
jQuery(printWindow).load(function() {
- console.logInfo("...all resources loaded.");
+ console.log("...all resources loaded.");
callback();
})
printDocument.close();
- console.logInfo("wait for resources loaded...");
+ console.log("wait for resources loaded...");
});
}
@@ -908,6 +902,26 @@
head.appendChild(script);
}
+ function initGoogleAnalytics(){
+ //
+ (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),
+ m = s.getElementsByTagName(o)[0];
+ a.async = 1;
+ a.src = g;
+ m.parentNode.insertBefore(a, m)
+ })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
+
+ ga('create', 'UA-50840116-3', {
+ 'alwaysSendReferrer': true
+ });
+ ga('set', 'page', '/cardprinter');
+ }
+
//############################################################################################################################
//############################################################################################################################
//############################################################################################################################
@@ -926,56 +940,6 @@
//############################################################################################################################
//############################################################################################################################
-
- function addJQueryFunctions() {
- //jQuery Extention
- jQuery.expr[':']['is'] = function(node, index, props) {
- return node.textContent == props[3];
- }
- }
-
-
- function addConsoleFunctions() {
-
- console.ERROR = 0;
- console.WARN = 1;
- console.INFO = 2;
- console.DEBUG = 3;
- console.TRACE = 4;
-
- console.logLevel = console.INFO;
-
- console.logError = function(msg) {
- if (console.logLevel >= console.ERROR) {
- console.log("ERROR: " + msg);
- }
- }
-
- console.logWarn = function(msg) {
- if (console.logLevel >= console.WARN) {
- console.log("WARN: " + msg);
- }
- }
-
- console.logInfo = function(msg) {
- if (console.logLevel >= console.INFO) {
- console.log("INFO: " + msg);
- }
- }
-
- console.logDebug = function(msg) {
- if (console.logLevel >= console.DEBUG) {
- console.log("DEBUG: " + msg);
- }
- }
-
- console.logTrace = function(msg) {
- if (console.logLevel >= console.TRACE) {
- console.log("TRACE: " + msg);
- }
- }
- }
-
function addStringFunctions() {
//trim string - remove leading and trailing whitespaces
@@ -1255,16 +1219,15 @@
issueData.epicKey = data.fields.epicLink;
if (issueData.epicKey) {
- jiraFunctions.getIssueData(issueData.epicKey, function(data) {
+ jiraFunctions.getIssueData(issueData.epicKey, function(data) {
issueData.epicName = data.fields.epicName;
}, false);
}
issueData.url = window.location.origin + "/browse/" + issueData.key;
- //check for lrs
+ //LRS Specific field mapping
if (true) {
- console.logInfo("Apply LRS Specifics");
//Desired-Date
if (data.fields.desiredDate) {
issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
@@ -1279,8 +1242,8 @@
async = typeof async !== 'undefined' ? async : true;
//https://docs.atlassian.com/jira/REST/latest/
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
- console.logDebug("IssueUrl: " + url);
- console.logDebug("Issue: " + issueKey + " Loading...");
+ console.log("IssueUrl: " + url);
+ //console.log("Issue: " + issueKey + " Loading...");
jQuery.ajax({
type: 'GET',
url: url,
@@ -1288,12 +1251,12 @@
dataType: 'json',
async: async,
success: function(responseData) {
- console.logDebug("Issue: " + issueKey + " Loaded!");
+ //console.log("Issue: " + issueKey + " Loaded!");
// add custom fields with field names
jQuery.each(responseData.names, function(key, value) {
if (key.startsWith("customfield_")) {
var newFieldId = value.toCamelCase();
- console.logTrace("add new field: " + newFieldId + " with value from " + key);
+ //console.log("add new field: " + newFieldId + " with value from " + key);
responseData.fields[value.toCamelCase()] = responseData.fields[key];
}
});
@@ -1306,20 +1269,20 @@
var pivotalTrackerFunctions = {
getSelectedIssueKeyList: function() {
- //Single Story
- if (/.*\/stories\/.*/g.test(document.URL)) {
- return [document.URL.replace(/.*\/stories\/(.*)\??/, '$1')];
- }
+ //Single Story
+ if (/.*\/stories\/.*/g.test(document.URL)) {
+ return [document.URL.replace(/.*\/stories\/(.*)\??/, '$1')];
+ }
- // Board
- if (/.*\/projects\/.*/g.test(document.URL)) {
- return jQuery('.story[data-id]:has(.selected)').map(function() {
- return jQuery(this).attr('data-id');
- });
- }
+ // Board
+ if (/.*\/projects\/.*/g.test(document.URL)) {
+ return jQuery('.story[data-id]:has(.selected)').map(function() {
+ return jQuery(this).attr('data-id');
+ });
+ }
- return [];
- },
+ return [];
+ },
getCardData: function(issueKey, callback) {
pivotalTrackerFunctions.getIssueData(issueKey, function(data) {
@@ -1374,8 +1337,8 @@
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.logDebug("IssueUrl: " + url);
- console.logDebug("Issue: " + issueKey + " Loading...");
+ console.log("IssueUrl: " + url);
+ //console.log("Issue: " + issueKey + " Loading...");
jQuery.ajax({
type: 'GET',
url: url,
@@ -1383,13 +1346,10 @@
dataType: 'json',
async: async,
success: function(responseData) {
- console.logDebug("Issue: " + issueKey + " Loaded!");
+ //console.log("Issue: " + issueKey + " Loaded!");
callback(responseData);
},
});
}
}
-
-
-
})();
From 7916ed7c783f6535a608fcc78e72633ce2e43b4e Mon Sep 17 00:00:00 2001
From: Bengt Brodersen
Date: Sun, 17 May 2015 02:21:14 +0200
Subject: [PATCH 04/19] add option for multiple Column and Rows
---
bookmarklet.js | 192 ++++++++++++++++++++++++++++---------------------
1 file changed, 111 insertions(+), 81 deletions(-)
diff --git a/bookmarklet.js b/bookmarklet.js
index f7f8cab..bd9ca79 100644
--- a/bookmarklet.js
+++ b/bookmarklet.js
@@ -3,30 +3,26 @@
console.log("Version: " + version);
try {
+ // load jQuery
+ if (window.jQuery === undefined) {
+ appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
+ }
+
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|| /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL); // PivotTracker
var isProd = !isDev;
-
- if (isProd){
- //cors = "https://cors-anywhere.herokuapp.com/";
- //$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
- initGoogleAnalytics();
- }
+ var appFunctions = null;
+ var printScopeDeviderToken = "Attachment";
var hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/";
if (isDev) {
console.log("DEVELOPMENT");
hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
}
-
- // load jQuery
- if (window.jQuery === undefined) {
- appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
- }
+ var resourceOrigin = hostOrigin + "resources/";
// wait untill all scripts loaded
appendScript('https://qoomon.github.io/void', function() {
- init();
main();
});
@@ -41,22 +37,26 @@
}
function init() {
+
addStringFunctions();
addDateFunctions();
- var printScopeDeviderToken = "Attachment";
-
- var resourceOrigin = hostOrigin + "resources/";
-
- var appFunctions = {};
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
appFunctions = jiraFunctions;
} else if (/.*\pivotaltracker.com\/.*/g.test(document.URL)) {
appFunctions = pivotalTrackerFunctions
}
+
+ if (isProd){
+ //cors = "https://cors-anywhere.herokuapp.com/";
+ //$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
+ initGoogleAnalytics();
+ }
}
function main() {
+ init();
+
//preconditions
if (jQuery("#card-print-overlay").length > 0) {
alert("Print Card already opened!");
@@ -64,7 +64,6 @@
}
var issueKeyList = appFunctions.getSelectedIssueKeyList();
-
if (issueKeyList.length <= 0) {
alert("Please select at least one issue.");
return;
@@ -74,6 +73,13 @@
jQuery("body").append(printOverlayHTML);
jQuery("#card-print-overlay").prepend(printOverlayStyle);
+ jQuery("#rowCount").val(readCookie("card_printer_row_count",2));
+ jQuery("#columnCount").val(readCookie("card_printer_column_count",1));
+ jQuery("#card-scale-range").val(readCookie("card_printer_card_scale",1));
+ jQuery("#multi-card-page-checkbox").attr('checked',readCookie("card_printer_multi_card_page",false) != 'false');
+ jQuery("#hide-description-checkbox").attr('checked',readCookie("card_printer_hide_description",false) != 'false');
+
+
if (isProd) {
ga('send', 'pageview');
}
@@ -81,61 +87,55 @@
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
renderCards(issueKeyList, function() {
jQuery("#card-print-dialog-title").text("Card Print");
- print();
+ // print();
});
}
function print() {
+ var rowCount = jQuery("#rowCount").val();
+ var columnCount = jQuery("#columnCount").val();
+ var scale = jQuery("#card-scale-range").val();
+ var multiCard = jQuery("#multi-card-page-checkbox").is(':checked');
+ var hideDescription = jQuery("#hide-description-checkbox").is(':checked');
+
+ writeCookie("card_printer_row_count", rowCount);
+ writeCookie("card_printer_column_count",columnCount);
+ writeCookie("card_printer_card_scale",scale);
+ writeCookie("card_printer_multi_card_page",multiCard);
+ writeCookie("card_printer_hide_description",hideDescription);
+
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
if (isProd) {
ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length);
}
-
- //jQuery("html", printDocument).css("font-size", + 0.5 +"cm");
-
- var orientationCSS = jQuery('')
- // jQuery("head",printDocument).append(orientationCSS);
-
+ var currentScale = jQuery("html", printDocument).css("font-size").replace("px", "");
printWindow.matchMedia("print").addListener(function() {
- var htmlWidth = jQuery("html", printDocument).css("font-size").replace("cm", "") * jQuery("html", printDocument).width() / 2;
- var cardMinWidth = jQuery(".card", printDocument).css("min-width").replace("px", "");
+ jQuery("html", printDocument).css("font-size",currentScale +"px");
+ jQuery(".page", printDocument).css("height", "calc( 100% / " + rowCount + " )");
+ jQuery(".page", printDocument).css("width", "calc( 100% / " + columnCount + " )");
- var cardScale = htmlWidth / cardMinWidth;
+ var pageWidth = jQuery(".page", printDocument).width();
+ var cardWidth = jQuery(".card", printDocument).width();
- console.log("htmlWidth: " + htmlWidth);
- console.log("cardMinWidth: " + cardMinWidth);
- console.log("cardScale: " + cardScale);
+ var newScale = currentScale * pageWidth / cardWidth;
- jQuery("html", printDocument).css("font-size",cardScale+"cm");
+ jQuery("html", printDocument).css("font-size",newScale +"px");
- jQuery(".page", printDocument).each(function(position, page) {
+ jQuery(".card", printDocument).each(function(position, element) {
- jQuery(page).css("width", "calc( 50% - 1cm )");
- jQuery(page).css("height", "calc( 50% - 1cm )");
- jQuery(page).css("float", "left");
-
- var height = jQuery(page).height() - jQuery(page).find(".card-header").outerHeight() - jQuery(page).find(".card-footer").outerHeight() - jQuery(page).find(".content-header").outerHeight() - 40;
- jQuery(page).find(".description").css("max-height", height + "px");
- var lineHeight = jQuery(page).find(".description").css("line-height");
- lineHeight = lineHeight.substring(0, lineHeight.length - 2);
- var lineClamp = Math.floor(height / lineHeight);
- jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp + "");
+ var height = jQuery(element).height()
+ - jQuery(element).find(".card-header").height()
+ - jQuery(element).find(".card-footer").height()
+ - jQuery(element).find(".content-header").height()
+ - 40;
+ jQuery(element).find(".description").css("max-height", height + "px");
});
});
- jQuery(".page:odd", printDocument).each(function(position, page) {
- jQuery(page).css("margin-left", "2cm");
- });
- jQuery(".page:nth-child(4n+3)", printDocument).each(function(position, page) {
- jQuery(page).css("margin-top", "2cm");
- });
- jQuery(".page:nth-child(4n+4)", printDocument).each(function(position, page) {
- jQuery(page).css("margin-top", "2cm");
- });
-
printWindow.print();
+ jQuery("html", printDocument).css("font-size",currentScale +"px");
}
function hideDescription(hide) {
@@ -273,7 +273,6 @@
//############################################################################################################################
//############################################################################################################################
-
// http://www.cssdesk.com/T9hXg
function printOverlayHTML() {
@@ -296,9 +295,11 @@