Skip to content

Commit

Permalink
📦 Release v3.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed Oct 8, 2016
1 parent 5541aed commit 8671ff8
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 77 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ Download or get the CDN link to the script:

| Name | Supported barcodes | Size (gzip) | CDN / Download |
|------|--------------------|:-----------:|---------------:|
| *All* | *All the barcodes!* | *8.2 kB* | *[JsBarcode.all.min.js][1]* |
| *All* | *All the barcodes!* | *8.3 kB* | *[JsBarcode.all.min.js][1]* |
| CODE128 | CODE128 (auto and force mode) | 5.4 kB | [JsBarcode.code128.min.js][2] |
| CODE39 | CODE39 | 4.6 kB | [JsBarcode.code39.min.js][3] |
| EAN / UPC | EAN-13, EAN-8, EAN-5, EAN-2, UPC (A) | 5.3 kB | [JsBarcode.ean-upc.min.js][4] |
| EAN / UPC | EAN-13, EAN-8, EAN-5, EAN-2, UPC (A) | 5.4 kB | [JsBarcode.ean-upc.min.js][4] |
| ITF-14 | ITF-14 | 4.4 kB | [JsBarcode.itf-14.min.js][5] |
| ITF | ITF | 4.4 kB | [JsBarcode.itf.min.js][6] |
| MSI | MSI, MSI10, MSI11, MSI1010, MSI1110 | 4.6 kB | [JsBarcode.msi.min.js][7] |
Expand Down
20 changes: 11 additions & 9 deletions bin/barcodes/EAN_UPC/EAN13.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ var EAN13 = function (_Barcode) {
data += checksum(data);
}

// Define the EAN-13 structure
// Make sure the font is not bigger than the space between the guard bars
var _this = _possibleConstructorReturn(this, _Barcode.call(this, data, options));

_this.structure = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];

// Make sure the font is not bigger than the space between the guard bars
if (!options.flat && options.fontSize > options.width * 10) {
if (options.fontSize > options.width * 10) {
_this.fontSize = options.width * 10;
} else {
_this.fontSize = options.fontSize;
}

// Make the guard bars go down half the way of the text
Expand All @@ -64,14 +59,21 @@ var EAN13 = function (_Barcode) {
}
};

// Define the EAN-13 structure


EAN13.prototype.getStructure = function getStructure() {
return ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
};

// The "standard" way of printing EAN13 barcodes with guard bars


EAN13.prototype.guardedEncoding = function guardedEncoding() {
var encoder = new _ean_encoder2.default();
var result = [];

var structure = this.structure[this.data[0]];
var structure = this.getStructure()[this.data[0]];

// Get the string to be encoded on the left side of the EAN code
var leftSide = this.data.substr(1, 6);
Expand Down Expand Up @@ -136,7 +138,7 @@ var EAN13 = function (_Barcode) {
var encoder = new _ean_encoder2.default();
var result = "";

var structure = this.structure[this.data[0]];
var structure = this.getStructure()[this.data[0]];

result += "101";
result += encoder.encode(this.data.substr(1, 6), structure);
Expand Down
24 changes: 24 additions & 0 deletions bin/barcodes/EAN_UPC/UPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ var UPC = function (_Barcode) {
};

UPC.prototype.encode = function encode() {
if (this.options.flat) {
return this.flatEncoding();
} else {
return this.guardedEncoding();
}
};

UPC.prototype.flatEncoding = function flatEncoding() {
var encoder = new _ean_encoder2.default();
var result = "";

result += "101";
result += encoder.encode(this.data.substr(0, 6), "LLLLLL");
result += "01010";
result += encoder.encode(this.data.substr(6, 6), "RRRRRR");
result += "101";

return {
data: result,
text: this.text
};
};

UPC.prototype.guardedEncoding = function guardedEncoding() {
var encoder = new _ean_encoder2.default();
var result = [];

Expand Down
45 changes: 24 additions & 21 deletions bin/barcodes/codabar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,31 @@ var codabar = function (_Barcode) {
var _this = _possibleConstructorReturn(this, _Barcode.call(this, data.toUpperCase(), options));

_this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
return _this;
}

codabar.prototype.valid = function valid() {
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
};

codabar.prototype.encode = function encode() {
var result = [];
var encodings = this.getEncodings();
for (var i = 0; i < this.data.length; i++) {
result.push(encodings[this.data.charAt(i)]);
// for all characters except the last, append a narrow-space ("0")
if (i !== this.data.length - 1) {
result.push("0");
}
}
return {
text: this.text,
data: result.join('')
};
};

_this.encodings = {
codabar.prototype.getEncodings = function getEncodings() {
return {
"0": "101010011",
"1": "101011001",
"2": "101001011",
Expand All @@ -54,26 +77,6 @@ var codabar = function (_Barcode) {
"C": "1001001011",
"D": "1010011001"
};
return _this;
}

codabar.prototype.valid = function valid() {
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
};

codabar.prototype.encode = function encode() {
var result = [];
for (var i = 0; i < this.data.length; i++) {
result.push(this.encodings[this.data.charAt(i)]);
// for all characters except the last, append a narrow-space ("0")
if (i !== this.data.length - 1) {
result.push("0");
}
}
return {
text: this.text,
data: result.join('')
};
};

return codabar;
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "JsBarcode",
"main": "dist/JsBarcode.all.min.js",
"version": "3.5.2",
"version": "3.5.3",
"homepage": "https://github.com/lindell/JsBarcode",
"authors": [
"Johan Lindell <johan@lindell.me>"
Expand Down
89 changes: 59 additions & 30 deletions dist/JsBarcode.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,16 +1404,11 @@ var EAN13 = function (_Barcode) {
data += checksum(data);
}

// Define the EAN-13 structure
// Make sure the font is not bigger than the space between the guard bars
var _this = _possibleConstructorReturn(this, _Barcode.call(this, data, options));

_this.structure = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];

// Make sure the font is not bigger than the space between the guard bars
if (!options.flat && options.fontSize > options.width * 10) {
if (options.fontSize > options.width * 10) {
_this.fontSize = options.width * 10;
} else {
_this.fontSize = options.fontSize;
}

// Make the guard bars go down half the way of the text
Expand All @@ -1436,14 +1431,21 @@ var EAN13 = function (_Barcode) {
}
};

// Define the EAN-13 structure


EAN13.prototype.getStructure = function getStructure() {
return ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
};

// The "standard" way of printing EAN13 barcodes with guard bars


EAN13.prototype.guardedEncoding = function guardedEncoding() {
var encoder = new _ean_encoder2.default();
var result = [];

var structure = this.structure[this.data[0]];
var structure = this.getStructure()[this.data[0]];

// Get the string to be encoded on the left side of the EAN code
var leftSide = this.data.substr(1, 6);
Expand Down Expand Up @@ -1508,7 +1510,7 @@ var EAN13 = function (_Barcode) {
var encoder = new _ean_encoder2.default();
var result = "";

var structure = this.structure[this.data[0]];
var structure = this.getStructure()[this.data[0]];

result += "101";
result += encoder.encode(this.data.substr(1, 6), structure);
Expand Down Expand Up @@ -1852,6 +1854,30 @@ var UPC = function (_Barcode) {
};

UPC.prototype.encode = function encode() {
if (this.options.flat) {
return this.flatEncoding();
} else {
return this.guardedEncoding();
}
};

UPC.prototype.flatEncoding = function flatEncoding() {
var encoder = new _ean_encoder2.default();
var result = "";

result += "101";
result += encoder.encode(this.data.substr(0, 6), "LLLLLL");
result += "01010";
result += encoder.encode(this.data.substr(6, 6), "RRRRRR");
result += "101";

return {
data: result,
text: this.text
};
};

UPC.prototype.guardedEncoding = function guardedEncoding() {
var encoder = new _ean_encoder2.default();
var result = [];

Expand Down Expand Up @@ -2465,8 +2491,31 @@ var codabar = function (_Barcode) {
var _this = _possibleConstructorReturn(this, _Barcode.call(this, data.toUpperCase(), options));

_this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
return _this;
}

_this.encodings = {
codabar.prototype.valid = function valid() {
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
};

codabar.prototype.encode = function encode() {
var result = [];
var encodings = this.getEncodings();
for (var i = 0; i < this.data.length; i++) {
result.push(encodings[this.data.charAt(i)]);
// for all characters except the last, append a narrow-space ("0")
if (i !== this.data.length - 1) {
result.push("0");
}
}
return {
text: this.text,
data: result.join('')
};
};

codabar.prototype.getEncodings = function getEncodings() {
return {
"0": "101010011",
"1": "101011001",
"2": "101001011",
Expand All @@ -2488,26 +2537,6 @@ var codabar = function (_Barcode) {
"C": "1001001011",
"D": "1010011001"
};
return _this;
}

codabar.prototype.valid = function valid() {
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
};

codabar.prototype.encode = function encode() {
var result = [];
for (var i = 0; i < this.data.length; i++) {
result.push(this.encodings[this.data.charAt(i)]);
// for all characters except the last, append a narrow-space ("0")
if (i !== this.data.length - 1) {
result.push("0");
}
}
return {
text: this.text,
data: result.join('')
};
};

return codabar;
Expand Down
6 changes: 3 additions & 3 deletions dist/JsBarcode.all.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/barcodes/JsBarcode.codabar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.code128.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.code39.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/barcodes/JsBarcode.ean-upc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.itf-14.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.itf.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.msi.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/barcodes/JsBarcode.pharmacode.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsbarcode",
"version": "3.5.2",
"version": "3.5.3",
"description": "JsBarcode is a customizable barcode generator with support for multiple barcode formats.",
"main": "./bin/JsBarcode.js",
"directories": {
Expand Down

0 comments on commit 8671ff8

Please sign in to comment.