-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
280 additions
and
59 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!-- ko with: viewModel --> | ||
<div style="display:none;" class="modal-box" data-bind="visible: isModalDisplayed"> | ||
<div class="modal-box-content"> | ||
<div class="modal-close icon icon-dismiss" data-bind="click: cancel"></div> | ||
<h3><span class="icon icon-file-pdf"></span> Export cards to PDF</h3> | ||
|
||
<!-- ko with: messageBar --> | ||
<div style="display: none;" class="message-bar" data-bind="html: message, slideIn: isVisible, css: { error: isError, warning: isWarning, info: isInfo, success: isSuccess}"></div> | ||
<!-- /ko --> | ||
|
||
<!-- ko with: config --> | ||
<div class="flex-container"> | ||
<h4 class="flex-1">Export Configuration</h4> | ||
<div class="modal-buttons flex-1"> | ||
<a class="btn" data-bind="click: setInInches, css: { secondary: configInMM, primary: configInInches, mainColor1: configInInches }">in Inches</a> | ||
<a class="btn" data-bind="click: setInMM, css: { secondary: configInInches, primary: configInMM, mainColor1: configInMM }">in Millimeters</a> | ||
</div> | ||
</div> | ||
<div class="flex-container flex-1"> | ||
<a class="btn" data-bind="click: setLandscape, css: { secondary: configIsPortrait, primary: configIsLandscape, mainColor1: configIsLandscape }">Landscape</a> | ||
<a class="btn" data-bind="click: setPortrait, css: { secondary: configIsLandscape, primary: configIsPortrait, mainColor1: configIsPortrait }">Portrait</a> | ||
</div> | ||
<div class="flex-container"> | ||
<div class="editable-field input-numeric pdf-card-value"> | ||
<label>Card Width</label> | ||
<input data-bind="value: displayedWidth"></input> | ||
</div> | ||
<div class="editable-field input-numeric pdf-card-value"> | ||
<label>Card Height</label> | ||
<input data-bind="value: displayedHeight"></input> | ||
</div> | ||
</div> | ||
<div class="flex-container"> | ||
<div class="editable-field input-numeric pdf-card-value"> | ||
<label>Margin between cards</label> | ||
<input data-bind="value: displayedMargin"></input> | ||
</div> | ||
</div> | ||
|
||
<!-- /ko --> | ||
|
||
<div data-bind="visible: exportInactive">It will take approximatively <span data-bind="text: estimatedTime"></span> to complete.</div> | ||
<h3 data-bind="visible: exportActive">Export in Progress ...</h3> | ||
<div data-bind="visible: exportActive, progressBar: { value : progressPercentage }"></div> | ||
|
||
<div class="modal-buttons"> | ||
<a class="btn primary mainColor1 iconized icon-file-pdf" data-bind="visible: exportInactive, click: launchPdfGeneration">Generate PDF</a> | ||
<a class="btn secondary iconized icon-dismiss" data-bind="visible: exportInactive, click: cancel">Close</a> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- /ko --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define([], function(ko) { | ||
|
||
function modalPdfExport(params) { | ||
var self = this; | ||
|
||
self.viewModel = params.pdfGenerator; | ||
} | ||
|
||
return modalPdfExport; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
define(['knockout'], function(ko) { | ||
|
||
/************************************/ | ||
/* Configuration for the PDF Export */ | ||
/************************************/ | ||
function pdfConfig() { | ||
var self = this; | ||
|
||
/*************************/ | ||
/* Variables declaration */ | ||
/*************************/ | ||
self.displayedUnit = ko.observable('i'); | ||
self.orientation = ko.observable('l'); | ||
self.cardWidthInPoints = ko.observable(200); | ||
self.cardHeightInPoints = ko.observable(300); | ||
self.marginInPoints = ko.observable(0); | ||
self.scale = ko.observable(1.0); | ||
|
||
/********************************/ | ||
/* End of Variables declaration */ | ||
/********************************/ | ||
// Displayed Unit | ||
self.configInMM = ko.computed(function() { | ||
return self.displayedUnit() == 'm'; | ||
}) | ||
self.configInInches = ko.computed(function() { | ||
return self.displayedUnit() == 'i'; | ||
}) | ||
|
||
// Orientation | ||
self.configIsLandscape = ko.computed(function() { | ||
return self.orientation() == 'l'; | ||
}) | ||
self.configIsPortrait = ko.computed(function() { | ||
return self.orientation() == 'p'; | ||
}) | ||
|
||
// Width & Height | ||
self.setCardDimensions = function(width, height) { | ||
self.cardWidthInPoints(width); | ||
self.cardHeightInPoints(height); | ||
} | ||
self.convertFromDisplayedUnitToPoints = function(unitValue) { | ||
if (self.configInInches()) { | ||
return Math.round(unitValue * 72); | ||
} else if (self.configInMM()) { | ||
return Math.round(unitValue / 0.35277); | ||
} | ||
return unitValue; | ||
} | ||
self.convertFromPointsToDisplayedUnit = function(pointsValue) { | ||
if (self.configInInches()) { | ||
return (pointsValue / 72).toFixed(2); | ||
} else if (self.configInMM()) { | ||
return Math.round(pointsValue * 0.35277); | ||
} | ||
return pointsValue; | ||
} | ||
self.displayedWidth = ko.computed({ | ||
read: function () { | ||
return self.convertFromPointsToDisplayedUnit(self.cardWidthInPoints() * self.scale()); | ||
}, | ||
write: function (value) { | ||
var newWidth = self.convertFromDisplayedUnitToPoints(value); | ||
self.scale(newWidth / self.cardWidthInPoints()); | ||
} | ||
}); | ||
self.displayedHeight = ko.computed({ | ||
read: function () { | ||
return self.convertFromPointsToDisplayedUnit(self.cardHeightInPoints() * self.scale()); | ||
}, | ||
write: function (value) { | ||
var newHeight = self.convertFromDisplayedUnitToPoints(value); | ||
self.scale(newHeight / self.cardHeightInPoints()); | ||
} | ||
}); | ||
self.displayedMargin = ko.computed({ | ||
read: function () { | ||
return self.convertFromPointsToDisplayedUnit(self.marginInPoints()); | ||
}, | ||
write: function (value) { | ||
var newMargin = self.convertFromDisplayedUnitToPoints(value); | ||
self.marginInPoints(newMargin); | ||
} | ||
}); | ||
|
||
/*************************/ | ||
/* Functions declaration */ | ||
/*************************/ | ||
self.setInInches = function() { | ||
self.displayedUnit('i'); | ||
} | ||
self.setInMM = function() { | ||
self.displayedUnit('m'); | ||
} | ||
self.setLandscape = function() { | ||
self.orientation('l'); | ||
} | ||
self.setPortrait = function() { | ||
self.orientation('p'); | ||
} | ||
|
||
/*******************************/ | ||
/*End of Functions declaration */ | ||
/*******************************/ | ||
} | ||
return { | ||
getPdfConfig: function(cardWidth, cardHeight) { | ||
return new pdfConfig(cardWidth, cardHeight); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// main: ./styles.less | ||
|
||
/*******************/ | ||
/* Flex management */ | ||
/*******************/ | ||
|
||
.flex-container { | ||
display: flex; | ||
} | ||
|
||
.flex-1 { | ||
flex: 1; | ||
} | ||
|
||
.flex-2 { | ||
flex: 2; | ||
} | ||
|
||
.flex-3 { | ||
flex: 3; | ||
} | ||
|
||
.flex-4 { | ||
flex: 4; | ||
} | ||
|
||
.flex-5 { | ||
flex: 5; | ||
} | ||
|
||
.flex-6 { | ||
flex: 6; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.