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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 69× 1× 69× 69× 69× 69× 69× 1× 69× 1× 1× 345× 1× 69× 1× 144× 144× 2× 142× 144× 1× 70× 70× 70× 70× 70× 70× 70× 1× 7× 7× 1× 69× 69× 69× 69× 69× 1× 3× 3× 3× 1× 2× 3× 2× 2× 3× 2× 2× 3× 9× 9× 1× 1× 2× 2× 2× 2× 2× 2× 2× 2× 3× 1× 72× 72× 7341× 7341× 4746× 72× 1× 1× 1× 2× 2× 1× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 5× 67× 2× 65× 72× 4× 4× 1× 69× 69× 69× 69× 69× 1× 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; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (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", "../barcode/enum/enum", "../barcode/primitives/displaytext", "../barcode/primitives/margin", "../barcode/rendering/renderer", "../barcode/utility/barcode-util", "./datamatrix-util"], function (require, exports, ej2_base_1, ej2_base_2, enum_1, displaytext_1, margin_1, renderer_1, barcode_util_1, datamatrix_util_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DataMatrixGenerator = (function (_super) { __extends(DataMatrixGenerator, _super); function DataMatrixGenerator(options, element) { return _super.call(this, options, element) || this; } DataMatrixGenerator.prototype.destroy = function () { this.notify('destroy', {}); _super.prototype.destroy.call(this); var content = document.getElementById(this.element.id + 'content'); Eif (content) { this.element.removeChild(content); } }; DataMatrixGenerator.prototype.initializePrivateVariables = function () { this.defaultLocale = {}; }; DataMatrixGenerator.prototype.getPersistData = function () { var keyEntity = ['loaded']; return this.addOnPersist(keyEntity); }; DataMatrixGenerator.prototype.getModuleName = function () { return 'DataMatrixGenerator'; }; DataMatrixGenerator.prototype.setCulture = function () { this.localeObj = new ej2_base_1.L10n(this.getModuleName(), this.defaultLocale, this.locale); }; DataMatrixGenerator.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; }; DataMatrixGenerator.prototype.initialize = function () { this.element.style.display = 'block'; this.element.style.width = this.getElementSize(this.width); this.element.style.height = this.getElementSize(this.height); 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); }; DataMatrixGenerator.prototype.triggerEvent = function (eventName, message) { var arg = { message: message }; this.trigger(enum_1.BarcodeEvent["" + eventName], arg); }; DataMatrixGenerator.prototype.preRender = function () { this.element.classList.add('e-datamatrix'); this.barcodeRenderer = new renderer_1.BarcodeRenderer(this.element.id, this.mode === 'SVG'); this.initialize(); this.initializePrivateVariables(); this.setCulture(); }; DataMatrixGenerator.prototype.onPropertyChanged = function (newProp, oldProp) { var width; var height; if (this.mode === 'Canvas' && newProp.mode !== 'Canvas') { barcode_util_1.refreshCanvasBarcode(this, this.barcodeCanvas); } else { this.barcodeRenderer = barcode_util_1.removeChildElements(newProp, this.barcodeCanvas, this.mode, this.element.id); } if (newProp.width) { width = (this.mode === 'Canvas' && newProp.mode !== 'Canvas') ? ((newProp.width * 1.5)) : newProp.width; this.barcodeCanvas.setAttribute('width', String(width)); } if (newProp.height) { height = (this.mode === 'Canvas' && newProp.mode !== 'Canvas') ? ((newProp.height * 1.5)) : newProp.height; this.barcodeCanvas.setAttribute('height', String(height)); } for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) { var prop = _a[_i]; switch (prop) { case 'mode': this.initialize(); break; case 'height': this.element.style.height = this.getElementSize(height); this.barcodeCanvas.setAttribute('height', String(this.element.offsetHeight)); break; case 'width': this.element.style.width = this.getElementSize(width); this.barcodeCanvas.setAttribute('width', String(this.element.offsetWidth)); break; case 'backgroundColor': this.barcodeCanvas.setAttribute('style', 'background:' + newProp.backgroundColor); break; } } this.renderElements(); }; DataMatrixGenerator.prototype.checkdata = function (value) { var validData = false; for (var i = 0; i < value.length; i++) { var number = 0; if ((value.charCodeAt(i) >= 32 && value.charCodeAt(i) <= 126) || (value.charCodeAt(i) === 10 || value.charCodeAt(i) === 13)) { validData = true; } } return validData; }; DataMatrixGenerator.prototype.exportImage = function (fileName, exportType) { barcode_util_1.exportAsImage(exportType, fileName, this.element, false, this); }; DataMatrixGenerator.prototype.exportAsBase64Image = function (barcodeExportType) { var returnValue = barcode_util_1.exportAsImage(barcodeExportType, '', this.element, true, this); return returnValue; }; DataMatrixGenerator.prototype.renderElements = function () { var dataMatrix = new datamatrix_util_1.DataMatrix(); dataMatrix.encodingValue = this.encoding; dataMatrix.size = this.size; dataMatrix.value = this.value; dataMatrix.width = this.barcodeCanvas.getAttribute('width'); dataMatrix.height = this.barcodeCanvas.getAttribute('height'); dataMatrix.XDimension = this.xDimension; dataMatrix.isSvgMode = this.mode === 'SVG' ? true : false; dataMatrix.margin = this.margin; dataMatrix.displayText = this.displayText; dataMatrix.foreColor = this.foreColor; var checkOtherLanguage = this.checkdata(this.value); var encoding = (dataMatrix.BuildDataMatrix()); if (isNaN(encoding[0])) { this.triggerEvent(enum_1.BarcodeEvent.invalid, encoding); } else if (!checkOtherLanguage) { this.triggerEvent(enum_1.BarcodeEvent.invalid, 'Invalid input'); } else { dataMatrix.draw(this.barcodeCanvas); } if (this.mode === 'Canvas') { this.barcodeCanvas.style.transform = 'scale(' + (2 / 3) + ')'; this.barcodeCanvas.style.transformOrigin = '0 0'; } }; DataMatrixGenerator.prototype.render = function () { this.notify('initial-load', {}); this.trigger('load'); this.notify('initial-end', {}); this.renderElements(); this.renderComplete(); }; __decorate([ ej2_base_1.Property('Auto') ], DataMatrixGenerator.prototype, "encoding", void 0); __decorate([ ej2_base_1.Property(enum_1.DataMatrixSize.Auto) ], DataMatrixGenerator.prototype, "size", void 0); __decorate([ ej2_base_1.Property('SVG') ], DataMatrixGenerator.prototype, "mode", void 0); __decorate([ ej2_base_1.Property(undefined) ], DataMatrixGenerator.prototype, "value", void 0); __decorate([ ej2_base_1.Property('100%') ], DataMatrixGenerator.prototype, "height", void 0); __decorate([ ej2_base_1.Property('100%') ], DataMatrixGenerator.prototype, "width", void 0); __decorate([ ej2_base_2.Complex({}, displaytext_1.DisplayText) ], DataMatrixGenerator.prototype, "displayText", void 0); __decorate([ ej2_base_2.Complex({}, margin_1.Margin) ], DataMatrixGenerator.prototype, "margin", void 0); __decorate([ ej2_base_1.Property('white') ], DataMatrixGenerator.prototype, "backgroundColor", void 0); __decorate([ ej2_base_2.Event() ], DataMatrixGenerator.prototype, "invalid", void 0); __decorate([ ej2_base_1.Property('black') ], DataMatrixGenerator.prototype, "foreColor", void 0); __decorate([ ej2_base_1.Property(1) ], DataMatrixGenerator.prototype, "xDimension", void 0); return DataMatrixGenerator; }(ej2_base_1.Component)); exports.DataMatrixGenerator = DataMatrixGenerator; }); |