diff --git a/.eslintrc.json b/.eslintrc.json index 33ca4f3..c7c2dad 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": "skelp/v3/es6", + "extends": "notninja/es6", "env": { "browser": true, "node": true @@ -19,8 +19,6 @@ { "args": "none" } - ], - "prefer-reflect": "off", - "sort-keys": "off" + ] } } diff --git a/.travis.yml b/.travis.yml index ceaef54..261c239 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: false language: node_js node_js: - "0.10" diff --git a/CHANGES.md b/CHANGES.md index 5bf3ef3..55b5aef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,11 @@ +## Version 2.3.0, 2017.05.31 + +* Enable setting of multiple properties at once resulting in a single re-render [#69](https://github.com/neocotic/qrious/issues/69) +* Deferring or avoiding ImageRenderer [#71](https://github.com/neocotic/qrious/issues/71) +* Switch to container-based Travis builds for faster boot times [#73](https://github.com/neocotic/qrious/issues/73) +* Change code style to be more contributor-friendly [#75](https://github.com/neocotic/qrious/issues/75) +* Improve download links in README [#76](https://github.com/neocotic/qrious/issues/76) + ## Version 2.2.0, 2016.10.30 * Add `backgroundAlpha` and `foregroundAlpha` options to control transparency [#63](https://github.com/neocotic/qrious/issues/63) diff --git a/Gruntfile.js b/Gruntfile.js index 05a3342..7d26356 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,6 @@ /* * QRious - * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2017 Alasdair Mercer * Copyright (C) 2010 Tom Zerucha * * This program is free software: you can redistribute it and/or modify @@ -17,12 +17,14 @@ * along with this program. If not, see . */ +'use strict'; + module.exports = function(grunt) { - var babel - var commonjs - var nodeResolve - var semver = require('semver') - var uglify + var babel; + var commonjs; + var nodeResolve; + var semver = require('semver'); + var uglify; var bannerLarge = [ '/*', @@ -43,12 +45,12 @@ module.exports = function(grunt) { ' * You should have received a copy of the GNU General Public License', ' * along with this program. If not, see .', ' */' - ].join('\n') + ].join('\n'); var bannerSmall = [ '/*! QRious v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | GPL v3 License', 'Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License', '*/' - ].join('\n') + ].join('\n'); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), @@ -59,19 +61,19 @@ module.exports = function(grunt) { tasks: [ 'test' ] } } - }) + }); - var buildTasks = [ 'compile' ] - var compileTasks = [] - var testTasks = [ 'compile' ] + var buildTasks = [ 'compile' ]; + var compileTasks = []; + var testTasks = [ 'compile' ]; if (semver.satisfies(process.version, '>=0.12')) { - babel = require('rollup-plugin-babel') - commonjs = require('rollup-plugin-commonjs') - nodeResolve = require('rollup-plugin-node-resolve') - uglify = require('rollup-plugin-uglify') + babel = require('rollup-plugin-babel'); + commonjs = require('rollup-plugin-commonjs'); + nodeResolve = require('rollup-plugin-node-resolve'); + uglify = require('rollup-plugin-uglify'); - compileTasks.push('clean', 'rollup') + compileTasks.push('clean', 'rollup'); grunt.config.merge({ clean: { @@ -90,15 +92,14 @@ module.exports = function(grunt) { return [ nodeResolve({ jsnext: true, - main: true, - skip: [ 'canvas' ] + main: true }), commonjs(), babel({ exclude: [ 'node_modules/**' ], runtimeHelpers: true }) - ] + ]; } }, files: { @@ -124,7 +125,7 @@ module.exports = function(grunt) { exclude: [ 'node_modules/**' ], runtimeHelpers: true }) - ] + ]; } }, files: { @@ -153,11 +154,11 @@ module.exports = function(grunt) { uglify({ output: { comments: function(node, comment) { - return comment.type === 'comment2' && /^\!/.test(comment.value) + return comment.type === 'comment2' && /^\!/.test(comment.value); } } }) - ] + ]; } }, files: { @@ -165,30 +166,30 @@ module.exports = function(grunt) { } } } - }) + }); - grunt.loadNpmTasks('grunt-contrib-clean') - grunt.loadNpmTasks('grunt-rollup') + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-rollup'); } else { - grunt.log.writeln('"clean" and "rollup" tasks are disabled because Node.js version is <0.12! Please consider upgrading Node.js...') + grunt.log.writeln('"clean" and "rollup" tasks are disabled because Node.js version is <0.12! Please consider upgrading Node.js...'); } if (semver.satisfies(process.version, '>=4')) { - compileTasks.unshift('eslint') + compileTasks.unshift('eslint'); grunt.config.set('eslint', { target: [ 'src/**/*.js' ] - }) + }); - grunt.loadNpmTasks('grunt-eslint') + grunt.loadNpmTasks('grunt-eslint'); } else { - grunt.log.writeln('"eslint" task is disabled because Node.js version is <4! Please consider upgrading Node.js...') + grunt.log.writeln('"eslint" task is disabled because Node.js version is <4! Please consider upgrading Node.js...'); } - grunt.loadNpmTasks('grunt-contrib-watch') + grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.registerTask('default', [ 'build' ]) - grunt.registerTask('build', buildTasks) - grunt.registerTask('compile', compileTasks) - grunt.registerTask('test', testTasks) -} + grunt.registerTask('default', [ 'build' ]); + grunt.registerTask('build', buildTasks); + grunt.registerTask('compile', compileTasks); + grunt.registerTask('test', testTasks); +}; diff --git a/LICENSE.md b/LICENSE.md index 7ac3863..c275508 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,5 +1,5 @@ QRious -Copyright (C) 2016 Alasdair Mercer +Copyright (C) 2017 Alasdair Mercer Copyright (C) 2010 Tom Zerucha This program is free software: you can redistribute it and/or modify diff --git a/README.md b/README.md index 416b95b..eed4b68 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ [QRious](https://github.com/neocotic/qrious) is a pure JavaScript library for generating QR codes using HTML5 canvas. [![Chat](https://img.shields.io/gitter/room/neocotic/qrious.svg?style=flat-square)](https://gitter.im/neocotic/qrious) -[![Build](https://img.shields.io/travis/neocotic/qrious/develop.svg?style=flat-square)](https://travis-ci.org/neocotic/qrious) -[![Dependency Status](https://img.shields.io/david/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious) -[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious#info=devDependencies) +[![Build Status](https://img.shields.io/travis/neocotic/qrious/develop.svg?style=flat-square)](https://travis-ci.org/neocotic/qrious) +[![Optional Dependency Status](https://img.shields.io/david/optional/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=optional) +[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=dev) [![License](https://img.shields.io/npm/l/qrious.svg?style=flat-square)](https://github.com/neocotic/qrious/blob/master/LICENSE.md) [![Release](https://img.shields.io/npm/v/qrious.svg?style=flat-square)](https://www.npmjs.com/package/qrious) @@ -38,8 +38,8 @@ you want to install that way instead of using `npm`. If you want to simply download the file to be used in the browser you can find them below: -* [Development Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.js) -* [Production Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.min.js) +* [Development Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js) (123kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js.map)) +* [Production Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js) (37kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js.map)) ### Node.js Dependencies @@ -75,8 +75,8 @@ In the browser: const qr = new QRious({ element: document.getElementById('qr'), value: 'https://github.com/neocotic/qrious' - }) - })() + }); + })(); @@ -85,18 +85,18 @@ In the browser: In Node.js: ``` javascript -const express = require('express') -const QRious = require('qrious') +const express = require('express'); +const QRious = require('qrious'); -const app = express() +const app = express(); app.get('/qr', (req, res) => { - const qr = new QRious({ value: 'https://github.com/neocotic/qrious' }) + const qr = new QRious({ value: 'https://github.com/neocotic/qrious' }); - res.end(new Buffer(qr.toDataURL(), 'base64')) -}) + res.end(new Buffer(qr.toDataURL(), 'base64')); +}); -app.listen(3000) +app.listen(3000); ``` Open up `demo.html` in your browser to play around a bit. @@ -119,30 +119,48 @@ using the following fields on your instance: | value | String | Value encoded within the QR code | `""` | ``` javascript -const qr = new QRious() -qr.background = '#000' -qr.backgroundAlpha = 0.8 -qr.foreground = '#fff' -qr.foregroundAlpha = 0.8 -qr.level = 'H' -qr.padding = 25 -qr.size = 500 -qr.value = 'https://github.com/neocotic/qrious' +const qr = new QRious(); +qr.background = 'green'; +qr.backgroundAlpha = 0.8; +qr.foreground = 'blue'; +qr.foregroundAlpha = 0.8; +qr.level = 'H'; +qr.padding = 25; +qr.size = 500; +qr.value = 'https://github.com/neocotic/qrious'; +``` + +The QR code will automatically update when you change one of these fields, so be wary when you plan on changing lots of +fields at the same time. You probably want to make a single call to `set(options)` instead as it will only update the QR +code once: + +``` javascript +const qr = new QRious(); +qr.set({ + background: 'green', + backgroundAlpha: 0.8, + foreground: 'blue', + foregroundAlpha: 0.8, + level: 'H', + padding: 25, + size: 500, + value: 'https://github.com/neocotic/qrious' +}); ``` These can also be passed as options to the constructor itself: ``` javascript const qr = new QRious({ - background: '#000', + background: 'green', backgroundAlpha: 0.8, - foreground: '#fff', + foreground: 'blue', foregroundAlpha: 0.8, level: 'H', padding: 25, size: 500, value: 'https://github.com/neocotic/qrious' -}) +}); ``` You can also pass in an `element` option to the constructor which can be used to generate the QR code using an existing @@ -154,21 +172,21 @@ for both if no `element` is specified, which means that they can be appeneded to const qr = new QRious({ element: document.querySelector('canvas'), value: 'https://github.com/neocotic/qrious' -}) +}); -qr.canvas.parentNode.appendChild(qr.image) +qr.canvas.parentNode.appendChild(qr.image); ``` A reference to the `QRious` instance is also stored on both of the elements for convenience. ``` javascript -const canvas = document.querySelector('canvas') +const canvas = document.querySelector('canvas'); const qr = new QRious({ element: canvas, value: 'https://github.com/neocotic/qrious' -}) +}); -console.log(qr === canvas.qrious) +qr === canvas.qrious; //=> true ``` @@ -180,11 +198,11 @@ passed to the constructor as an option or the default value for the `mime` optio ``` javascript const qr = new QRious({ value: 'https://github.com/neocotic/qrious' -}) +}); -console.log(qr.toDataURL()) +qr.toDataURL(); //=> "data:image/png;base64,iVBOR...AIpqDnseH86KAAAAAElFTkSuQmCC" -console.log(qr.toDataURL('image/jpeg')) +qr.toDataURL('image/jpeg'); //=> "data:image/jpeg;base64,/9j/...xqAqIqgKFAAAAAq3RRQAUUUUAf/Z" ``` @@ -193,8 +211,8 @@ console.log(qr.toDataURL('image/jpeg')) The current version of `QRious`. ``` javascript -console.log(QRious.VERSION) -//=> "2.2.0" +QRious.VERSION; +//=> "2.3.0" ``` ## Migrating from v1 @@ -223,7 +241,7 @@ A list of QRious contributors can be found in [AUTHORS.md](https://github.com/ne ## License -Copyright © 2016 Alasdair Mercer +Copyright © 2017 Alasdair Mercer Copyright © 2010 Tom Zerucha See [LICENSE.md](https://github.com/neocotic/qrious/blob/master/LICENSE.md) for more information on our GPLv3 license. diff --git a/bower.json b/bower.json index 8826f38..1ad975e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "qrious", - "version": "2.2.0", + "version": "2.3.0", "description": "Library for QR code generation using canvas", "homepage": "https://github.com/neocotic/qrious", "authors": [ diff --git a/demo.html b/demo.html index cf50728..7f35ab9 100644 --- a/demo.html +++ b/demo.html @@ -1,7 +1,7 @@