yh-hiprint 2.2.10 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HiprintDesigner.vue +5 -5
- package/column-field.js +4 -6
- package/designer.vue +4 -4
- package/font-size.js +3 -4
- package/index.js +3 -4
- package/libs/hiprint.bundle.js +1325 -1328
- package/libs/jquery.js +10620 -0
- package/libs/jsbarcode/JsBarcode.js +251 -0
- package/libs/jsbarcode/barcodes/Barcode.js +17 -0
- package/libs/jsbarcode/barcodes/CODE128/CODE128.js +167 -0
- package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +42 -0
- package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +42 -0
- package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +42 -0
- package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +41 -0
- package/libs/jsbarcode/barcodes/CODE128/auto.js +73 -0
- package/libs/jsbarcode/barcodes/CODE128/constants.js +54 -0
- package/libs/jsbarcode/barcodes/CODE128/index.js +29 -0
- package/libs/jsbarcode/barcodes/CODE39/index.js +105 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +92 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +119 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +58 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +65 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +81 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +165 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +185 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +30 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +27 -0
- package/libs/jsbarcode/barcodes/EAN_UPC/index.js +39 -0
- package/libs/jsbarcode/barcodes/GenericBarcode/index.js +55 -0
- package/libs/jsbarcode/barcodes/ITF/ITF.js +69 -0
- package/libs/jsbarcode/barcodes/ITF/ITF14.js +55 -0
- package/libs/jsbarcode/barcodes/ITF/constants.js +9 -0
- package/libs/jsbarcode/barcodes/ITF/index.js +19 -0
- package/libs/jsbarcode/barcodes/MSI/MSI.js +74 -0
- package/libs/jsbarcode/barcodes/MSI/MSI10.js +33 -0
- package/libs/jsbarcode/barcodes/MSI/MSI1010.js +35 -0
- package/libs/jsbarcode/barcodes/MSI/MSI11.js +33 -0
- package/libs/jsbarcode/barcodes/MSI/MSI1110.js +35 -0
- package/libs/jsbarcode/barcodes/MSI/checksums.js +29 -0
- package/libs/jsbarcode/barcodes/MSI/index.js +34 -0
- package/libs/jsbarcode/barcodes/codabar/index.js +92 -0
- package/libs/jsbarcode/barcodes/index.js +33 -0
- package/libs/jsbarcode/barcodes/index.tmp.js +33 -0
- package/libs/jsbarcode/barcodes/pharmacode/index.js +73 -0
- package/libs/jsbarcode/exceptions/ErrorHandler.js +54 -0
- package/libs/jsbarcode/exceptions/exceptions.js +67 -0
- package/libs/jsbarcode/help/fixOptions.js +17 -0
- package/libs/jsbarcode/help/getOptionsFromElement.js +41 -0
- package/libs/jsbarcode/help/getRenderProperties.js +108 -0
- package/libs/jsbarcode/help/linearizeEncodings.js +27 -0
- package/libs/jsbarcode/help/merge.js +11 -0
- package/libs/jsbarcode/help/optionsFromStrings.js +27 -0
- package/libs/jsbarcode/options/defaults.js +28 -0
- package/libs/jsbarcode/renderers/canvas.js +158 -0
- package/libs/jsbarcode/renderers/index.js +21 -0
- package/libs/jsbarcode/renderers/object.js +30 -0
- package/libs/jsbarcode/renderers/shared.js +101 -0
- package/libs/jsbarcode/renderers/svg.js +189 -0
- package/libs/plugins/jquery.hiwprint.js +13 -14
- package/libs/plugins/jquery.minicolors.js +1114 -0
- package/package.json +1 -4
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
|
+
|
|
9
|
+
var _merge = require("../help/merge.js");
|
|
10
|
+
|
|
11
|
+
var _merge2 = _interopRequireDefault(_merge);
|
|
12
|
+
|
|
13
|
+
var _shared = require("./shared.js");
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
|
|
19
|
+
var svgns = "http://www.w3.org/2000/svg";
|
|
20
|
+
|
|
21
|
+
var SVGRenderer = function () {
|
|
22
|
+
function SVGRenderer(svg, encodings, options) {
|
|
23
|
+
_classCallCheck(this, SVGRenderer);
|
|
24
|
+
|
|
25
|
+
this.svg = svg;
|
|
26
|
+
this.encodings = encodings;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.document = options.xmlDocument || document;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_createClass(SVGRenderer, [{
|
|
32
|
+
key: "render",
|
|
33
|
+
value: function render() {
|
|
34
|
+
var currentX = this.options.marginLeft;
|
|
35
|
+
|
|
36
|
+
this.prepareSVG();
|
|
37
|
+
for (var i = 0; i < this.encodings.length; i++) {
|
|
38
|
+
var encoding = this.encodings[i];
|
|
39
|
+
var encodingOptions = (0, _merge2.default)(this.options, encoding.options);
|
|
40
|
+
|
|
41
|
+
var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
|
|
42
|
+
|
|
43
|
+
this.setGroupOptions(group, encodingOptions);
|
|
44
|
+
|
|
45
|
+
this.drawSvgBarcode(group, encodingOptions, encoding);
|
|
46
|
+
this.drawSVGText(group, encodingOptions, encoding);
|
|
47
|
+
|
|
48
|
+
currentX += encoding.width;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "prepareSVG",
|
|
53
|
+
value: function prepareSVG() {
|
|
54
|
+
// Clear the SVG
|
|
55
|
+
while (this.svg.firstChild) {
|
|
56
|
+
this.svg.removeChild(this.svg.firstChild);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(0, _shared.calculateEncodingAttributes)(this.encodings, this.options);
|
|
60
|
+
var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings);
|
|
61
|
+
var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings);
|
|
62
|
+
|
|
63
|
+
var width = totalWidth + this.options.marginLeft + this.options.marginRight;
|
|
64
|
+
this.setSvgAttributes(width, maxHeight);
|
|
65
|
+
|
|
66
|
+
if (this.options.background) {
|
|
67
|
+
this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute("style", "fill:" + this.options.background + ";");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "drawSvgBarcode",
|
|
72
|
+
value: function drawSvgBarcode(parent, options, encoding) {
|
|
73
|
+
var binary = encoding.data;
|
|
74
|
+
|
|
75
|
+
// Creates the barcode out of the encoded binary
|
|
76
|
+
var yFrom;
|
|
77
|
+
if (options.textPosition == "top") {
|
|
78
|
+
yFrom = options.fontSize + options.textMargin;
|
|
79
|
+
} else {
|
|
80
|
+
yFrom = 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var barWidth = 0;
|
|
84
|
+
var x = 0;
|
|
85
|
+
for (var b = 0; b < binary.length; b++) {
|
|
86
|
+
x = b * options.width + encoding.barcodePadding;
|
|
87
|
+
|
|
88
|
+
if (binary[b] === "1") {
|
|
89
|
+
barWidth++;
|
|
90
|
+
} else if (barWidth > 0) {
|
|
91
|
+
this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent);
|
|
92
|
+
barWidth = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Last draw is needed since the barcode ends with 1
|
|
97
|
+
if (barWidth > 0) {
|
|
98
|
+
this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "drawSVGText",
|
|
103
|
+
value: function drawSVGText(parent, options, encoding) {
|
|
104
|
+
var textElem = this.document.createElementNS(svgns, 'text');
|
|
105
|
+
|
|
106
|
+
// Draw the text if displayValue is set
|
|
107
|
+
if (options.displayValue) {
|
|
108
|
+
var x, y;
|
|
109
|
+
|
|
110
|
+
textElem.setAttribute("style", "font:" + options.fontOptions + " " + options.fontSize + "px " + options.font);
|
|
111
|
+
|
|
112
|
+
if (options.textPosition == "top") {
|
|
113
|
+
y = options.fontSize - options.textMargin;
|
|
114
|
+
} else {
|
|
115
|
+
y = options.height + options.textMargin + options.fontSize;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Draw the text in the correct X depending on the textAlign option
|
|
119
|
+
if (options.textAlign == "left" || encoding.barcodePadding > 0) {
|
|
120
|
+
x = 0;
|
|
121
|
+
textElem.setAttribute("text-anchor", "start");
|
|
122
|
+
} else if (options.textAlign == "right") {
|
|
123
|
+
x = encoding.width - 1;
|
|
124
|
+
textElem.setAttribute("text-anchor", "end");
|
|
125
|
+
}
|
|
126
|
+
// In all other cases, center the text
|
|
127
|
+
else {
|
|
128
|
+
x = encoding.width / 2;
|
|
129
|
+
textElem.setAttribute("text-anchor", "middle");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
textElem.setAttribute("x", x);
|
|
133
|
+
textElem.setAttribute("y", y);
|
|
134
|
+
|
|
135
|
+
textElem.appendChild(this.document.createTextNode(encoding.text));
|
|
136
|
+
|
|
137
|
+
parent.appendChild(textElem);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "setSvgAttributes",
|
|
142
|
+
value: function setSvgAttributes(width, height) {
|
|
143
|
+
var svg = this.svg;
|
|
144
|
+
svg.setAttribute("width", width + "px");
|
|
145
|
+
svg.setAttribute("height", height + "px");
|
|
146
|
+
svg.setAttribute("x", "0px");
|
|
147
|
+
svg.setAttribute("y", "0px");
|
|
148
|
+
svg.setAttribute("viewBox", "0 0 " + width + " " + height);
|
|
149
|
+
|
|
150
|
+
svg.setAttribute("xmlns", svgns);
|
|
151
|
+
svg.setAttribute("version", "1.1");
|
|
152
|
+
|
|
153
|
+
svg.setAttribute("style", "transform: translate(0,0)");
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "createGroup",
|
|
157
|
+
value: function createGroup(x, y, parent) {
|
|
158
|
+
var group = this.document.createElementNS(svgns, 'g');
|
|
159
|
+
group.setAttribute("transform", "translate(" + x + ", " + y + ")");
|
|
160
|
+
|
|
161
|
+
parent.appendChild(group);
|
|
162
|
+
|
|
163
|
+
return group;
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "setGroupOptions",
|
|
167
|
+
value: function setGroupOptions(group, options) {
|
|
168
|
+
group.setAttribute("style", "fill:" + options.lineColor + ";");
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "drawRect",
|
|
172
|
+
value: function drawRect(x, y, width, height, parent) {
|
|
173
|
+
var rect = this.document.createElementNS(svgns, 'rect');
|
|
174
|
+
|
|
175
|
+
rect.setAttribute("x", x);
|
|
176
|
+
rect.setAttribute("y", y);
|
|
177
|
+
rect.setAttribute("width", width);
|
|
178
|
+
rect.setAttribute("height", height);
|
|
179
|
+
|
|
180
|
+
parent.appendChild(rect);
|
|
181
|
+
|
|
182
|
+
return rect;
|
|
183
|
+
}
|
|
184
|
+
}]);
|
|
185
|
+
|
|
186
|
+
return SVGRenderer;
|
|
187
|
+
}();
|
|
188
|
+
|
|
189
|
+
exports.default = SVGRenderer;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
$.fn.hiwprint = function (options) {
|
|
1
|
+
hiprintJQuery.fn.hiwprint = function (options) {
|
|
3
2
|
var usedFrame = document.getElementById("hiwprint_iframe");
|
|
4
3
|
if (usedFrame) usedFrame.parentNode.removeChild(usedFrame);
|
|
5
|
-
var opt =
|
|
4
|
+
var opt = hiprintJQuery.extend({}, hiprintJQuery.fn.hiwprint.defaults, options);
|
|
6
5
|
var $element = this;
|
|
7
|
-
var $iframe =
|
|
6
|
+
var $iframe = hiprintJQuery(
|
|
8
7
|
'<iframe id="hiwprint_iframe" style="visibility: hidden; height: 0; width: 0; position: absolute;"></iframe>'
|
|
9
8
|
);
|
|
10
9
|
var css = "";
|
|
@@ -12,12 +11,12 @@ $.fn.hiwprint = function (options) {
|
|
|
12
11
|
if (opt.styleHandler) {
|
|
13
12
|
css += opt.styleHandler();
|
|
14
13
|
}
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
css += '<link rel="stylesheet" type="text/css" media="print" href="' +
|
|
14
|
+
if (hiprintJQuery("link[media=print]").length > 0) {
|
|
15
|
+
hiprintJQuery("link[media=print]").each(function () {
|
|
16
|
+
if (hiprintJQuery(this).attr("href").indexOf("print-lock.css") >= 0) {
|
|
17
|
+
css += '<link rel="stylesheet" type="text/css" media="print" href="' + hiprintJQuery(this).attr("href") + '">';
|
|
19
18
|
// ↑若加上media="print",仅对浏览器打印时有效 所以查看iframe页面时样式无效
|
|
20
|
-
css += '<link rel="stylesheet" type="text/css" href="' +
|
|
19
|
+
css += '<link rel="stylesheet" type="text/css" href="' + hiprintJQuery(this).attr("href") + '">';
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
22
|
}
|
|
@@ -46,14 +45,14 @@ $.fn.hiwprint = function (options) {
|
|
|
46
45
|
$iframe.appendTo("body");
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
hiprintJQuery.fn.hiwprint.defaults = {
|
|
50
49
|
importCss: true,
|
|
51
50
|
printContainer: true,
|
|
52
51
|
callback: null,
|
|
53
52
|
styleHandler: null,
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
function performPrint(iframeElement, opt) {
|
|
55
|
+
function performPrint (iframeElement, opt) {
|
|
57
56
|
try {
|
|
58
57
|
iframeElement.focus();
|
|
59
58
|
if (isEdge() || isIE()) {
|
|
@@ -74,16 +73,16 @@ function performPrint(iframeElement, opt) {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
function isIE() {
|
|
76
|
+
function isIE () {
|
|
78
77
|
return navigator.userAgent.indexOf("MSIE") !== -1 || !!document.documentMode;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
// Edge 20+
|
|
82
|
-
function isEdge() {
|
|
81
|
+
function isEdge () {
|
|
83
82
|
return !isIE() && !!window.StyleMedia;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
function loadAllImages(printDocument, callback, time) {
|
|
85
|
+
function loadAllImages (printDocument, callback, time) {
|
|
87
86
|
if (time === undefined) {
|
|
88
87
|
time = 0;
|
|
89
88
|
}
|