cleanup
This commit is contained in:
parent
362fc8a9b8
commit
500eb70734
@ -5,10 +5,7 @@
|
|||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
ga('create', 'UA-50840116-3', 'auto', {'alwaysSendReferrer': true});
|
ga('create', 'UA-50840116-3', 'auto', {'alwaysSendReferrer': true});
|
||||||
ga('send', {
|
ga('send', {'hitType': 'pageview', 'page': '/jiracardprinter/Bookmarklet.js'});
|
||||||
'hitType': 'pageview',
|
|
||||||
'page': '/jiracardprinter/Bookmarklet.js'
|
|
||||||
});
|
|
||||||
// </GoogleAnalytics>
|
// </GoogleAnalytics>
|
||||||
|
|
||||||
// load jQuery
|
// load jQuery
|
||||||
@ -34,6 +31,7 @@ function init(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main(){
|
function main(){
|
||||||
|
//preconditions
|
||||||
if(jQuery("#card-print-overlay").length > 0){
|
if(jQuery("#card-print-overlay").length > 0){
|
||||||
alert("Print Card already opened!");
|
alert("Print Card already opened!");
|
||||||
return;
|
return;
|
||||||
@ -45,13 +43,18 @@ function main(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openPrintPreview(issueKeyList);
|
// open print preview
|
||||||
|
jQuery("head").append(printOverlayStyle);
|
||||||
|
jQuery("body").append(printOverlayHTML);
|
||||||
|
|
||||||
|
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
|
||||||
|
renderCards(issueKeyList, function(){
|
||||||
|
jQuery("#card-print-dialog-title").text("Card Print");
|
||||||
|
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPrintPreview(issueKeyList) {
|
function renderCards(issueKeyList, callback) {
|
||||||
|
|
||||||
jQuery("head").append(newPrintOverlayStyle);
|
|
||||||
jQuery("body").append(newPrintOverlayHTML);
|
|
||||||
|
|
||||||
var printFrame = jQuery("#card-print-dialog-content-iframe");
|
var printFrame = jQuery("#card-print-dialog-content-iframe");
|
||||||
var printWindow = printFrame[0].contentWindow;
|
var printWindow = printFrame[0].contentWindow;
|
||||||
@ -60,11 +63,11 @@ function openPrintPreview(issueKeyList) {
|
|||||||
printDocument.open();
|
printDocument.open();
|
||||||
printDocument.write("<head/><body/>");
|
printDocument.write("<head/><body/>");
|
||||||
|
|
||||||
jQuery("head", printDocument).append(newPrintPanelPageCSS());
|
jQuery("head", printDocument).append(printPanelPageCSS());
|
||||||
jQuery("head", printDocument).append(newPrintPanelCardCSS());
|
jQuery("head", printDocument).append(printPanelCardCSS());
|
||||||
|
|
||||||
console.logInfo("load " + issueKeyList.length + " issues...");
|
console.logInfo("load " + issueKeyList.length + " issues...");
|
||||||
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
|
|
||||||
var deferredList = [];
|
var deferredList = [];
|
||||||
|
|
||||||
issueKeyList.each(function(position, issueKey) {
|
issueKeyList.each(function(position, issueKey) {
|
||||||
@ -83,9 +86,8 @@ function openPrintPreview(issueKeyList) {
|
|||||||
|
|
||||||
applyDeferred(deferredList,function() {
|
applyDeferred(deferredList,function() {
|
||||||
jQuery(printWindow).load(function(){
|
jQuery(printWindow).load(function(){
|
||||||
jQuery("#card-print-dialog-title").text("Card Print");
|
|
||||||
console.logInfo("everything loaded!");
|
console.logInfo("everything loaded!");
|
||||||
printWindow.print();
|
callback();
|
||||||
})
|
})
|
||||||
printDocument.close();
|
printDocument.close();
|
||||||
console.logInfo("wait for resources loaded...");
|
console.logInfo("wait for resources loaded...");
|
||||||
@ -93,7 +95,6 @@ function openPrintPreview(issueKeyList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closePrintPreview(){
|
function closePrintPreview(){
|
||||||
console.logInfo("close overlay");
|
|
||||||
jQuery("#card-print-overlay").remove();
|
jQuery("#card-print-overlay").remove();
|
||||||
jQuery("#card-print-overlay-style").remove();
|
jQuery("#card-print-overlay-style").remove();
|
||||||
}
|
}
|
||||||
@ -272,7 +273,7 @@ function fillCardWithJSONData(card, data) {
|
|||||||
|
|
||||||
// http://www.cssdesk.com/T9hXg
|
// http://www.cssdesk.com/T9hXg
|
||||||
|
|
||||||
function newPrintOverlayHTML(){
|
function printOverlayHTML(){
|
||||||
var result = jQuery(document.createElement('div'))
|
var result = jQuery(document.createElement('div'))
|
||||||
.attr("id","card-print-overlay")
|
.attr("id","card-print-overlay")
|
||||||
.html(multilineString(function() {
|
.html(multilineString(function() {
|
||||||
@ -330,7 +331,7 @@ function newPrintOverlayHTML(){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newPrintOverlayStyle(){
|
function printOverlayStyle(){
|
||||||
var result = jQuery(document.createElement('style'))
|
var result = jQuery(document.createElement('style'))
|
||||||
.attr("id", "card-print-overlay-style")
|
.attr("id", "card-print-overlay-style")
|
||||||
.attr("type", "text/css")
|
.attr("type", "text/css")
|
||||||
@ -430,7 +431,7 @@ return result;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function newPrintPanelPageCSS(){
|
function printPanelPageCSS(){
|
||||||
|
|
||||||
var result = jQuery(document.createElement('style'))
|
var result = jQuery(document.createElement('style'))
|
||||||
.attr("id", "printPanelPageStyle")
|
.attr("id", "printPanelPageStyle")
|
||||||
@ -542,7 +543,7 @@ function newCardHTML(issueKey){
|
|||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newPrintPanelCardCSS(){
|
function printPanelCardCSS(){
|
||||||
var result = jQuery(document.createElement('style'))
|
var result = jQuery(document.createElement('style'))
|
||||||
.attr("type", "text/css")
|
.attr("type", "text/css")
|
||||||
.html(multilineString(function() {
|
.html(multilineString(function() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user