| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 |
1×
1×
1×
1×
1×
1×
1×
22×
22×
22×
1×
50×
50×
50×
50×
1×
1×
1×
1×
1×
140×
1×
23×
23×
1×
32×
10×
22×
32×
16×
32×
86×
86×
16×
16×
16×
11×
11×
11×
5×
5×
16×
32×
1×
156×
1×
156×
1×
156×
156×
156×
156×
156×
156×
156×
1×
2×
1×
4×
4×
1×
172×
172×
172×
3×
3×
78×
78×
13×
13×
13×
13×
7×
7×
7×
7×
11×
11×
4×
4×
3×
3×
8×
8×
3×
3×
2×
2×
6×
6×
2×
2×
12×
12×
172×
23×
23×
172×
172×
172×
172×
172×
172×
172×
172×
172×
172×
172×
172×
172×
149×
2×
147×
2×
145×
23×
172×
23×
23×
1×
10×
1×
10×
10×
10×
10×
10×
1×
1×
339×
339×
309×
30×
339×
1×
140×
140×
140×
140×
140×
140×
140×
119×
119×
119×
119×
1×
140×
1×
140×
1×
140×
140×
140×
140×
140×
1×
700×
1×
140×
140×
1×
141×
141×
141×
141×
140×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| /* istanbul ignore next */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/* istanbul ignore next */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) Eif (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "./enum/enum", "./rendering/renderer", "./rendering/canvas-renderer", "./one-dimension/code128B", "./one-dimension/code128C", "./primitives/displaytext", "./primitives/margin", "./one-dimension/code39", "./one-dimension/codabar", "./one-dimension/code128A", "./one-dimension/code128", "./one-dimension/ean8", "./one-dimension/ean13", "./one-dimension/upcE", "./one-dimension/upcA", "./one-dimension/code11", "./one-dimension/code93", "./one-dimension/code93Extension", "./one-dimension/code32", "./one-dimension/code39Extension", "./utility/barcode-util"], function (require, exports, ej2_base_1, ej2_base_2, enum_1, renderer_1, canvas_renderer_1, code128B_1, code128C_1, displaytext_1, margin_1, code39_1, codabar_1, code128A_1, code128_1, ean8_1, ean13_1, upcE_1, upcA_1, code11_1, code93_1, code93Extension_1, code32_1, code39Extension_1, barcode_util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BarcodeGenerator = (function (_super) {
__extends(BarcodeGenerator, _super);
function BarcodeGenerator(options, element) {
return _super.call(this, options, element) || this;
}
BarcodeGenerator.prototype.triggerEvent = function (eventName, message) {
var arg = {
message: message
};
this.trigger(enum_1.BarcodeEvent["" + eventName], arg);
};
BarcodeGenerator.prototype.onPropertyChanged = function (newProp, oldProp) {
if (this.mode === 'Canvas' && newProp.mode !== 'Canvas') {
this.refreshCanvasBarcode();
}
else {
this.barcodeRenderer = barcode_util_1.removeChildElements(newProp, this.barcodeCanvas, this.mode, this.element.id);
}
if (newProp.width) {
this.barcodeCanvas.setAttribute('width', String(newProp.width));
}
for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
var prop = _a[_i];
switch (prop) {
case 'width':
this.element.style.width = this.getElementSize(this.width);
this.barcodeCanvas.setAttribute('width', String(this.element.offsetWidth));
break;
case 'height':
this.element.style.height = this.getElementSize(this.height);
this.barcodeCanvas.setAttribute('height', String(this.element.offsetHeight));
break;
case 'backgroundColor':
this.barcodeCanvas.style.background = newProp.backgroundColor;
break;
case 'mode':
this.initialize();
}
}
this.renderElements();
};
BarcodeGenerator.prototype.initialize = function () {
if (!this.height) {
this.height = '100px';
}
if (!this.width) {
this.width = '100%';
}
this.element.style.display = 'block';
this.element.style.height = this.getElementSize(this.height);
this.element.style.width = this.getElementSize(this.width);
var height = this.mode === 'SVG' ? this.element.offsetHeight : this.element.offsetHeight * 1.5;
var width = this.mode === 'SVG' ? this.element.offsetWidth : this.element.offsetWidth * 1.5;
this.barcodeCanvas = this.barcodeRenderer.renderRootElement({
id: this.element.id + 'content',
height: height, width: width
}, this.backgroundColor, width, height);
this.element.appendChild(this.barcodeCanvas);
};
BarcodeGenerator.prototype.exportImage = function (filename, exportType) {
barcode_util_1.exportAsImage(exportType, filename, this.element, false, this);
};
BarcodeGenerator.prototype.exportAsBase64Image = function (exportType) {
var returnValue = barcode_util_1.exportAsImage(exportType, '', this.element, true, this);
return returnValue;
};
BarcodeGenerator.prototype.renderElements = function () {
var barCode;
this.type = this.type || 'Code128';
switch (this.type) {
case 'Code39Extension':
barCode = new code39Extension_1.Code39Extension;
break;
case 'Code39':
barCode = new code39_1.Code39();
break;
case 'Codabar':
barCode = new codabar_1.CodaBar();
break;
case 'Code128A':
barCode = new code128A_1.Code128A();
break;
case 'Code128B':
barCode = new code128B_1.Code128B();
break;
case 'Code128C':
barCode = new code128C_1.Code128C();
break;
case 'Code128':
barCode = new code128_1.Code128();
break;
case 'Ean8':
barCode = new ean8_1.Ean8();
break;
case 'Ean13':
barCode = new ean13_1.Ean13();
break;
case 'UpcA':
barCode = new upcA_1.UpcA();
break;
case 'UpcE':
barCode = new upcE_1.UpcE();
break;
case 'Code11':
barCode = new code11_1.Code11();
break;
case 'Code93':
barCode = new code93_1.Code93();
break;
case 'Code93Extension':
barCode = new code93Extension_1.Code93Extension();
break;
case 'Code32':
barCode = new code32_1.Code32();
break;
}
if (this.mode === 'Canvas') {
this.barcodeCanvas.getContext('2d').setTransform(1, 0, 0, 1, 0, 0);
this.barcodeCanvas.getContext('2d').scale(1.5, 1.5);
}
barCode.width = this.barcodeCanvas.getAttribute('width');
Iif ((this.type === 'Ean8' || this.type === 'Ean13' || this.type === 'UpcA') && this.displayText.text.length > 0) {
this.triggerEvent(enum_1.BarcodeEvent.invalid, 'Invalid Display Text');
}
this.value = this.value || '';
barCode.value = this.value;
barCode.margin = this.margin;
barCode.type = this.type;
barCode.height = this.barcodeCanvas.getAttribute('height');
barCode.foreColor = this.foreColor;
barCode.isSvgMode = this.mode === 'SVG' ? true : false;
barCode.displayText = this.displayText;
barCode.enableCheckSum = this.enableCheckSum;
var validateMessage = barCode.validateInput(this.value);
if (validateMessage === undefined) {
if (this.type === 'Code39Extension') {
barCode.drawCode39(this.barcodeCanvas);
}
else if (this.type === 'Code93Extension') {
barCode.drawCode93(this.barcodeCanvas);
}
else {
barCode.draw(this.barcodeCanvas);
}
}
else {
this.triggerEvent(enum_1.BarcodeEvent.invalid, validateMessage);
}
if (this.mode === 'Canvas') {
this.barcodeCanvas.style.transform = 'scale(' + (2 / 3) + ')';
this.barcodeCanvas.style.transformOrigin = '0 0';
}
};
BarcodeGenerator.prototype.refreshCanvasBarcode = function () {
this.clearCanvas(this);
};
BarcodeGenerator.prototype.clearCanvas = function (view) {
var width = view.element.offsetWidth;
var height = view.element.offsetHeight;
Eif (view.mode !== 'SVG') {
var ctx = canvas_renderer_1.BarcodeCanvasRenderer.getContext(this.barcodeCanvas);
ctx.clearRect(0, 0, width, height);
}
};
BarcodeGenerator.prototype.getPersistData = function () {
var keyEntity = ['loaded'];
return this.addOnPersist(keyEntity);
};
BarcodeGenerator.prototype.getElementSize = function (real, rulerSize) {
var value;
if (real.toString().indexOf('px') > 0 || real.toString().indexOf('%') > 0) {
value = real.toString();
}
else {
value = real.toString() + 'px';
}
return value;
};
BarcodeGenerator.prototype.preRender = function () {
this.element.classList.add('e-barcode');
this.barcodeRenderer = new renderer_1.BarcodeRenderer(this.element.id, this.mode === 'SVG');
this.initialize();
this.initializePrivateVariables();
this.setCulture();
var measureElement = document.getElementsByClassName('barcodeMeasureElement');
if (measureElement.length > 0) {
for (var i = measureElement.length - 1; i >= 0; i--) {
measureElement[parseInt(i.toString(), 10)].parentNode.removeChild(measureElement[parseInt(i.toString(), 10)]);
}
var element = 'barcodeMeasureElement';
window["" + element] = null;
}
};
BarcodeGenerator.prototype.initializePrivateVariables = function () {
this.defaultLocale = {};
};
BarcodeGenerator.prototype.setCulture = function () {
this.localeObj = new ej2_base_1.L10n(this.getModuleName(), this.defaultLocale, this.locale);
};
BarcodeGenerator.prototype.render = function () {
this.notify('initial-load', {});
this.trigger('load');
this.notify('initial-end', {});
this.renderElements();
this.renderComplete();
};
BarcodeGenerator.prototype.getModuleName = function () {
return 'barcode';
};
BarcodeGenerator.prototype.requiredModules = function () {
var modules = [];
return modules;
};
BarcodeGenerator.prototype.destroy = function () {
this.notify('destroy', {});
_super.prototype.destroy.call(this);
var content = document.getElementById(this.element.id + 'content');
if (content) {
this.element.removeChild(content);
}
};
__decorate([
ej2_base_1.Property('100%')
], BarcodeGenerator.prototype, "width", void 0);
__decorate([
ej2_base_1.Property('100px')
], BarcodeGenerator.prototype, "height", void 0);
__decorate([
ej2_base_1.Property('SVG')
], BarcodeGenerator.prototype, "mode", void 0);
__decorate([
ej2_base_1.Property('Code128')
], BarcodeGenerator.prototype, "type", void 0);
__decorate([
ej2_base_1.Property(undefined)
], BarcodeGenerator.prototype, "value", void 0);
__decorate([
ej2_base_1.Property(true)
], BarcodeGenerator.prototype, "enableCheckSum", void 0);
__decorate([
ej2_base_2.Complex({}, displaytext_1.DisplayText)
], BarcodeGenerator.prototype, "displayText", void 0);
__decorate([
ej2_base_2.Complex({}, margin_1.Margin)
], BarcodeGenerator.prototype, "margin", void 0);
__decorate([
ej2_base_1.Property('white')
], BarcodeGenerator.prototype, "backgroundColor", void 0);
__decorate([
ej2_base_1.Property('black')
], BarcodeGenerator.prototype, "foreColor", void 0);
__decorate([
ej2_base_2.Event()
], BarcodeGenerator.prototype, "invalid", void 0);
return BarcodeGenerator;
}(ej2_base_1.Component));
exports.BarcodeGenerator = BarcodeGenerator;
});
|