forked from SuperiorJT/angular2-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 4
/
angular2-qrcode.js
130 lines (130 loc) · 4.3 KB
/
angular2-qrcode.js
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
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { NgModule, Component, Input, ElementRef } from '@angular/core';
import * as QRious from 'qrious';
var QRCodeComponent = (function () {
function QRCodeComponent(elementRef) {
this.elementRef = elementRef;
this.background = 'white';
this.backgroundAlpha = 1.0;
this.foreground = 'black';
this.foregroundAlpha = 1.0;
this.level = 'L';
this.mime = 'image/png';
this.padding = null;
this.size = 100;
this.value = '';
this.canvas = false;
}
QRCodeComponent.prototype.ngOnChanges = function (changes) {
if ('background' in changes ||
'backgroundAlpha' in changes ||
'foreground' in changes ||
'foregroundAlpha' in changes ||
'level' in changes ||
'mime' in changes ||
'padding' in changes ||
'size' in changes ||
'value' in changes ||
'canvas' in changes) {
this.generate();
}
};
QRCodeComponent.prototype.generate = function () {
try {
var el = this.elementRef.nativeElement;
el.innerHTML = '';
var qr = new QRious({
background: this.background,
backgroundAlpha: this.backgroundAlpha,
foreground: this.foreground,
foregroundAlpha: this.foregroundAlpha,
level: this.level,
mime: this.mime,
padding: this.padding,
size: this.size,
value: this.value
});
if (this.canvas) {
el.appendChild(qr.canvas);
}
else {
el.appendChild(qr.image);
}
}
catch (e) {
console.error("Could not generate QR Code: " + e.message);
}
};
return QRCodeComponent;
}());
__decorate([
Input(),
__metadata("design:type", String)
], QRCodeComponent.prototype, "background", void 0);
__decorate([
Input(),
__metadata("design:type", Number)
], QRCodeComponent.prototype, "backgroundAlpha", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QRCodeComponent.prototype, "foreground", void 0);
__decorate([
Input(),
__metadata("design:type", Number)
], QRCodeComponent.prototype, "foregroundAlpha", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QRCodeComponent.prototype, "level", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QRCodeComponent.prototype, "mime", void 0);
__decorate([
Input(),
__metadata("design:type", Number)
], QRCodeComponent.prototype, "padding", void 0);
__decorate([
Input(),
__metadata("design:type", Number)
], QRCodeComponent.prototype, "size", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], QRCodeComponent.prototype, "value", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], QRCodeComponent.prototype, "canvas", void 0);
QRCodeComponent = __decorate([
Component({
moduleId: 'module.id',
selector: 'qr-code',
template: ""
}),
__metadata("design:paramtypes", [ElementRef])
], QRCodeComponent);
export { QRCodeComponent };
var QRCodeModule = (function () {
function QRCodeModule() {
}
return QRCodeModule;
}());
QRCodeModule = __decorate([
NgModule({
exports: [QRCodeComponent],
declarations: [QRCodeComponent],
entryComponents: [QRCodeComponent]
})
], QRCodeModule);
export { QRCodeModule };
//# sourceMappingURL=angular2-qrcode.js.map