Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Re-organize printing for proper order
Browse files Browse the repository at this point in the history
Related to tickets 14362 and 16081
  • Loading branch information
th-we committed Aug 6, 2014
1 parent 5f4eee3 commit 92496d8
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions Resources/public/js/controller/DocumentListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,35 @@ function DocumentListCtrl($scope) {
callback();
};

$scope.printBatch = function() {
$scope.print(getBatchDocuments());
var print = function(documents) {
printDivs = monodi.document.getPrintHtml(documents).querySelectorAll("html > body > *");
$('#printContainer').append(printDivs).show(0, function(){
window.print();
window.setTimeout(function(){
$('#printContainer').hide().children('.mei').remove();
}, 600);
});
};

$scope.print = function(ids) {
var documents = [],
i;

ids = ids instanceof Array ? ids : [ids];

for (i = 0; i < ids.length; i += 1) {
$scope.getDocument(ids[i], function(i){
var printDivs;
documents.push(this.content);
if (documents.length === ids.length) {
printDivs = monodi.document.getPrintHtml(documents).querySelectorAll("html > body > *");
$('#printContainer').append(printDivs).show(0, function(){
window.print();
window.setTimeout(function(){
$('#printContainer').hide().children('.mei').remove();
}, 600);
});
}
});
}
$scope.printBatch = function(ids, documents) {
ids = ids || getBatchDocuments();
documents = documents || [];

$scope.getDocument(ids.shift(), function() {
documents.push(this.content);
if (ids.length > 0) {
$scope.printBatch(ids, documents);
} else {
print(documents);
}
});
};

$scope.print = function(id) {
$scope.getDocument(id, function() {
print([this.content]);
});
};

$scope.saveDocumentLocal = function(id, callback) {
$scope.getDocument(id, function() {
Expand Down Expand Up @@ -330,4 +332,4 @@ function DocumentListCtrl($scope) {
return this.name;
}).get();
};
}
}

0 comments on commit 92496d8

Please sign in to comment.