Comparing version 3.8.2 to 3.9.0
@@ -18,2 +18,7 @@ "use strict"; | ||
fontSize: 20, | ||
cornerText: undefined, | ||
cornerTextAlign: "right", | ||
cornerTextMargin: 1, | ||
cornerTextFontSize: 8, | ||
cornerTextFontOptions: "", | ||
background: "#ffffff", | ||
@@ -20,0 +25,0 @@ lineColor: "#000000", |
@@ -83,2 +83,6 @@ "use strict"; | ||
var _drawCornerText = this.drawCornerText(parent, options, encoding, yFrom), | ||
newY = _drawCornerText.newY, | ||
height = _drawCornerText.height; | ||
var barWidth = 0; | ||
@@ -92,3 +96,3 @@ var x = 0; | ||
} else if (barWidth > 0) { | ||
this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent); | ||
this.drawRect(x - options.width * barWidth, newY, options.width * barWidth, options.height - height, parent); | ||
barWidth = 0; | ||
@@ -100,9 +104,61 @@ } | ||
if (barWidth > 0) { | ||
this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent); | ||
this.drawRect(x - options.width * (barWidth - 1), newY, options.width * barWidth, options.height - height, parent); | ||
} | ||
} | ||
}, { | ||
key: "drawCornerText", | ||
value: function drawCornerText(parent, options, encoding, yFrom) { | ||
if (options.cornerText) { | ||
var textElem = this.document.createElementNS(svgns, "text"); | ||
var x, | ||
y = yFrom; | ||
var styleStr = ""; | ||
styleStr = "font-size: " + options.cornerTextFontSize + "px" + "; "; | ||
styleStr += "font-family: " + options.font + "; "; | ||
if (options.cornerTextFontOptions.indexOf("bold") >= 0) { | ||
styleStr += "font-weight: bold; "; | ||
} | ||
if (options.cornerTextFontOptions.indexOf("italic") >= 0) { | ||
styleStr += "font-style: italic; "; | ||
} | ||
if (options.cornerTextFontOptions.indexOf("normal") >= 0) { | ||
styleStr += "font-style: normal; "; | ||
} | ||
if (options.cornerTextFontOptions.indexOf("oblique") >= 0) { | ||
styleStr += "font-style: oblique; "; | ||
} | ||
textElem.setAttribute("style", styleStr); | ||
// Draw the text in the correct X depending on the conerTextAlign option | ||
if (options.cornerTextAlign == "left" || encoding.barcodePadding > 0) { | ||
x = 0; | ||
textElem.setAttribute("text-anchor", "start"); | ||
} else if (options.cornerTextAlign == "right") { | ||
x = encoding.width - 1; | ||
textElem.setAttribute("text-anchor", "end"); | ||
} else { | ||
// In all other cases, center the text | ||
x = encoding.width / 2; | ||
textElem.setAttribute("text-anchor", "middle"); | ||
} | ||
textElem.setAttribute("x", x); | ||
textElem.setAttribute("y", y); | ||
textElem.appendChild(this.document.createTextNode(options.cornerText)); | ||
parent.appendChild(textElem); | ||
var newY = options.cornerTextMargin; | ||
return { | ||
newY: newY, | ||
height: options.cornerTextMargin + options.cornerTextFontSize | ||
}; | ||
} | ||
return { newY: yFrom, height: 0 }; | ||
} | ||
}, { | ||
key: "drawSVGText", | ||
value: function drawSVGText(parent, options, encoding) { | ||
var textElem = this.document.createElementNS(svgns, 'text'); | ||
var textElem = this.document.createElementNS(svgns, "text"); | ||
@@ -113,15 +169,15 @@ // Draw the text if displayValue is setfontName: "ocr-a" | ||
var styleStr = ''; | ||
var styleStr = ""; | ||
styleStr = "font-size: " + options.fontSize + "px" + "; "; | ||
styleStr += "font-family: " + options.font + "; "; | ||
if (options.fontOptions.indexOf('bold') >= 0) { | ||
if (options.fontOptions.indexOf("bold") >= 0) { | ||
styleStr += "font-weight: bold; "; | ||
} | ||
if (options.fontOptions.indexOf('italic') >= 0) { | ||
if (options.fontOptions.indexOf("italic") >= 0) { | ||
styleStr += "font-style: italic; "; | ||
} | ||
if (options.fontOptions.indexOf('normal') >= 0) { | ||
if (options.fontOptions.indexOf("normal") >= 0) { | ||
styleStr += "font-style: normal; "; | ||
} | ||
if (options.fontOptions.indexOf('oblique') >= 0) { | ||
if (options.fontOptions.indexOf("oblique") >= 0) { | ||
styleStr += "font-style: oblique; "; | ||
@@ -134,3 +190,3 @@ } | ||
} else { | ||
y = options.height + options.textMargin + options.fontSize; | ||
y = options.height + options.textMargin; | ||
} | ||
@@ -145,8 +201,7 @@ | ||
textElem.setAttribute("text-anchor", "end"); | ||
} else { | ||
// In all other cases, center the text | ||
x = encoding.width / 2; | ||
textElem.setAttribute("text-anchor", "middle"); | ||
} | ||
// In all other cases, center the text | ||
else { | ||
x = encoding.width / 2; | ||
textElem.setAttribute("text-anchor", "middle"); | ||
} | ||
@@ -179,3 +234,3 @@ textElem.setAttribute("x", x); | ||
value: function createGroup(x, y, parent) { | ||
var group = this.document.createElementNS(svgns, 'g'); | ||
var group = this.document.createElementNS(svgns, "g"); | ||
group.setAttribute("transform", "translate(" + x + ", " + y + ")"); | ||
@@ -195,3 +250,3 @@ | ||
value: function drawRect(x, y, width, height, parent) { | ||
var rect = this.document.createElementNS(svgns, 'rect'); | ||
var rect = this.document.createElementNS(svgns, "rect"); | ||
@@ -198,0 +253,0 @@ rect.setAttribute("x", x); |
{ | ||
"name": "jsbarcode2", | ||
"version": "3.8.2", | ||
"description": "JsBarcode is a customizable barcode generator with support for multiple barcode formats.", | ||
"version": "3.9.0", | ||
"description": | ||
"JsBarcode is a customizable barcode generator with support for multiple barcode formats.", | ||
"main": "./bin/JsBarcode.js", | ||
@@ -14,4 +15,6 @@ "directories": { | ||
"test": "gulp babel && node_modules/mocha/bin/mocha test/node/ -R spec", | ||
"coveralls": "NODE_ENV=test YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha test/node/ --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js", | ||
"coverage": "./node_modules/.bin/mocha test/node/ -r blanket -R html-cov > test/coverage.html", | ||
"coveralls": | ||
"NODE_ENV=test YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha test/node/ --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js", | ||
"coverage": | ||
"./node_modules/.bin/mocha test/node/ -r blanket -R html-cov > test/coverage.html", | ||
"build": "gulp compile", | ||
@@ -73,12 +76,6 @@ "prepublish": "npm run build" | ||
"blanket": { | ||
"pattern": [ | ||
"JsBarcode.js", | ||
"barcodes" | ||
], | ||
"data-cover-never": [ | ||
"GenericBarcode", | ||
"node_modules" | ||
] | ||
"pattern": ["JsBarcode.js", "barcodes"], | ||
"data-cover-never": ["GenericBarcode", "node_modules"] | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
134477
2656
0