Merge pull request #4 from qoomon/develop

Google Analytix
This commit is contained in:
Bengt Brodersen 2015-01-28 01:13:18 +01:00
commit de3e3e6100

View File

@ -1,28 +1,36 @@
var qoomon_dev;
var isDev = qoomon_dev;
version = "3.1.7";
console.logInfo("Version: " + version);
// <GoogleAnalytics>
(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', 'auto', {'alwaysSendReferrer': true});
ga('send', {'hitType': 'pageview', 'page': '/jiracardprinter/Bookmarklet.js'});
ga('create', 'UA-50840116-3', 'auto');
ga('set', 'location', window.location.protocol + '//' + window.location.host + window.location.pathname);
ga('set', 'hostname', window.location.hostname);
ga('set', 'page', '/cardprinter');
ga('set', 'title', document.title);
//ga('set', 'campaignSource', '(direct)');
//ga('set', 'campaignMedium', '(none)');
// </GoogleAnalytics>
// load jQuery
if (window.jQuery === undefined) {
appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
}
try {
var qoomon_dev;
var isDev = qoomon_dev;
// wait untill all scripts loaded
appendScript('https://qoomon.github.io/void', function(){
// 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();
});
});
function init(){
function init(){
addJQueryFunctions();
addConsoleFunctions();
addStringFunctions();
@ -41,9 +49,9 @@ function init(){
//$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
console.logLevel = console.INFO;
}
}
function main(){
function main(){
//preconditions
if(jQuery("#card-print-overlay").length > 0){
alert("Print Card already opened!");
@ -51,6 +59,7 @@ function main(){
}
var issueKeyList = getSelectedIssueKeyList();
if(issueKeyList.length <= 0){
alert("Please select at least one issue.");
return;
@ -60,14 +69,21 @@ function main(){
jQuery("body").append(printOverlayHTML);
jQuery("#card-print-overlay").prepend(printOverlayStyle);
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");
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
print();
});
}
}
function renderCards(issueKeyList, callback) {
function print(){
ga('send', 'event', 'button', 'click', 'print', $(".card").length );
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
}
function renderCards(issueKeyList, callback) {
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
@ -107,15 +123,15 @@ function renderCards(issueKeyList, callback) {
printDocument.close();
console.logInfo("wait for resources loaded...");
});
}
}
function closePrintPreview(){
function closePrintPreview(){
jQuery("#card-print-overlay").remove();
jQuery("#card-print-overlay-style").remove();
}
}
function getSelectedIssueKeyList() {
function getSelectedIssueKeyList() {
//JIRA
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
@ -135,9 +151,9 @@ function getSelectedIssueKeyList() {
}
return [];
}
}
function fillCardWithJSONData(card, data) {
function fillCardWithJSONData(card, data) {
//Key
var key = data.key;
console.logDebug("key: " + key);
@ -281,21 +297,21 @@ function fillCardWithJSONData(card, data) {
//############################################################################################################################
//############################################################################################################################
//############################################################################################################################
//############################################################################################################################
//############################################################################################################################
//############################################################################################################################
// 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() {
/*!
<div id="card-print-dialog">
/*!
<div id="card-print-dialog">
<div id="card-print-dialog-header">
<div id="card-print-dialog-title">Card Print</div>
<div id="info">
@ -311,8 +327,8 @@ function printOverlayHTML(){
<iframe id="card-print-dialog-content-iframe"></iframe>
</div>
<div id="card-print-dialog-footer"></div>
</div>
*/
</div>
*/
}));
// info
@ -332,7 +348,7 @@ function printOverlayHTML(){
result.find("#card-print-dialog-print")
.click(function(event){
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
print();
return false;
});
@ -363,15 +379,15 @@ function printOverlayHTML(){
});
return result;
}
}
function printOverlayStyle(){
function printOverlayStyle(){
var result = jQuery(document.createElement('style'))
.attr("id", "card-print-overlay-style")
.attr("type", "text/css")
.html(multilineString(function() {
/*!
#card-print-overlay {
/*!
#card-print-overlay {
position: fixed;
height: 100%;
width: 100%;
@ -383,9 +399,9 @@ function printOverlayStyle(){
word-wrap:break-word;
z-index: 99999;
}
}
#card-print-dialog {
#card-print-dialog {
position: relative;
top: 60px;
@ -404,9 +420,9 @@ function printOverlayStyle(){
border-radius: 4px;
overflow: hidden;
}
}
#card-print-dialog-header {
#card-print-dialog-header {
position: relative;
background: #f0f0f0;
height: 25px;
@ -414,50 +430,50 @@ function printOverlayStyle(){
border-bottom: 1px solid #cccccc;
padding: 15px 20px 15px 20px;
}
}
#card-print-dialog-content {
#card-print-dialog-content {
position: relative;
background: white;
height: calc(100% - 106px); + height: 100px;
height: calc(100% - 106px); + height: 100px;
width: 100%;
overflow-y: scroll;
}
}
#card-print-dialog-content-iframe {
#card-print-dialog-content-iframe {
position: relative;
height: 100%;
width: 100%;
border:none;
}
}
#card-print-dialog-footer {
#card-print-dialog-footer {
position: relative;
background: #f0f0f0;
border-top: 1px solid #cccccc;
height: 30px;
padding: 10px;
text-align: right;
}
}
#buttons {
#buttons {
position: relative;
float: right;
display: inline-block;
height 30px;
}
}
#info {
#info {
position: absolute;
right: 400px;
float: left;
display: inline-block;
height 30px;
}
}
#card-print-dialog-title{
#card-print-dialog-title{
position: relative;
float: left;
color: rgb(51, 51, 51);
@ -467,14 +483,14 @@ height: calc(100% - 106px); + height: 100px;
font-weight: normal;
height: 30px;
line-height: 30px;
}
*/
}));
return result;
}
}
*/
}));
return result;
}
function printPanelPageCSS(){
function printPanelPageCSS(){
var result = jQuery(document.createElement('style'))
.attr("id", "printPanelPageStyle")
@ -530,28 +546,28 @@ function printPanelPageCSS(){
-webkit-filter:opacity(1.0);
filter:opacity(1.0);
}
}
.page:last-of-type {
page-break-after: auto;
}
}
*/
}));
.page:last-of-type {
page-break-after: auto;
}
}
*/
}));
return result;
}
return result;
}
// http://www.cssdesk.com/scHcP
// http://www.cssdesk.com/scHcP
function newPage(issueKey){
function newPage(issueKey){
var page = jQuery(document.createElement('div'))
.attr("id",issueKey)
.addClass("page")
.html(multilineString(function() {
/*!
<div class="card">
/*!
<div class="card">
<div class="author">Bengt Brodersen - qoomon.com</div>
<div class="card-border"></div>
<div class="card-header">
@ -578,38 +594,38 @@ function newPage(issueKey){
<span class="epic-name" contenteditable="true"></span>
</div>
</div>
</div>
*/
</div>
*/
}));
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 {
}
body {
margin: 0;
}
.hidden {
}
.hidden {
visibility: hidden;
}
.card-header:after,
.card-footer:after {
}
.card-header:after,
.card-footer:after {
content:" ";
display: block;
clear: both;
height:0
}
.card-border,
.badge,
.shadow {
}
.card-border,
.badge,
.shadow {
border-style: solid;
border-color: #2f2f2f;
border-top-width: 0.14cm;
@ -619,24 +635,24 @@ body {
-webkit-border-radius: 0.25cm;
border-radius: 0.25cm;
// -webkit-filter: drop-shadow(0px 5px 10px black)
}
.circular {
}
.circular {
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.badge {
}
.badge {
width: 3.2cm;
height: 3.2cm;
background: #d0d0d0;
}
}
.card {
.card {
position: relative;
min-width: 21.0cm;
}
.author {
}
.author {
z-index: 999;
position: absolute;
top:3.1cm;
@ -647,8 +663,8 @@ body {
transform: rotate(-90deg);
font-size: 0.4cm;
color: DARKGREY;
}
.card-border {
}
.card-border {
position: absolute;
top:2.0cm;
left:0.4cm;
@ -656,37 +672,37 @@ body {
height: calc(100% - 4.0cm);
background: #ffffff;
}
.card-header {
}
.card-header {
position: relative;
}
.card-content {
}
.card-content {
position: relative;
margin-top: 0.3cm;
margin-left: 1.0cm;
margin-right: 1.1cm;
margin-bottom: 0.2cm;
min-height: 3.0cm;
}
.content-header {
}
.content-header {
position: relative;
font-size: 1.1cm;
line-height: 1.1cm;
margin-bottom: 0.6cm;
}
.card-footer {
}
.card-footer {
position: relative;
page-break-inside: avoid;
}
.summary {
}
.summary {
font-weight: bold;
}
.description {
}
.description {
min-height: 3.0cm;
font-size: 0.6cm;
line-height: 0.6cm;
}
.key {
}
.key {
position: absolute;
float: left;
width: auto;
@ -700,8 +716,8 @@ body {
font-weight: bold;
font-size: 1.0cm;
line-height: 1.6cm;
}
.type-icon {
}
.type-icon {
position: relative;
float: left;
background-color: GREENYELLOW;
@ -711,22 +727,22 @@ body {
background-size: 70%;
background-position: center;
z-index: 1;
}
}
.card[type="story"] .type-icon {
.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 {
}
.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 {
}
.card[type="epic"] .type-icon {
background-color: ROYALBLUE;
background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Flash.png);
}
}
.estimate {
.estimate {
position: relative;
float: left;
left: -0.65cm;
@ -739,13 +755,13 @@ body {
line-height: 1.15cm;
margin-top:1.5cm;
z-index: 999;
}
}
.due {
.due {
position: relative;
float: right;
}
.due-icon {
}
.due-icon {
position: relative;
float:right;
width: 2.5cm;
@ -758,8 +774,8 @@ body {
background-size: 65%;
background-position: center;
z-index: 1;
}
.due-date {
}
.due-date {
position: relative;
float: right;
right: -0.6cm;
@ -775,8 +791,8 @@ body {
font-weight: bold;
font-size: 0.7cm;
line-height: 0.7cm;
}
.attachment {
}
.attachment {
position: relative;
float: left;
margin-left: 0.6cm;
@ -789,8 +805,8 @@ body {
background-size: 70%;
background-position: center;
}
.assignee {
}
.assignee {
position: relative;
float: right;
width: 2.1cm;
@ -808,8 +824,8 @@ body {
-webkit-filter: contrast(150%) grayscale(100%);
filter: contrast(150%) grayscale(100%);
background-position: center;
}
.qr-code {
}
.qr-code {
position: relative;
float: left;
width: 2.1cm;
@ -819,8 +835,8 @@ body {
-webkit-background-size: cover;
background-size: cover;
background-position: center;
}
.epic {
}
.epic {
width: auto;
height: auto;
position: relative;
@ -834,22 +850,22 @@ body {
font-size: 0.7cm;
line-height: 0.7cm;
max-width: calc( 100% - 10.2cm);
}
.epic-key {
}
.epic-name {
}
.epic-key {
}
.epic-name {
font-weight: bold;
}
*/
}).replace(/{RESOURCE_ORIGIN}/g, resourceOrigin));
}
*/
}).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');
@ -861,36 +877,36 @@ function appendScript(url, callback){
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];
}
}
}
function addConsoleFunctions() {
function addConsoleFunctions() {
console.ERROR = 0;
console.WARN = 1;
@ -929,9 +945,9 @@ function addConsoleFunctions() {
console.log("TRACE: " + msg);
}
}
}
}
function addStringFunctions() {
function addStringFunctions() {
//trim string - remove leading and trailing whitespaces
if (!String.prototype.trim) {
@ -968,9 +984,9 @@ function addStringFunctions() {
return s;
}
}
}
}
function addDateFunctions() {
function addDateFunctions() {
Date.prototype.format = function(format) {
var returnStr = '';
@ -985,9 +1001,9 @@ function addDateFunctions() {
}
}
return returnStr;
};
};
Date.replaceChars = {
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'],
@ -1048,15 +1064,23 @@ Date.replaceChars = {
r: function() { return this.toString(); },
U: function() { return this.getTimep() / 1000; }
};
}
}
function multilineString(commentFunction) {
function multilineString(commentFunction) {
return commentFunction.toString()
.replace(/^[^\/]+\/\*!?/, '')
.replace(/\*\/[^\/]+$/, '');
}
}
function resizeIframe(iframe) {
function resizeIframe(iframe) {
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
}
} catch (err) {
console.logError(err.message);
ga('send', 'exception', {
'exDescription': err.message,
'exFatal': true
});
}