Skip to content

Commit

Permalink
0.0.7
Browse files Browse the repository at this point in the history
Print to many pages if items not fit in one page. Add minified version.
  • Loading branch information
shoom3301 committed Mar 31, 2016
1 parent 5a456f8 commit 0e75815
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "barcodeEditor",
"description": "Editor for print barcode",
"version": "0.0.6",
"version": "0.0.7",
"main": [
"dist/barcode_editor.js",
"dist/css/style.scss"
Expand Down
23 changes: 22 additions & 1 deletion dist/barcode_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@
popItem: function(){
this.items[this.items.length-1].remove();
this.items.pop();
},
/**
* Count of items in one page
* @returns {int}
*/
countInPage: function(){
var inRow = Math.floor(this.get('pageWidth')/this.get('itemWidth'));
var rowsCount = Math.floor(this.get('pageHeight')/this.get('itemHeight'));
return inRow*rowsCount;
}
});

Expand Down Expand Up @@ -343,7 +352,19 @@
* Print page
*/
print: function(){
this.$el.print({});
var model = this.model;
var inPage = model.countInPage(), total = model.items.length, currentHeight = model.get('pageHeight');
var deferred = $.Deferred();

model.set('pageHeight', Math.ceil(total/inPage)*currentHeight);

deferred.then(function(){
model.set('pageHeight', currentHeight);
});

this.$el.print({
deferred: deferred
});
},
/**
* Set parameter to input
Expand Down
32 changes: 32 additions & 0 deletions dist/barcode_editor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"jquery-ui/widget": "bower_components/jquery-ui/ui/widget",
"jquery-ui/resizable": "bower_components/jquery-ui/ui/resizable",
"jQuery.print": "bower_components/jQuery.print/jQuery.print",
"barcodeEditor": "dist/barcode_editor"
"barcodeEditor": "dist/barcode_editor.min"
},
shim:{
"jquery-ui/resizable": ["jquery-ui/core", "jquery-ui/mouse", "jquery-ui/widget"],
Expand All @@ -132,18 +132,18 @@
window.editor1 = new BarcodeEditor({
selector: '#barcodeEditor1',
pageWidth: 210,
pageHeight: 230,
pageHeight: 297,
topBorder: 5,
rightBorder: 5,
bottomBorder: 5,
leftBorder: 5,
fontSize: 12,
imageWidth: 100,
itemWidth: 150,
itemHeight: 50,
imageWidth: 42,
itemWidth: 50,
itemHeight: 28,
text: 'Съеш еще этих мягких булок',
barcodeImage: 'dist/barcode.png',
itemsCount: 3
itemsCount: 40
});

window.editor2 = new BarcodeEditor({
Expand Down

0 comments on commit 0e75815

Please sign in to comment.