chore: cleanup, node14 and new admin default

This commit is contained in:
Taranto 2020-10-16 17:26:30 +01:00 committed by Josh Harvey
parent c7c18633d7
commit 89bb9a8f25
244 changed files with 3957 additions and 39487 deletions

View file

@ -0,0 +1,40 @@
{
"name": "qr-code",
"version": "0.1.8",
"homepage": "https://github.com/educastellano/qr-code",
"authors": [
"Eduard Castellano <educastellano08@gmail.com>"
],
"description": "Web Component for generating QR codes",
"main": "src/qr-code.js",
"keywords": [
"qr",
"qrcode",
"qr-code",
"webcomponent",
"customelement",
"web-components"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"demo"
],
"dependencies": {
"qrjs": "~0.1.2"
},
"_release": "0.1.8",
"_resolution": {
"type": "version",
"tag": "v0.1.8",
"commit": "28a413834c62d8ec7f5b3f3005fe2ee78e47e647"
},
"_source": "https://github.com/educastellano/qr-code.git",
"_target": "^0.1.8",
"_originalSource": "webcomponent-qr-code",
"_direct": true
}

View file

@ -0,0 +1,94 @@
# &lt;qr-code&gt;
Web Component for generating QR Codes, using (a [fork](https://github.com/educastellano/qr.js) of) [qr.js](https://github.com/lifthrasiir/qr.js) lib.
> Maintained by [Eduard Castellano](https://github.com/educastellano).
## Demo
> [Check it live](http://educastellano.github.io/qr-code/demo).
## Usage
* **NPM and Browserify** ([polyfill](https://github.com/WebComponents/webcomponentsjs) and the component):
Install:
```sh
npm install webcomponents.js
npm install webcomponent-qr-code
```
Import:
```js
require('webcomponents.js');
require('webcomponent-qr-code');
```
* **Bower** ([polyfill](https://github.com/WebComponents/webcomponentsjs), [qr.js](https://github.com/educastellano/qr.js) and the component):
Install:
```sh
bower install webcomponentsjs
bower install webcomponent-qr-code
```
Import:
```html
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="bower_components/qrjs/qr.js"></script>
<script src="bower_components/webcomponent-qr-code/src/qr-code.js"></script>
```
> You can also import the component with [HTML Imports](http://w3c.github.io/webcomponents/spec/imports/), but you still need to import the polyfill and the qr.js lib separately:
>
> ```html
> <link rel="import" href="bower_components/webcomponent-qr-code/src/qr-code.html">
> ```
* **Start using it!**
```html
<qr-code data="hello world!"></qr-code>
```
## Options
Attribute | Options | Default | Description
--- | --- | --- | ---
`data` | *string* | `null` | The information encoded by the QR code.
`format` | `png`, `html`, `svg` | `png` | Format of the QR code rendered inside the component.
`modulesize` | *int* | `5` | Size of the modules in *pixels*.
`margin` | *int* | `4` | Margin of the QR code in *modules*.
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## History
* v0.1.7 April 11, 2015
* Support for SVG
* v0.1.6 April 10, 2015
* Default attributes
* qr.js removed and used as a dependency
* Available in NPM
* v0.1.1 March 31, 2015
* Framework-agnostic webcomponent (no use of Polymer)
* Available in Bower
* v0.0.1 September 18, 2013
* Started project using [boilerplate-element](https://github.com/customelements/boilerplate-element)
## License
[MIT License](http://opensource.org/licenses/MIT)

View file

@ -0,0 +1,30 @@
{
"name": "qr-code",
"version": "0.1.7",
"homepage": "https://github.com/educastellano/qr-code",
"authors": [
"Eduard Castellano <educastellano08@gmail.com>"
],
"description": "Web Component for generating QR codes",
"main": "src/qr-code.js",
"keywords": [
"qr",
"qrcode",
"qr-code",
"webcomponent",
"customelement",
"web-components"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"demo"
],
"dependencies": {
"qrjs": "~0.1.2"
}
}

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>&lt;qr-code&gt;</title>
</head>
<body>
<a href="demo">Demo here</a>
</body>
</html>

View file

@ -0,0 +1 @@
require('./src/qr-code.js')

View file

@ -0,0 +1,29 @@
{
"name": "webcomponent-qr-code",
"version": "0.1.8",
"description": "Web Component for generating QR codes",
"main": "qr-code.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/educastellano/qr-code.git"
},
"keywords": [
"qr",
"qrcode",
"qr-code",
"webcomponent",
"custom-element"
],
"author": "Eduard Castellano",
"license": "MIT",
"bugs": {
"url": "https://github.com/educastellano/qr-code/issues"
},
"homepage": "https://github.com/educastellano/qr-code",
"dependencies": {
"qrjs": "^0.1.2"
}
}

View file

@ -0,0 +1,56 @@
<polymer-element name="qr-code"
attributes="data format modulesize margin">
<script>
Polymer('qr-code', {
format: 'png',
dataChanged: function () {
this.generate();
},
generate: function () {
var options = {
modulesize: this.modulesize,
margin: this.margin === 0 ? -1 : this.margin
};
if (this.format === 'png') {
this.generatePNG(options);
}
else {
this.generateHTML(options);
}
},
generatePNG: function (options) {
var img;
try {
img = document.createElement('img');
img.src = QRCode.generatePNG(this.data, options);
this.clear();
this.appendChild(img);
}
catch (e) {
console.log('no canvas support');
}
},
generateHTML: function (options) {
var div = QRCode.generateHTML(this.data, options);
this.clear();
this.appendChild(div);
},
clear: function () {
var i;
for (i=0; i<this.children.length; i++) {
this.children[i].parentNode.removeChild(this.children[i]);
}
}
});
</script>
</polymer-element>

View file

@ -0,0 +1 @@
<script src="qr-code.js"></script>

View file

@ -0,0 +1,144 @@
'use strict';
(function(definition) {
if (typeof define === 'function' && define.amd) {
define(['QRCode'], definition);
} else if (typeof module === 'object' && module.exports) {
var QRCode = require('qrjs');
module.exports = definition(QRCode);
} else {
definition(window.QRCode);
}
})(function(QRCode) {
//
// Prototype
//
var proto = Object.create(HTMLElement.prototype, {
//
// Attributes
//
attrs: {
value: {
data: null,
format: 'png',
modulesize: 5,
margin: 4
}
},
defineAttributes: {
value: function () {
var attrs = Object.keys(this.attrs),
attr;
for (var i=0; i<attrs.length; i++) {
attr = attrs[i];
(function (attr) {
Object.defineProperty(this, attr, {
get: function () {
var value = this.getAttribute(attr);
return value === null ? this.attrs[attr] : value;
},
set: function (value) {
this.setAttribute(attr, value);
}
});
}.bind(this))(attr);
}
}
},
//
// LifeCycle Callbacks
//
createdCallback: {
value: function () {
this.createShadowRoot();
this.defineAttributes();
this.generate();
}
},
attributeChangedCallback: {
value: function (attrName, oldVal, newVal) {
var fn = this[attrName+'Changed'];
if (fn && typeof fn === 'function') {
fn.call(this, oldVal, newVal);
}
this.generate();
}
},
//
// Methods
//
getOptions: {
value: function () {
var modulesize = this.modulesize,
margin = this.margin;
return {
modulesize: modulesize !== null ? parseInt(modulesize) : modulesize,
margin: margin !== null ? parseInt(margin) : margin
};
}
},
generate: {
value: function () {
if (this.data !== null) {
if (this.format === 'png') {
this.generatePNG();
}
else if (this.format === 'html') {
this.generateHTML();
}
else if (this.format === 'svg') {
this.generateSVG();
}
else {
this.shadowRoot.innerHTML = '<div>qr-code: '+ this.format +' not supported!</div>'
}
}
else {
this.shadowRoot.innerHTML = '<div>qr-code: no data!</div>'
}
}
},
generatePNG: {
value: function () {
try {
var img = document.createElement('img');
img.src = QRCode.generatePNG(this.data, this.getOptions());
this.clear();
this.shadowRoot.appendChild(img);
}
catch (e) {
this.shadowRoot.innerHTML = '<div>qr-code: no canvas support!</div>'
}
}
},
generateHTML: {
value: function () {
var div = QRCode.generateHTML(this.data, this.getOptions());
this.clear();
this.shadowRoot.appendChild(div);
}
},
generateSVG: {
value: function () {
var div = QRCode.generateSVG(this.data, this.getOptions());
this.clear();
this.shadowRoot.appendChild(div);
}
},
clear: {
value: function () {
while (this.shadowRoot.lastChild) {
this.shadowRoot.removeChild(this.shadowRoot.lastChild);
}
}
}
});
//
// Register
//
document.registerElement('qr-code', {
prototype: proto
});
});