jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
1,961 lines (1,725 loc) • 1.23 MB
JavaScript
/* Release Date: Jan-28-2025
Copyright (c) 2011-2025 jQWidgets.
License: https://jqwidgets.com/license/ */
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 2917:
/***/ (() => {
/* tslint:disable */
/* eslint-disable */
(function(){
if (typeof document === 'undefined') {
return;
}
(function ($) {
$.jqx.jqxWidget("jqxBarcode", "", {});
$.extend($.jqx._jqxBarcode.prototype, {
defineInstance: function () {
var settings = {
value: '12345',
type: 'codabar',
backgroundColor: 'white',
lineWidth: 4,
lineHeight: 50,
lineColor: 'black',
displayLabel: true,
labelPosition: 'bottom',
labelFontSize: 14,
labelMarginTop: 5,
labelMarginBottom: 5,
labelColor: 'black',
labelFont: 'monospace',
renderAs: 'svg'
}
$.extend(true, this, settings);
return settings;
},
createInstance: function (args) {
var that = this;
var barcode = new Barcode(this.element);
barcode.value = that.value;
barcode.type = that.type;
barcode.backgroundColor = that.backgroundColor;
barcode.lineWidth = that.lineWidth;
barcode.lineHeight = that.lineHeight;
barcode.lineColor = that.lineColor;
barcode.displayLabel = that.displayLabel;
barcode.labelPosition = that.labelPosition;
barcode.labelFontSize = that.labelFontSize;
barcode.labelMarginTop = that.labelMarginTop;
barcode.labelMarginBottom = that.labelMarginBottom;
barcode.labelColor = that.labelColor;
barcode.labelFont = that.labelFont;
barcode.renderAs = that.renderAs;
this.element.innerHTML = barcode.template();
this.barcode = barcode;
barcode.refresh();
},
getDataURL: function (format) {
return this.barcode.getDataURL(format);
},
export: function (format, fileName) {
this.barcode.export(format, fileName);
},
isValid: function () {
return this.barcode.isValid(false);
},
propertyChangedHandler: function (object, key, oldvalue, value) {
var that = object;
that.barcode.refresh();
}
});
})(jqxBaseFramework);
class Barcode {
constructor(host) {
this.host = host;
}
// Barcode's properties.
static get properties() {
return {
value: {
type: 'string',
value: ''
},
type: {
value: 'codabar',
type: 'string',
allowedValues: [
'pharmacode',
'codabar',
'code128a',
'code128b',
'code128c',
'msi',
'msi10',
'msi11',
'msi1010',
'msi1110',
'ean13',
'ean8',
'code39',
'code93',
]
},
backgroundColor: {
value: 'white',
type: 'string'
},
lineWidth: {
value: 4,
type: 'number'
},
lineHeight: {
value: 50,
type: 'number'
},
lineColor: {
value: 'black',
type: 'string'
},
displayLabel: {
value: true,
type: 'boolean'
},
labelPosition: {
value: 'bottom',
type: 'string',
allowedValues: ['top', 'bottom']
},
labelFontSize: {
value: 14,
type: 'number'
},
labelMarginTop: {
value: 5,
type: 'number'
},
labelMarginBottom: {
value: 5,
type: 'number'
},
labelColor: {
value: 'black',
type: 'string'
},
labelFont: {
value: 'monospace',
type: 'string'
},
renderAs: {
value: 'svg',
type: 'string',
allowedValues: ['svg', 'canvas']
},
};
}
/** Barcode's template. */
template() {
return '<div class="jqx-barcode-container"></div>';
}
/**
* Refreshes the UI Component.
*/
refresh() {
const that = this;
that._generateCode(that.renderAs);
}
/**
* Generates barcode
*/
_generateCode(renderAs, hidden = false) {
const that = this;
const encoded = this._getEncoded(that.type, that.value);
const barcodeLength = encoded.length * that.lineWidth;
const barcodeHeight =
that.lineHeight +
that.displayLabel *
(that.labelMarginTop + that.labelMarginBottom + that.labelFontSize);
let x = 0,
y = 0,
container;
that.isValid();
if (renderAs === 'svg') {
container = document.createElementNS(
'http://www.w3.org/2000/svg',
'svg'
);
container.setAttribute('width', barcodeLength);
container.setAttribute('height', barcodeHeight);
container.setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:svg',
'http://www.w3.org/2000/svg'
);
container.style.backgroundColor = that.backgroundColor;
}
else if (renderAs === 'canvas') {
container = document.createElement('canvas');
container.setAttribute('width', barcodeLength);
container.setAttribute('height', barcodeHeight);
let ctx = container.getContext('2d');
ctx.fillStyle = that.backgroundColor;
ctx.fillRect(0, 0, barcodeLength, barcodeHeight);
}
if (hidden) {
container.style.display = 'none';
}
container.classList.add('jqx-barcode');
that.host.firstChild.appendChild(container);
if (that.displayLabel && that.labelPosition === 'top') {
y += that.labelMarginTop + that.labelFontSize;
renderAs === 'svg'
? that._drawTextSVG(barcodeLength / 2, y, container)
: that._drawTextCanvas(barcodeLength / 2, y, container);
y += that.labelMarginBottom;
}
for (let line of encoded) {
if (line === '1') {
renderAs === 'svg'
? that._drawStepSVG(that.lineColor, 1, x, y, container)
: that._drawStepCanvas(that.lineColor, 1, x, y, container);
}
else {
renderAs === 'svg'
? that._drawStepSVG('white', 0, x, y, container)
: that._drawStepCanvas('white', 0, x, y, container);
}
x += that.lineWidth;
}
if (that.displayLabel && that.labelPosition === 'bottom') {
y += that.lineHeight + that.labelMarginTop + that.labelFontSize;
renderAs === 'svg'
? that._drawTextSVG(barcodeLength / 2, y, container)
: that._drawTextCanvas(barcodeLength / 2, y, container);
}
//Removes previous container
if (that.host.firstChild.children.length === 2) {
if (that.host.firstChild.children[1].style.display !== 'none') {
that.host.firstChild.removeChild(that.host.firstChild.firstChild);
}
}
}
/**
* Gets barcode encoded string
*/
_getEncoded(type, value) {
const that = this;
let encoded;
switch (type) {
case 'pharmacode': {
encoded = that._getEncodedPharmacode(value);
break;
}
case 'codabar': {
encoded = that._getEncodedCodabar(value);
break;
}
case 'code128a': {
encoded = that._getEncodedCode128(value, 'A');
break;
}
case 'code128b': {
encoded = that._getEncodedCode128(value, 'B');
break;
}
case 'code128c': {
encoded = that._getEncodedCode128(that.value, 'C');
break;
}
case 'msi': {
encoded = that._getEncodedMSI(that.value, '');
break;
}
case 'msi10': {
encoded = that._getEncodedMSI(that.value, '10');
break;
}
case 'msi11': {
encoded = that._getEncodedMSI(that.value, '11');
break;
}
case 'msi1010': {
encoded = that._getEncodedMSI(that.value, '1010');
break;
}
case 'msi1110': {
encoded = that._getEncodedMSI(that.value, '1010');
break;
}
case 'ean13': {
encoded = that._getEncodedEAN(that.value, '13');
break;
}
case 'ean8': {
encoded = that._getEncodedEAN(that.value, '8');
break;
}
case 'code39': {
encoded = that._getEncodedCode39(that.value);
break;
}
case 'code93': {
encoded = that._getEncodedCode93(that.value);
break;
}
}
return encoded;
}
/**
* Validates the barcode value
*/
isValid(isQRcode = false) {
const that = this;
const type = that.type;
const val = that.value;
let charactersRegex = /[^@!(一-龠)(ぁ-ゔ)(ァ-ヴー)\d0-9A-Z \$\%\*\+\-\.\/\:\=\?\^\{\|\}\~]/gm,
patternValidity = true,
lengthValidity = true,
illegalChars = [];
if (!isQRcode) {
switch (type) {
case 'pharmacode': {
charactersRegex = /[^\d]/gm;
lengthValidity = val.length >= 1 && val.length <= 6;
patternValidity = +val >= 3 && +val <= 131070;
break;
}
case 'codabar': {
charactersRegex = /[^ABCD\d\$-]/gm;
patternValidity = /^[A-D]\d+[A-D]$/gm.test(val);
break;
}
case 'code128a': {
charactersRegex = /[^\x20-\x5F]/gm;
break;
}
case 'code128b': {
charactersRegex = /[^\x20-\x7F]/gm;
break;
}
case 'code128c': {
charactersRegex = /[^\d]/gm;
break;
}
case 'msi':
case 'msi10':
case 'msi11':
case 'msi1010':
case 'msi1110': {
charactersRegex = /[^\d]/gm;
break;
}
case 'ean13': {
charactersRegex = /[^\d]/gm;
lengthValidity = val.length === 13 || val.length === 12;
break;
}
case 'ean8': {
charactersRegex = /[^\d]/gm;
lengthValidity = val.length === 7 || val.length === 8;
break;
}
case 'code39': {
charactersRegex = /[^\w\*.]/gm;
patternValidity = /^\*\*$/gm.test(val);
break;
}
case 'code93': {
charactersRegex = /[^\w\*.\-\* \$+\/%]/gm;
patternValidity = /^\*\*$/gm.test(val);
break;
}
}
}
illegalChars = val.match(charactersRegex);
if (!patternValidity || illegalChars || !lengthValidity) {
this.host.dispatchEvent(new CustomEvent("invalid", {
detail: {
value: val,
invalidCharacters: illegalChars,
patternValidity: patternValidity,
lengthValidity: lengthValidity
}
}));
return false;
}
return true;
}
/**
* Draws the label text in SVG
*/
_drawTextSVG(x, y, svg_container) {
const that = this;
let textElem = document.createElementNS(
'http://www.w3.org/2000/svg',
'text'
);
textElem.setAttribute('x', x);
textElem.setAttribute('y', y);
textElem.setAttribute('text-anchor', 'middle');
textElem.classList.add('jqx-barcode-label');
textElem.style.fill = that.labelColor;
textElem.style.fontFamily = that.labelFont;
textElem.style.fontSize = that.labelFontSize + 'px';
textElem.textContent = that.value;
svg_container.appendChild(textElem);
}
/**
* Draws the label text in Canvas
*/
_drawTextCanvas(x, y, canvas) {
const that = this;
let ctx = canvas.getContext('2d');
ctx.font = `${that.labelFontSize}px ${that.labelFont}`;
ctx.fillStyle = that.labelColor;
ctx.textAlign = 'center';
ctx.fillText(that.value, x, y);
}
/**
* Draws a single unit bar in svg
*/
_drawStepSVG(color, opacity, x, y, svg_container) {
const that = this;
if (that.squareWidth) {
that.lineWidth = that.squareWidth;
that.lineHeight = that.squareWidth;
}
let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttribute('x', x);
rect.setAttribute('y', y);
rect.setAttribute('width', that.lineWidth);
rect.setAttribute('height', that.lineHeight);
rect.setAttribute('fill-opacity', opacity);
rect.style.fill = color;
svg_container.appendChild(rect);
}
/**
* Draws a single unit bar in canvas
*/
_drawStepCanvas(color, opacity, x, y, canvas) {
const that = this;
if (that.squareWidth) {
that.lineWidth = that.squareWidth;
that.lineHeight = that.squareWidth;
}
let ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.globalAlpha = opacity;
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.rect(x, y, that.lineWidth, that.lineHeight);
ctx.fill();
}
/**
* Encodes data in pharmacode format
*/
_getEncodedPharmacode(val) {
let encoded = '';
while (val !== 0) {
if (val % 2 === 0) {
encoded = '11100' + encoded;
val = (val - 2) / 2;
}
else {
encoded = '100' + encoded;
val = (val - 1) / 2;
}
}
encoded = encoded.slice(0, -2);
return encoded;
}
/**
* Encodes data in codabar format
*/
_getEncodedCodabar(val) {
let encoded = '';
const sets = {
0: 1010100110,
1: 1010110010,
2: 1010010110,
3: 1100101010,
4: 1011010010,
5: 1101010010,
6: 1001010110,
7: 1001011010,
8: 1001101010,
9: 1101001010,
'-': 1010011010,
$: 1011001010,
':': 11010110110,
'/': 11011010110,
'.': 11011011010,
'+': 10110110110,
A: 10110010010,
B: 10010010110,
C: 10100100110,
D: 10100110010,
};
for (let char of val) {
encoded += sets[char];
}
encoded = encoded.slice(0, -1);
return encoded;
}
/**
* Encodes data in code39 format
*/
_getEncodedCode39(val) {
let encoded = '';
const chars = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'-',
'.',
' ',
'$',
'/',
'+',
'%',
'*',
];
const set = [
20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645,
29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301,
30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385,
29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477,
17489, 17681, 20753, 35770,
];
for (let char of val) {
encoded += set[chars.indexOf(char)].toString(2) + '0';
}
encoded = encoded.slice(0, -1);
return encoded;
}
/**
* Encodes data in code93 format
*/
_getEncodedCode93(val) {
let encoded = '';
const chars = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'-',
'.',
' ',
'$',
'/',
'+',
'%',
'*',
];
const set = [
100010100, 101001000, 101000100, 101000010, 100101000, 100100100,
100100010, 101010000, 100010010, 100001010, 110101000, 110100100,
110100010, 110010100, 110010010, 110001010, 101101000, 101100100,
101100010, 100110100, 100011010, 101011000, 101001100, 101000110,
100101100, 100010110, 110110100, 110110010, 110101100, 110100110,
110010110, 110011010, 101101100, 101100110, 100110110, 100111010,
100101110, 111010100, 111010010, 111001010, 111010110, 100110010,
111011010, 101011110,
];
for (let char of val) {
encoded += set[chars.indexOf(char)] + '0';
}
encoded = encoded.slice(0, -1);
return encoded;
}
/**
* Encodes data in MSI format
*/
_getEncodedMSI(val, mod) {
let encoded = '';
const sets = {
0: 100100100100,
1: 100100100110,
2: 100100110100,
3: 100100110110,
4: 100110100100,
5: 100110100110,
6: 100110110100,
7: 100110110110,
8: 110100100100,
9: 110100100110,
};
encoded += '110';
if (mod === '10') {
val += this._getMSIMod10(val);
}
else if (mod === '11') {
val += this._getMSIMod11(val);
}
else if (mod === '1010') {
val += this._getMSIMod10(val);
val += this._getMSIMod10(val);
}
else if (mod === '1110') {
val += this._getMSIMod11(val);
val += this._getMSIMod10(val);
}
for (let char of val) {
encoded += sets[char];
}
encoded += '1001';
return encoded;
}
/**
* Encodes data in EAN format
*/
_getEncodedEAN(val, type) {
let encoded = '';
const table = [
[
'0001101',
'0011001',
'0010011',
'0111101',
'0100011',
'0110001',
'0101111',
'0111011',
'0110111',
'0001011',
],
[
'0100111',
'0110011',
'0011011',
'0100001',
'0011101',
'0111001',
'0000101',
'0010001',
'0001001',
'0010111',
],
[
'1110010',
'1100110',
'1101100',
'1000010',
'1011100',
'1001110',
'1010000',
'1000100',
'1001000',
'1110100',
],
];
const ean13_set = [
'000000',
'001011',
'001101',
'001110',
'010011',
'011001',
'011100',
'010101',
'010110',
'011010',
];
//Compute check digit and add it to the string if it doesn't exist
if (val.length === 12 || val.length === 7) {
let intSumEven = 0,
intSumOdd = 0,
intCheck,
stopper;
if (val.length === 7) {
stopper = 5;
}
else {
stopper = 12;
}
for (let i = 0; i < stopper; i += 2) {
intSumEven += parseInt(val[i]);
intSumOdd += parseInt(val[i + 1]);
}
intCheck = (intSumOdd * 3 + intSumEven) % 10;
if (intCheck > 0) {
intCheck = 10 - intCheck;
}
val += intCheck;
}
if (type === '13') {
encoded += '101';
let structure = ean13_set[val[0]];
for (let i = 1; i < 7; i++) {
encoded += table[structure[i - 1]][val[i]];
}
encoded += '01010';
for (let i = 0; i < 6; i++) {
encoded += table[2][val[i + 7]];
}
encoded += '101';
}
else if (type === '8') {
encoded += '101';
for (let i = 0; i < 4; i++) {
encoded += table[0][val[i]];
}
encoded += '01010';
for (let i = 0; i < 4; i++) {
encoded += table[2][val[i + 4]];
}
encoded += '101';
}
return encoded;
}
/**
* Gets the mod10 value of the MSI format
*/
_getMSIMod10(val) {
let sum = 0;
for (var i = 0; i < val.length; i++) {
var n = parseInt(val[i]);
if ((i + val.length) % 2 === 0) {
sum += n;
}
else {
sum += ((n * 2) % 10) + Math.floor((n * 2) / 10);
}
}
return (10 - (sum % 10)) % 10;
}
/**
* Gets the mod11 value of the MSI format
*/
_getMSIMod11(val) {
let sum = 0;
var weights = [2, 3, 4, 5, 6, 7];
for (var i = 0; i < val.length; i++) {
var n = parseInt(val[val.length - 1 - i]);
sum += weights[i % weights.length] * n;
}
return (11 - (sum % 11)) % 11;
}
/**
* Encodes data in code128 format
*/
_getEncodedCode128(val, type) {
let encoded = '',
elements = [],
checkSum = 0,
start;
const table = [
[' ', ' ', '00', '11011001100'],
['!', '!', '01', '11001101100'],
['"', '"', '02', '11001100110'],
['#', '#', '03', '10010011000'],
['$', '$', '04', '10010001100'],
['%', '%', '05', '10001001100'],
['&', '&', '06', '10011001000'],
['\'', '\'', '07', '10011000100'],
['(', '(', '08', '10001100100'],
[')', ')', '09', '11001001000'],
['*', '*', '10', '11001000100'],
['+', '+', '11', '11000100100'],
[',', ',', '12', '10110011100'],
['-', '-', '13', '10011011100'],
['.', '.', '14', '10011001110'],
['/', '/', '15', '10111001100'],
['0', '0', '16', '10011101100'],
['1', '1', '17', '10011100110'],
['2', '2', '18', '11001110010'],
['3', '3', '19', '11001011100'],
['4', '4', '20', '11001001110'],
['5', '5', '21', '11011100100'],
['6', '6', '22', '11001110100'],
['7', '7', '23', '11101101110'],
['8', '8', '24', '11101001100'],
['9', '9', '25', '11100101100'],
[':', ':', '26', '11100100110'],
[';', ';', '27', '11101100100'],
['<', '<', '28', '11100110100'],
['=', '=', '29', '11100110010'],
['>', '>', '30', '11011011000'],
['?', '?', '31', '11011000110'],
['@', '@', '32', '11000110110'],
['A', 'A', '33', '10100011000'],
['B', 'B', '34', '10001011000'],
['C', 'C', '35', '10001000110'],
['D', 'D', '36', '10110001000'],
['E', 'E', '37', '10001101000'],
['F', 'F', '38', '10001100010'],
['G', 'G', '39', '11010001000'],
['H', 'H', '40', '11000101000'],
['I', 'I', '41', '11000100010'],
['J', 'J', '42', '10110111000'],
['K', 'K', '43', '10110001110'],
['L', 'L', '44', '10001101110'],
['M', 'M', '45', '10111011000'],
['N', 'N', '46', '10111000110'],
['O', 'O', '47', '10001110110'],
['P', 'P', '48', '11101110110'],
['Q', 'Q', '49', '11010001110'],
['R', 'R', '50', '11000101110'],
['S', 'S', '51', '11011101000'],
['T', 'T', '52', '11011100010'],
['U', 'U', '53', '11011101110'],
['V', 'V', '54', '11101011000'],
['W', 'W', '55', '11101000110'],
['X', 'X', '56', '11100010110'],
['Y', 'Y', '57', '11101101000'],
['Z', 'Z', '58', '11101100010'],
['[', '[', '59', '11100011010'],
['\\', '\\', '60', '11101111010'],
[']', ']', '61', '11001000010'],
['^', '^', '62', '11110001010'],
['_', '_', '63', '10100110000'],
['NUL', '`', '64', '10100001100'],
['SOH', 'a', '65', '10010110000'],
['STX', 'b', '66', '10010000110'],
['ETX', 'c', '67', '10000101100'],
['EOT', 'd', '68', '10000100110'],
['ENQ', 'e', '69', '10110010000'],
['ACK', 'f', '70', '10110000100'],
['BEL', 'g', '71', '10011010000'],
['BS', 'h', '72', '10011000010'],
['HT', 'i', '73', '10000110100'],
['LF', 'j', '74', '10000110010'],
['VT', 'k', '75', '11000010010'],
['FF', 'l', '76', '11001010000'],
['CR', 'm', '77', '11110111010'],
['SO', 'n', '78', '11000010100'],
['SI', 'o', '79', '10001111010'],
['DLE', 'p', '80', '10100111100'],
['DC1', 'q', '81', '10010111100'],
['DC2', 'r', '82', '10010011110'],
['DC3', 's', '83', '10111100100'],
['DC4', 't', '84', '10011110100'],
['NAK', 'u', '85', '10011110010'],
['SYN', 'v', '86', '11110100100'],
['ETB', 'w', '87', '11110010100'],
['CAN', 'x', '88', '11110010010'],
['EM', 'y', '89', '11011011110'],
['SUB', 'z', '90', '11011110110'],
['ESC', '[', '91', '11110110110'],
['FS', '|', '92', '10101111000'],
['GS', ']', '93', '10100011110'],
['RS', '~', '94', '10001011110'],
['US', 'DEL', '95', '10111101000'],
['FNC3', 'FNC3', '96', '10111100010'],
['FNC2', 'FNC2', '97', '11110101000'],
['SHIFT', 'SHIFT', '98', '11110100010'],
['CODEC', 'CODEC', '99', '10111011110'],
['CODEB', 'FNC4', 'CODEB', '10111101110'],
['FNC4', 'CODEA', 'CODEA', '11101011110'],
['FNC1', 'FNC1', 'FNC1', '11110101110'],
['StartA', 'StartA', 'StartA', '11010000100'],
['StartB', 'StartB', 'StartB', '11010010000'],
['StartC', 'StartC', 'StartC', '11010011100'],
['Stop', 'Stop', 'Stop', '1100011101011'],
];
if (type === 'A') {
start = 103;
for (const [i, char] of val.split('').entries()) {
let element = table.find((x) => x[0] === char);
if (element) {
elements.push(element);
checkSum += i * element.length;
}
}
}
else if (type === 'B') {
start = 104;
for (const [i, char] of val.split('').entries()) {
let element = table.find((x) => x[1] === char);
if (element) {
elements.push(element);
checkSum += i * element.length;
}
}
}
else if (type === 'C') {
start = 105;
for (let i = 0; i < val.length - 1; i += 2) {
let substr = val.substring(i, 2);
let element = table.find((x) => x[2] === substr);
if (element) {
elements.push(element);
checkSum += substr * element.length;
}
}
}
checkSum += start;
elements.push(table[checkSum % 103]);
elements.unshift(table[start]);
elements.push(table[106]);
elements.forEach((el) => (encoded += el[3]));
return encoded;
}
/**
* Gets the Base64 String of the barcode
*
* @param {String} format Sets the dataURL format of the string. Allowed values are 'svg', 'png', 'jpg'
*/
getDataURL(format) {
const that = this;
if (format === 'svg') {
if (that.renderAs !== 'svg') {
that._generateCode('svg', true);
}
let svg = that.host.querySelector('svg');
let data = new XMLSerializer().serializeToString(svg);
let svgBlob = new Blob([data], {
type: 'image/svg+xml;charset=utf-8',
});
const url = URL.createObjectURL(svgBlob);
return url;
}
else if (format === 'png' || format === 'jpg') {
let file_format = format === 'png' ? 'png' : 'jpeg';
if (that.renderAs !== 'canvas') {
that._generateCode('canvas', true);
}
let canvas = that.host.querySelector('canvas');
const url = canvas.toDataURL(`image/${file_format}`);
return url;
}
}
/**
* Gets the Base64 String of the barcode asynchronously
*
* @param {String} format Sets the dataURL format of the string. Allowed values are 'svg', 'png', 'jpg'
*/
getDataURLAsync(format) {
const that = this;
return new Promise((resolve, reject) => {
let url = that.getDataURL(format);
if (url) {
resolve(url);
}
else {
reject();
}
});
}
/**
* Export the barcode to a file
*
* @param {String} format Sets the export format of the barcode. Allowed values are 'svg', 'png', 'jpg'
* @param {String} fileName Sets the name of the exported file
*/
export(format = 'png', fileName = 'barcode') {
const that = this;
that.getDataURLAsync(format).then((url) => {
let a = document.createElement('a');
a.setAttribute('download', `${fileName}.${format}`);
a.setAttribute('href', url);
a.setAttribute('target', '_blank');
a.click();
});
}
/**
* Called when a property is changed.
*/
propertyChangedHandler(propertyName, oldValue, newValue) {
const that = this;
that.refresh();
}
ready() {
const that = this;
this._generateCode(that.renderAs);
}
}
})();
/***/ }),
/***/ 5459:
/***/ ((module, exports, __webpack_require__) => {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* tslint:disable */
/* eslint-disable */
(function(){
if (typeof document === 'undefined') {
return;
}
var oldBrowser = document.all && !document.addEventListener;
if (!oldBrowser) {
(function (window, undefined) {
var
rootJQXLite,
readyList,
document = window.document,
location = window.location,
navigator = window.navigator,
_JQXLite = window.JQXLite,
_$ = window.$,
// Save a reference to some core methods
core_push = Array.prototype.push,
core_slice = Array.prototype.slice,
core_indexOf = Array.prototype.indexOf,
core_toString = Object.prototype.toString,
core_hasOwn = Object.prototype.hasOwnProperty,
core_trim = String.prototype.trim,
// Define a local copy of JQXLite
JQXLite = function (selector, context) {
// The JQXLite object is actually just the init constructor 'enhanced'
return new JQXLite.fn.init(selector, context, rootJQXLite);
},
// Used for matching numbers
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
// Used for detecting and trimming whitespace
core_rnotwhite = /\S/,
core_rspace = /\s+/,
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
// JSON RegExp
rvalidchars = /^[\],:{}\s]*$/,
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
// Matches dashed string for camelizing
rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi,
// Used by JQXLite.camelCase as callback to replace()
fcamelCase = function (all, letter) {
return (letter + "").toUpperCase();
},
// The ready event handler and self cleanup method
DOMContentLoaded = function () {
if (document.addEventListener) {
document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
JQXLite.ready();
} else if (document.readyState === "complete") {
// we're here because readyState === "complete" in oldIE
// which is good enough for us to call the dom ready!
document.detachEvent("onreadystatechange", DOMContentLoaded);
JQXLite.ready();
}
},
// [[Class]] -> type pairs
class2type = {};
JQXLite.fn = JQXLite.prototype = {
constructor: JQXLite,
init: function (selector, context, rootJQXLite) {
var match, elem, ret, doc;
// Handle $(""), $(null), $(undefined), $(false)
if (!selector) {
return this;
}
// Handle $(DOMElement)
if (selector.nodeType) {
this.context = this[0] = selector;
this.length = 1;
return this;
}
// Handle HTML strings
if (typeof selector === "string") {
if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
// Assume that strings that start and end with <> are HTML and skip the regex check
match = [null, selector, null];
} else {
match = rquickExpr.exec(selector);
}
// Match html or make sure no context is specified for #id
if (match && (match[1] || !context)) {
// HANDLE: $(html) -> $(array)
if (match[1]) {
context = context instanceof JQXLite ? context[0] : context;
doc = (context && context.nodeType ? context.ownerDocument || context : document);
// scripts is true for back-compat
selector = JQXLite.parseHTML(match[1], doc, true);
if (rsingleTag.test(match[1]) && JQXLite.isPlainObject(context)) {
this.attr.call(selector, context, true);
}
return JQXLite.merge(this, selector);
// HANDLE: $(#id)
} else {
elem = document.getElementById(match[2]);
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if (elem && elem.parentNode) {
// Handle the case where IE and Opera return items
// by name instead of ID
if (elem.id !== match[2]) {
return rootJQXLite.find(selector);
}
// Otherwise, we inject the element directly into the JQXLite object
this.length = 1;
this[0] = elem;
}
this.context = document;
this.selector = selector;
return this;
}
// HANDLE: $(expr, $(...))
} else if (!context || context.jqx) {
return (context || rootJQXLite).find(selector);
// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
} else {
return this.constructor(context).find(selector);
}
// HANDLE: $(function)
// Shortcut for document ready
} else if (JQXLite.isFunction(selector)) {
return rootJQXLite.ready(selector);
}
if (selector.selector !== undefined) {
this.selector = selector.selector;
this.context = selector.context;
}
return JQXLite.makeArray(selector, this);
},
// Start with an empty selector
selector: "",
// The current version of JQXLite being used
jqx: "4.5.0",
// The default length of a JQXLite object is 0
length: 0,
// The number of elements contained in the matched element set
size: function () {
return this.length;
},
toArray: function () {
return core_slice.call(this);
},
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function (num) {
return num == null ?
// Return a 'clean' array
this.toArray() :
// Return just the object
(num < 0 ? this[this.length + num] : this[num]);
},
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function (elems, name, selector) {
// Build a new JQXLite matched element set
var ret = JQXLite.merge(this.constructor(), elems);
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
if (name === "find") {
ret.selector = this.selector + (this.selector ? " " : "") + selector;
} else if (name) {
ret.selector = this.selector + "." + name + "(" + selector + ")";
}
// Return the newly-formed element set
return ret;
},
// Execute a callback for every element in the matched set.
// (You can seed the arguments with an array of args, but this is
// only used internally.)
each: function (callback, args) {
return JQXLite.each(this, callback, args);
},
ready: function (fn) {
// Add the callback
JQXLite.ready.promise().done(fn);
return this;
},
eq: function (i) {
i = +i;
return i === -1 ?
this.slice(i) :
this.slice(i, i + 1);
},
first: function () {
return this.eq(0);
},
last: function () {
return this.eq(-1);
},
slice: function () {
return this.pushStack(core_slice.apply(this, arguments),
"slice", core_slice.call(arguments).join(","));
},
map: function (callback) {
return this.pushStack(JQXLite.map(this, function (elem, i) {
return callback.call(elem, i, elem);
}));
},
end: function () {
return this.prevObject || this.constructor(null);
},
// For internal use only.
// Behaves like an Array's method, not like a JQXLite method.
push: core_push,
sort: [].sort,
splice: [].splice
};
// Give the init function the JQXLite prototype for later instantiation
JQXLite.fn.init.prototype = JQXLite.fn;
JQXLite.extend = JQXLite.fn.extend = function () {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if (typeof target === "boolean") {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// Handle case when target is a string or something (possible in deep copy)
if (typeof target !== "object" && !JQXLite.isFunction(target)) {
target = {};
}
// extend JQXLite itself if only one argument is passed
if (length === i) {
target = this;
--i;
}
for (; i < length; i++) {
// Only deal with non-null/undefined values
if ((options = arguments[i]) != null) {
// Extend the base object
for (name in options) {
src = target[name];
copy = options[name];
// Prevent never-ending loop
if (target === copy) {
continue;
}
// Recurse if we're merging plain objects or arrays
if (deep && copy && (JQXLite.isPlainObject(copy) || (copyIsArray = JQXLite.isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && JQXLite.isArray(src) ? src : [];
} else {
clone = src && JQXLite.isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[name] = JQXLite.extend(deep, clone, copy);
// Don't bring in undefined values
} else if (copy !== undefined) {
target[name] = copy;
}
}
}
}
// Return the modified object
return target;
};
JQXLite.extend({
noConflict: function (deep) {
if (window.$ === JQXLite) {
window.$ = _$;
}
if (deep && window.JQXLite === JQXLite) {
window.JQXLite = _JQXLite;
}
return JQXLite;
},
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Hold (or release) the ready event
holdReady: function (hold) {
if (hold) {
JQXLite.readyWait++;
} else {
JQXLite.ready(true);
}
},
// Handle when the DOM is ready
ready: function (wait) {
// Abort if there are pending holds or we're already ready
if (wait === true ? --JQXLite.readyWait : JQXLite.isReady) {
return;
}
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if (!document.body) {
return setTimeout(JQXLite.ready, 1);
}
// Remember that the DOM is ready
JQXLite.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if (wait !== true && --JQXLite.readyWait > 0) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith(document, [JQXLite]);
// Trigger any bound ready events
if (JQXLite.fn.trigger) {
JQXLite(document).trigger("ready").off("ready");
}
},
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
isFunction: function (obj) {
return JQXLite.type(obj) === "function";
},
isArray: Array.isArray || function (obj) {
return JQXLite.type(obj) === "array";
},
isWindow: function (obj) {
return obj != null && obj == obj.window;
},
isNumeric: function (obj) {
return !isNaN(parseFloat(obj)) && isFinite(obj);
},
type: function (obj) {
return obj == null ?
String(obj) :
class2type[core_toString.call(obj)] || "object";
},
isPlainObject: function (obj) {
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if (!obj || JQXLite.type(obj) !== "object" || obj.nodeType || JQXLite.isWindow(obj)) {
return false;
}
try {
// Not own constructor property must be Object
if (obj.constructor &&
!core_hasOwn.call(obj, "constructor") &&
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
return false;
}
} catch (e) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) { }
return key === undefined || core_hasOwn.call(obj, key);
},
isEmptyObject: function (obj) {
var name;
for (name in obj) {
return false;
}
return true;
},
error: function (msg) {
throw new Error(msg);
},
// data: string of html
// context (optional): If specified, the fragment will be created in this context, defaults to document
// scripts (optional): If true, will include scripts passed in the html string
parseHTML: function (data, context, scripts) {
var parsed;
if (!data || typeof data !== "string") {
return null;
}
if (typeof context === "boolean") {
scripts = context;
context = 0;
}
context = context || document;
// Single tag
if ((parsed = rsingleTag.exec(data))) {
return [context.createElement(parsed[1])];
}
parsed = JQXLite.buildFragment([data], context, scripts ? null : []);
return JQXLite.merge([],
(parsed.cacheable ? JQXLite.clone(parsed.fragment) : parsed.fragment).childNodes);
},
parseJSON: function (data) {
if (!data || typeof data !== "string") {
return null;
}
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = JQXLite.trim(data);
// Attempt to parse using the native JSON parser first
if (window.JSON && window.JSON.parse) {
return window.JSON.parse(data);
}
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
if (rvalidchars.test(data.replace(rvalidescape, "@")
.replace(rvalidtokens, "]")
.replace(rvalidbraces, ""))) {
return (new Function("return " + data))();
}
JQXLite.error("Invalid JSON: " + data);
},
// Cross-browser xml parsing
parseXML: function (data) {
var xml, tmp;
if (!data || typeof data !== "string") {
return null;
}
try {
if (window.DOMParser) { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString(data, "text/xml");
} else { // IE
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = "false";
xml.loadXML(data);
}
} catch (e) {
xml = undefined;
}
if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) {
JQXLite.error("Invalid XML: " + data);
}
return xml;
},
noop: function () { },
// Evaluates a script in a global context
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
globalEval: function (data) {
if (data && core_rnotwhite.test(data)) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than JQXLite in Firefox
(window.execScript || function (data) {
window["eval"].call(window, data);
})(data);
}
},
// Convert dashed to camelCase; used by the css and data modules
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function (string) {
return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase);
},
nodeName: function (elem, name) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
},
// args is for internal usage only
each: function (obj, callback, args) {
var name,
i = 0,
length = obj.length,
isObj = length === undefined || JQXLite.isFunction(obj);
if (args) {
if (isObj) {
for (name in obj) {
if (callback.apply(obj[name], args) === false) {
break;
}
}
} else {
for (; i < length;) {
if (callback.apply(obj[i++], args) === false) {
break;
}
}
}
// A special, fast, case for the most common use of each
} else {
if (isObj) {
for (name in obj) {
if (callback.call(obj[name], name, obj[name]) === false) {
break;
}
}
} else {
for (; i < length;) {
if (callback.call(obj[i], i, obj[i++]) === false) {
break;
}
}
}
}
return obj;
},
// Use native String.trim function wherever possible
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
function (text) {
return text == null ?
"" :
core_trim.call(text);
} :
// Otherwise use our own trimming functionality
function (text) {
return text == null ?
"" :
(text + "").replace(rtrim, "");
},
// results is for internal usage only
makeArray: function (arr, results) {
var type,
ret = results || [];
if (arr != null) {
// The window, strings (and functions) also have 'length'
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
type = JQXLite.type(arr);
if (arr.length == null || type === "string" || type === "function" || type === "regexp" || JQXLite.isWindow(arr)) {
core_push.call(ret, arr);
} else {
JQXLite.merge(ret, arr);
}
}
return ret;
},
inArray: function (elem, arr, i) {
var len;
if (arr) {
if (core_indexOf) {
return core_indexOf.call(arr, elem, i);
}
len = arr.length;
i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
for (; i < len; i++) {
// Skip accessing in sparse arrays
if (i in arr && arr[i] === elem) {
return i;
}
}
}
return -1;
},
merge: function (first, second) {
var l = second.length,
i = first.length,
j = 0;
if (typeof l === "number") {
for (; j < l; j++) {
first[i++] = second[j];
}
} else {
while (second[j] !== undefined) {
first[i++] = second[j++];
}
}
first.length = i;
return first;
},
grep: function (elems, callback, inv) {
var retVal,
ret = [],
i = 0,
length = elems.length;
inv = !!inv;
// Go through the array, only saving the items
// that pass the validator function
for (; i < length; i++) {
retVal = !!callback(elems[i], i);
if (inv !== retVal) {
ret.push(elems[i]);
}
}
return ret;
},
// arg is for internal usage only
map: function (elems, callback, arg) {
var value, key,
ret = [],
i = 0,
length = elems.length,
// jqx objects are treated as arrays
isArray = elems instanceof JQXLite || length !== undefined && typeof length === "number" && ((length > 0 && elems[0] && elems[length - 1]) || length === 0 || JQXLite.isArray(elems));
// Go through the array, translating each of the items to their
if (isArray) {
for (; i < length; i++) {
value = callback(elems[i], i, arg);
if (value != null) {
ret[ret.length] = value;
}
}
// Go through every key on the object,
} else {
for (key in elems) {
value = callback(elems[key], key, arg);
if (value != null) {
ret[ret.length] = value;
}
}
}
// Flatten any nested arrays
return ret.concat.apply([], ret);
},
// A global GUID counter for objects
guid: 1,
// Bind a function to a context, optionally partially applying any
// arguments.
proxy: function (fn, context) {
var tmp, args, proxy;
if (typeof context === "string") {
tmp = fn[context];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if (!JQXLite.isFunction(fn)) {
return undefined;
}
// Simulated bind
args = core_slice.call(arguments, 2);
proxy = function () {
return fn.apply(context, args.concat(core_slice.call(arguments)));
};
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || JQXLite.guid++;
return proxy;
},
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
access: function (elems, fn, key, value, chainable, emptyGet, pass) {
var exec,
bulk = key == null,
i = 0,
length = elems.length;
// Sets many values
if (key && typeof key === "object") {
for (i in key) {
JQXLite.access(elems, fn, i, key[i], 1, emptyGet, value);
}
chainable = 1;
// Sets one value
} else if (value !== undefined) {
// Optionally, function values get executed if exec is true
exec = pass === undefined && JQXLite.isFunction(value);
if (bulk) {
// Bulk operations only iterate when executing function values
if (exec) {
exec = fn;
fn = function (elem, key, value) {
return exec.call(JQXLite(elem), value);
};
// Otherwise they run against the entire set
} else {
fn.call(elems, value);
fn = null;
}
}
if (fn) {
for (; i < length; i++) {
fn(elems[i], key, exec ? value.call(elems[i], i, fn(elems[i], key)) : value, pass);
}
}
chainable = 1;
}
return chainable ?
elems :
// Gets
bulk ?
fn.call(elems) :
length ? fn(elems[0], key) : emptyGet;
},
now: function () {
return (new Date()).getTime();
}
});
JQXLite.ready.promise = function (obj) {
if (!readyList) {
readyList = JQXLite.Deferred();
// Catch cases where $(document).ready() is called after the browser event has already occurred.
// we once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jqx.com/ticket/12282#comment:15
if (document.readyState === "complete") {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout(JQXLite.ready, 1);
// Standards-based browsers support DOMContentLoaded
} else if (document.addEventListener) {
// Use the handy event callback
document.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
// A fallback to window.onload, that will always work
window.addEventListener("load", JQXLite.ready, fal