add Scale
This commit is contained in:
parent
d93637b694
commit
aaa3a9c9c5
@ -1,9 +1,10 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var global = {};
|
var global = {};
|
||||||
global.version = "4.2.5";
|
global.version = "4.2.6";
|
||||||
global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer";
|
global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer";
|
||||||
global.isDev = document.currentScript == null;
|
global.isDev = document.currentScript == null;
|
||||||
global.isProd = !global.isDev;
|
global.isProd = !global.isDev;
|
||||||
|
global.settings = {};
|
||||||
|
|
||||||
window.addEventListener("error", function(event) {
|
window.addEventListener("error", function(event) {
|
||||||
var error = event.error;
|
var error = event.error;
|
||||||
@ -24,14 +25,16 @@
|
|||||||
// wait untill all scripts loaded
|
// wait untill all scripts loaded
|
||||||
appendScript('https://qoomon.github.io/void', function() {
|
appendScript('https://qoomon.github.io/void', function() {
|
||||||
init().then(function(){
|
init().then(function(){
|
||||||
main();
|
return main();
|
||||||
}).catch(function(cause){
|
}).catch(function(cause){
|
||||||
console.log("ERROR " + JSON.stringify(cause,2,2));
|
console.log("ERROR " + cause.stack);
|
||||||
alert("Sorry somthing went wrong. Please create an issue at " + global.issueTrackingUrl);
|
alert("Sorry somthing went wrong.\n\nPlease create an issue at " + global.issueTrackingUrl + "\n\n" + cause.stack);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
var promises = [];
|
||||||
|
|
||||||
console.log("Run...")
|
console.log("Run...")
|
||||||
// determine application
|
// determine application
|
||||||
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
||||||
@ -62,8 +65,16 @@
|
|||||||
if (issueKeyList.length <= 0) {
|
if (issueKeyList.length <= 0) {
|
||||||
alert("Please select at least one issue.");
|
alert("Please select at least one issue.");
|
||||||
return;
|
return;
|
||||||
|
} else if (issueKeyList.length > 100) {
|
||||||
|
confirm("Are you sure you want select " + issueKeyList.length + " issues?");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var settings = global.settings;
|
||||||
|
settings.scale = readCookie("card_printer_font_scale",1);
|
||||||
|
settings.rowCount = readCookie("card_printer_row_count",2);
|
||||||
|
settings.colCount = readCookie("card_printer_column_count", 1);
|
||||||
|
|
||||||
// open print preview
|
// open print preview
|
||||||
jQuery("body").append(printPreviewElement());
|
jQuery("body").append(printPreviewElement());
|
||||||
jQuery("#card-print-overlay").prepend(printOverlayStyleElement());
|
jQuery("#card-print-overlay").prepend(printOverlayStyleElement());
|
||||||
@ -77,24 +88,24 @@
|
|||||||
redrawCards();
|
redrawCards();
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery("#rowCount").val(readCookie("card_printer_row_count", 2));
|
jQuery("#font-scale-range").val(settings.scale);
|
||||||
jQuery("#columnCount").val(readCookie("card_printer_column_count", 1));
|
jQuery("#rowCount").val(settings.rowCount);
|
||||||
jQuery("#font-scale-range").val(readCookie("card_printer_font_scale",1));
|
jQuery("#columnCount").val(settings.colCount);
|
||||||
|
|
||||||
jQuery("#single-card-page-checkbox").attr('checked', readCookie("card_printer_single_card_page", 'true') == 'true');
|
jQuery("#single-card-page-checkbox").attr('checked', readCookie("card_printer_single_card_page", 'true') == 'true');
|
||||||
jQuery("#hide-description-checkbox").attr('checked', readCookie("card_printer_hide_description", 'false') == 'true');
|
jQuery("#hide-description-checkbox").attr('checked', readCookie("card_printer_hide_description", 'false') == 'true');
|
||||||
jQuery("#hide-assignee-checkbox").attr('checked', readCookie("card_printer_hide_assignee", 'true') == 'true');
|
jQuery("#hide-assignee-checkbox").attr('checked', readCookie("card_printer_hide_assignee", 'true') == 'true');
|
||||||
jQuery("#hide-due-date-checkbox").attr('checked', readCookie("card_printer_hide_due_date", 'false') == 'true');
|
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 " + global.version + " - Loading issues...");
|
jQuery("#card-print-dialog-title").text("Card Printer " + global.version + " - Loading issues...");
|
||||||
renderCards(issueKeyList).then(function() {
|
promises.push(renderCards(issueKeyList).then(function() {
|
||||||
jQuery("#card-print-dialog-title").text("Card Printer " + global.version);
|
jQuery("#card-print-dialog-title").text("Card Printer " + global.version);
|
||||||
//print();
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
if (global.isProd) {
|
if (global.isProd) {
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
}
|
}
|
||||||
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@ -189,9 +200,7 @@
|
|||||||
});
|
});
|
||||||
console.log("wait for resources loaded...");
|
console.log("wait for resources loaded...");
|
||||||
printDocument.close();
|
printDocument.close();
|
||||||
}).catch(function(cause){
|
});
|
||||||
console.log("ERROR " + JSON.stringify(cause))
|
|
||||||
});;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function redrawCards() {
|
function redrawCards() {
|
||||||
@ -301,16 +310,6 @@
|
|||||||
jQuery("head", printDocument).append(style);
|
jQuery("head", printDocument).append(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide/show status
|
|
||||||
jQuery("#styleHideStatus", printDocument).remove();
|
|
||||||
if (!jQuery("#hide-status-checkbox")[0].checked) {
|
|
||||||
var style = document.createElement('style');
|
|
||||||
style.id = 'styleHideStatus';
|
|
||||||
style.type = 'text/css';
|
|
||||||
style.innerHTML = ".issue-status { display: none; }"
|
|
||||||
jQuery("head", printDocument).append(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable/disable single card page
|
// enable/disable single card page
|
||||||
jQuery("#styleSingleCardPage", printDocument).remove();
|
jQuery("#styleSingleCardPage", printDocument).remove();
|
||||||
if (jQuery("#single-card-page-checkbox")[0].checked) {
|
if (jQuery("#single-card-page-checkbox")[0].checked) {
|
||||||
@ -327,16 +326,14 @@
|
|||||||
var printWindow = printFrame[0].contentWindow;
|
var printWindow = printFrame[0].contentWindow;
|
||||||
var printDocument = printWindow.document;
|
var printDocument = printWindow.document;
|
||||||
|
|
||||||
var columnCount = jQuery("#columnCount").val();
|
var scaleRoot = global.settings.scale;
|
||||||
var rowCount = jQuery("#rowCount").val();
|
var rowCount = global.settings.rowCount;
|
||||||
|
var columnCount = global.settings.colCount;
|
||||||
var cardCount = jQuery(".card", printDocument).length;
|
|
||||||
var pageCount = Math.ceil(cardCount / (columnCount * rowCount))
|
|
||||||
|
|
||||||
// scale
|
// scale
|
||||||
|
|
||||||
// reset scale
|
// reset scale
|
||||||
jQuery("html", printDocument).css("font-size", "1cm");
|
jQuery("html", printDocument).css("font-size", scaleRoot +"cm");
|
||||||
jQuery("#styleColumnCount", printDocument).remove();
|
jQuery("#styleColumnCount", printDocument).remove();
|
||||||
jQuery("#styleRowCount", printDocument).remove();
|
jQuery("#styleRowCount", printDocument).remove();
|
||||||
|
|
||||||
@ -354,9 +351,9 @@
|
|||||||
var scaleHeight = cardMaxHeight / cardMinHeight - 0.01;
|
var scaleHeight = cardMaxHeight / cardMinHeight - 0.01;
|
||||||
|
|
||||||
// scale down
|
// scale down
|
||||||
var scale = Math.min(scaleWidth, scaleHeight, 1) * global.scale;
|
var scale = Math.min(scaleWidth, scaleHeight, 1);
|
||||||
if (scale < 1) {
|
if (scale < 1) {
|
||||||
jQuery("html", printDocument).css("font-size", scale + "cm");
|
jQuery("html", printDocument).css("font-size", ( scaleRoot * scale) + "cm");
|
||||||
}
|
}
|
||||||
|
|
||||||
// size
|
// size
|
||||||
@ -455,20 +452,12 @@
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// show status
|
|
||||||
|
|
||||||
result.find("#hide-status-checkbox").click(function() {
|
|
||||||
writeCookie("card_printer_hide_status", this.checked);
|
|
||||||
redrawCards();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// scale font
|
// scale font
|
||||||
|
|
||||||
result.find("#font-scale-range").on("input", function() {
|
result.find("#font-scale-range").on("input", function() {
|
||||||
writeCookie("card_printer_font_scale", jQuery(this).val());
|
writeCookie("card_printer_font_scale", jQuery(this).val());
|
||||||
|
|
||||||
global.scale = jQuery(this).val();
|
global.settings.scale = jQuery(this).val();
|
||||||
|
|
||||||
redrawCards();
|
redrawCards();
|
||||||
});
|
});
|
||||||
@ -477,6 +466,9 @@
|
|||||||
|
|
||||||
result.find("#rowCount").on("input", function() {
|
result.find("#rowCount").on("input", function() {
|
||||||
writeCookie("card_printer_row_count", jQuery(this).val());
|
writeCookie("card_printer_row_count", jQuery(this).val());
|
||||||
|
|
||||||
|
global.settings.rowCount = jQuery(this).val();
|
||||||
|
|
||||||
redrawCards();
|
redrawCards();
|
||||||
});
|
});
|
||||||
result.find("#rowCount").click(function() {
|
result.find("#rowCount").click(function() {
|
||||||
@ -486,6 +478,9 @@
|
|||||||
|
|
||||||
result.find("#columnCount").on("input", function() {
|
result.find("#columnCount").on("input", function() {
|
||||||
writeCookie("card_printer_column_count", jQuery(this).val());
|
writeCookie("card_printer_column_count", jQuery(this).val());
|
||||||
|
|
||||||
|
global.settings.colCount = jQuery(this).val();
|
||||||
|
|
||||||
redrawCards();
|
redrawCards();
|
||||||
});
|
});
|
||||||
result.find("#columnCount").click(function() {
|
result.find("#columnCount").click(function() {
|
||||||
@ -853,7 +848,7 @@
|
|||||||
if (/.*\/issues\/\?jql=.*/g.test(document.URL)) {
|
if (/.*\/issues\/\?jql=.*/g.test(document.URL)) {
|
||||||
var jql = document.URL.replace(/.*\?jql=(.*)/, '$1');
|
var jql = document.URL.replace(/.*\?jql=(.*)/, '$1');
|
||||||
var jqlIssues = [];
|
var jqlIssues = [];
|
||||||
var url = '/rest/api/2/search?jql=' + jql + "&maxResults=1000";
|
var url = '/rest/api/2/search?jql=' + jql + "&maxResults=500&fields=key";
|
||||||
console.log("IssueUrl: " + url);
|
console.log("IssueUrl: " + url);
|
||||||
//console.log("Issue: " + issueKey + " Loading...");
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
@ -1013,11 +1008,7 @@
|
|||||||
issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key;
|
issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return Promise.all(promises).then(function(results){return issueData;});
|
||||||
Promise.all(promises)
|
|
||||||
.then(function(){resolve(issueData);})
|
|
||||||
.catch(function(cause){reject(cause);});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getIssueData = function(issueKey) {
|
module.getIssueData = function(issueKey) {
|
||||||
@ -1082,11 +1073,7 @@
|
|||||||
issueData.url = data.url;
|
issueData.url = data.url;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return Promise.all(promises).then(function(results){return issueData;});
|
||||||
Promise.all(promises)
|
|
||||||
.then(function(){resolve(issueData);})
|
|
||||||
.catch(function(cause){reject(cause);});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getIssueData = function(issueKey, callback, async) {
|
module.getIssueData = function(issueKey, callback, async) {
|
||||||
@ -1137,11 +1124,7 @@
|
|||||||
issueData.url = data.shortUrl;
|
issueData.url = data.shortUrl;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return Promise.all(promises).then(function(results){return issueData;});
|
||||||
Promise.all(promises)
|
|
||||||
.then(function(){resolve(issueData);})
|
|
||||||
.catch(function(cause){reject(cause);});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getIssueData = function(issueKey, callback, async) {
|
module.getIssueData = function(issueKey, callback, async) {
|
||||||
|
|||||||
12
card.css
12
card.css
@ -23,8 +23,7 @@ body {
|
|||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
.badge {
|
.badge {
|
||||||
// WHITESMOKE, GAINSBOROM;
|
background-color: WHITESMOKE;
|
||||||
background-color: #E0E0E0;
|
|
||||||
}
|
}
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
@ -53,16 +52,16 @@ body {
|
|||||||
.author {
|
.author {
|
||||||
color: DIMGREY;
|
color: DIMGREY;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:0.35rem;
|
top: 0.5rem;
|
||||||
left: calc(50% - 2rem);
|
left: calc(50% - 2rem);
|
||||||
font-size: 0.6rem;
|
font-size: 0.8rem;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
line-height: 0.38rem;
|
line-height: 0.38rem;
|
||||||
}
|
}
|
||||||
.author > span:nth-of-type(2) {
|
.author > span:nth-of-type(2) {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -0.07rem;
|
top: 0.0rem;
|
||||||
left: 0.49rem;
|
left: 0.65rem;
|
||||||
font-size: 0.5em;
|
font-size: 0.5em;
|
||||||
}
|
}
|
||||||
.card {
|
.card {
|
||||||
@ -305,7 +304,6 @@ body {
|
|||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: 65%;
|
background-size: 65%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
@page {
|
@page {
|
||||||
margin: 0.0mm;
|
margin: 0.0mm;
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="card-print-dialog-footer">
|
<div id="card-print-dialog-footer">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<label style="margin-right:10px"><input id="font-scale-range" type="range" min="0.5" max="1.0" step="0.01" value="1.0" />Scale</label>
|
<label style="margin-right:10px; padding-right: 3px;"><input id="font-scale-range" type="range" min="0.5" max="1.0" step="0.01" style="width: 100px; position: relative; top: 2px; margin-right:5px;" value="1.0" />Scale</label>
|
||||||
<label style="margin-right:10px;"><input id="rowCount" type="text" class="text" maxlength="1" style="width: 10px;" value="2"/>Row Count</label>
|
<label style="margin-right:0px;"><input id="rowCount" type="text" class="text" maxlength="1" style="width: 10px;" value="2"/>x</label>
|
||||||
<label style="margin-right:10px;"><input id="columnCount" type="text" class="text" maxlength="1" style="width: 10px;" value="1"/>Column Count</label>
|
<label style="margin-right:10px;"><input id="columnCount" type="text" class="text" maxlength="1" style="width: 10px; margin-right:5px;" value="1"/>Page Grid</label>
|
||||||
<label style="margin-right:10px"><input id="single-card-page-checkbox" type="checkbox"/>Single Card Per Page</label>
|
<label style="margin-right:10px"><input id="single-card-page-checkbox" type="checkbox"/>Single Card Per Page</label>
|
||||||
<label style="margin-right:10px"><input id="hide-description-checkbox" type="checkbox"/>Hide Description</label>
|
<label style="margin-right:10px"><input id="hide-description-checkbox" type="checkbox"/>Hide Description</label>
|
||||||
<label style="margin-right:10px"><input id="hide-assignee-checkbox" type="checkbox"/>Hide Assignee</label>
|
<label style="margin-right:10px"><input id="hide-assignee-checkbox" type="checkbox"/>Hide Assignee</label>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user