diff --git a/README.md b/README.md
index 6fc7aff..d365d51 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ Uses [QR Code Generator](http://www.d-project.com/qrcode/index.html) (MIT). Kudo
* some fixes
* adds image support for fore- and background
+* adds label and image positioning
* updates build process
diff --git a/makefile.js b/makefile.js
index e13fbe5..aafb68f 100644
--- a/makefile.js
+++ b/makefile.js
@@ -2,152 +2,111 @@
'use strict';
-var path = require('path'),
- child_process = require('child_process');
-
-
-var pkg = require('./package.json'),
-
- root = path.resolve(__dirname),
- src = path.resolve(root, 'src'),
- build = path.resolve(root, 'build'),
-
- jshint = {
- // Enforcing Options
- bitwise: true,
- curly: true,
- eqeqeq: true,
- forin: true,
- latedef: true,
- newcap: true,
- noempty: true,
- plusplus: true,
- trailing: true,
- undef: true,
-
- // Environments
- browser: true,
-
- // Globals
- predef: [
- "jQuery", "qrcode"
- ]
- },
-
- mapperSrc = function (blob) {
-
- return blob.source.replace(src, build);
- },
-
- mapperRoot = function (blob) {
+module.exports = function (make) {
- return blob.source.replace(root, build);
- };
+ var path = require('path'),
+ pkg = require('./package.json'),
-module.exports = function (make) {
-
- var Event = make.Event,
$ = make.fQuery,
- moment = make.moment,
- stamp, replacements;
+
+ root = path.resolve(__dirname),
+ src = path.join(root, 'src'),
+ build = path.join(root, 'build');
- make.version('>=0.8.1');
+ make.version('>=0.10.0');
make.defaults('release');
make.before(function () {
- stamp = moment();
+ var moment = make.moment();
- replacements = {
+ make.env = {
pkg: pkg,
- stamp: stamp.format('YYYY-MM-DD HH:mm:ss')
+ stamp: moment.format('YYYY-MM-DD HH:mm:ss')
};
- Event.info({ method: 'before', message: pkg.version + ' ' + replacements.stamp });
+ $.info({ method: 'before', message: pkg.version + ' ' + make.env.stamp });
});
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
- if (!/-dev$/.test(pkg.version)) {
+ if (!/\+$/.test(pkg.version)) {
done();
return;
}
$.git(root, function (err, result) {
- pkg.version += '-' + result.revListOriginMasterHead.length + '-' + result.revParseHead.slice(0, 7);
- Event.info({
- method: 'check-version',
- message: 'version set to ' + pkg.version
- });
+ pkg.version += result.buildSuffix;
+ $.info({ method: 'check-version', message: 'version set to ' + pkg.version });
done();
});
});
- make.target('clean', [], 'delete build folder')
- .sync(function () {
-
- $.rmfr($.I_AM_SURE, build);
- });
+ make.target('clean', [], 'delete build folder').sync(function () {
+ $.DELETE(build);
+ });
- make.target('lint', [], 'lint all JavaScript files with JSHint')
- .sync(function () {
- $(src + ': jquery.qrcode.js')
- .jshint(jshint);
- });
+ make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
+
+ var options = {
+ // Enforcing Options
+ bitwise: true,
+ curly: true,
+ eqeqeq: true,
+ forin: true,
+ latedef: true,
+ newcap: true,
+ noempty: true,
+ plusplus: true,
+ trailing: true,
+ undef: true,
+
+ // Environments
+ browser: true
+ },
+ global = {
+ 'jQuery': true,
+ 'qrcode': true
+ };
+
+ $(src + ': jquery.qrcode.js, demo/scripts.js').log(-3)
+ .jshint(options, global);
+ });
- make.target('build', ['check-version'], 'build all updated files')
- .sync(function () {
+ make.target('build', ['check-version'], 'build all updated files').sync(function () {
- var scriptName = pkg.name;
+ $(src + ': jquery.qrcode.js')
+ .includify()
+ .handlebars(make.env)
+ .WRITE($.map.p(src, build).s('.js', '-' + pkg.version + '.js'))
+ .uglifyjs()
+ .WRITE($.map.p(src, build).s('.js', '-' + pkg.version + '.min.js'));
- $(src + '/demo/*')
- .handlebars(replacements)
- .write($.OVERWRITE, mapperSrc);
+ $(src + ': **, ! *.js')
+ .handlebars(make.env)
+ .WRITE($.map.p(src, build));
- $(src + ': ' + scriptName + '.js')
- .includify()
- .handlebars(replacements)
- .write($.OVERWRITE, path.join(build, scriptName + '-' + pkg.version + '.js'))
- .write($.OVERWRITE, path.join(build, 'demo', scriptName + '.js'))
- .uglifyjs()
- .write($.OVERWRITE, path.join(build, scriptName + '-' + pkg.version + '.min.js'));
+ $(root + ': README*, LICENSE*')
+ .handlebars(make.env)
+ .WRITE($.map.p(root, build));
+ });
- $(root + ': README*, LICENSE*')
- .write($.OVERWRITE, mapperRoot);
- });
+ make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) {
- make.target('release', ['clean', 'build'], 'create a zipball')
- .async(function (done, fail) {
-
- var target = path.join(build, pkg.name + '-' + pkg.version + '.zip'),
- cmd = 'zip',
- args = ['-ro', target, '.'],
- options = { cwd: build },
- proc = child_process.spawn(cmd, args, options);
-
- Event.info({ method: 'exec', message: cmd + ' ' + args.join(' ') });
-
- proc.stderr.on('data', function (data) {
- process.stderr.write(data);
- });
- proc.on('exit', function (code) {
- if (code) {
- Event.error({ method: 'exec', message: cmd + ' exit code ' + code });
- fail();
- } else {
- Event.ok({ method: 'exec', message: 'created zipball ' + target });
- done();
- }
- });
+ $(build + ': **').shzip({
+ target: path.join(build, pkg.name + '-' + pkg.version + '.zip'),
+ dir: build,
+ callback: done
});
+ });
};
diff --git a/package.json b/package.json
index 8764874..6a96491 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,13 @@
{
- "name": "jquery.qrcode",
- "displayName": "jQuery.qrcode",
- "version": "0.6.0-dev"
+ "name": "jquery.qrcode",
+ "displayName": "jQuery.qrcode",
+ "version": "0.6.0+",
+ "description": "generate QR codes dynamically",
+ "url": "http://larsjung.de/qrcode/",
+ "author": "Lars Jung",
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/lrsjng/jQuery.qrcode.git"
+ }
}
diff --git a/src/demo/index.html b/src/demo/index.html
index 957b90b..27902fa 100644
--- a/src/demo/index.html
+++ b/src/demo/index.html
@@ -15,7 +15,7 @@
-
+
diff --git a/src/demo/scripts.js b/src/demo/scripts.js
index 126069c..dc0ceed 100644
--- a/src/demo/scripts.js
+++ b/src/demo/scripts.js
@@ -1,99 +1,103 @@
-var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
+(function ($) {
+ 'use strict';
- guiValuePairs = [
- ["size", "px"],
- ["minversion", ""],
- ["quiet", "modules"],
- ["radius", "%"],
- ["msize", "%"],
- ["mposx", "%"],
- ["mposy", "%"]
- ],
+ var isOpera = Object.prototype.toString.call(window.opera) === '[object Opera]',
- updateGui = function () {
+ guiValuePairs = [
+ ["size", "px"],
+ ["minversion", ""],
+ ["quiet", " modules"],
+ ["radius", "%"],
+ ["msize", "%"],
+ ["mposx", "%"],
+ ["mposy", "%"]
+ ],
- for (var idx in guiValuePairs) {
+ updateGui = function () {
- var pair = guiValuePairs[idx],
- $label = $('label[for="' + pair[0] + '"]');
+ $.each(guiValuePairs, function (idx, pair) {
- $label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
- }
- },
+ var $label = $('label[for="' + pair[0] + '"]');
- updateQrCode = function () {
+ $label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
+ });
+ },
- var options = {
- render: $("#render").val(),
- ecLevel: $("#eclevel").val(),
- minVersion: parseInt($("#minversion").val(), 10),
+ updateQrCode = function () {
- fill: $("#fill").val(),
- background: $("#background").val(),
- // fill: $("#img-buffer")[0],
+ var options = {
+ render: $("#render").val(),
+ ecLevel: $("#eclevel").val(),
+ minVersion: parseInt($("#minversion").val(), 10),
- text: $("#text").val(),
- size: parseInt($("#size").val(), 10),
- radius: parseInt($("#radius").val(), 10) * 0.01,
- quiet: parseInt($("#quiet").val(), 10),
+ fill: $("#fill").val(),
+ background: $("#background").val(),
+ // fill: $("#img-buffer")[0],
- mode: parseInt($("#mode").val(), 10),
+ text: $("#text").val(),
+ size: parseInt($("#size").val(), 10),
+ radius: parseInt($("#radius").val(), 10) * 0.01,
+ quiet: parseInt($("#quiet").val(), 10),
- mSize: parseInt($("#msize").val(), 10) * 0.01,
- mPosX: parseInt($("#mposx").val(), 10) * 0.01,
- mPosY: parseInt($("#mposy").val(), 10) * 0.01,
+ mode: parseInt($("#mode").val(), 10),
- label: $("#label").val(),
- fontname: $("#font").val(),
- fontcolor: $("#fontcolor").val(),
+ mSize: parseInt($("#msize").val(), 10) * 0.01,
+ mPosX: parseInt($("#mposx").val(), 10) * 0.01,
+ mPosY: parseInt($("#mposy").val(), 10) * 0.01,
- image: $("#img-buffer")[0]
- };
+ label: $("#label").val(),
+ fontname: $("#font").val(),
+ fontcolor: $("#fontcolor").val(),
- $("#container").empty().qrcode(options);
- },
+ image: $("#img-buffer")[0]
+ };
- update = function () {
+ $("#container").empty().qrcode(options);
+ },
- updateGui();
- updateQrCode();
- },
+ update = function () {
- onImageInput = function () {
+ updateGui();
+ updateQrCode();
+ },
- var input = $("#image")[0];
+ onImageInput = function () {
- if (input.files && input.files[0]) {
+ var input = $("#image")[0];
- var reader = new FileReader();
+ if (input.files && input.files[0]) {
- reader.onload = function (event) {
- $("#img-buffer").attr("src", event.target.result);
- $("#mode").val("4");
- setTimeout(update, 250);
- };
- reader.readAsDataURL(input.files[0]);
- }
- },
+ var reader = new FileReader();
+
+ reader.onload = function (event) {
+ $("#img-buffer").attr("src", event.target.result);
+ $("#mode").val("4");
+ setTimeout(update, 250);
+ };
+ reader.readAsDataURL(input.files[0]);
+ }
+ },
- download = function (event) {
+ download = function (event) {
- var data = $("#container canvas")[0].toDataURL('image/png');
- $("#download").attr("href", data);
- };
+ var data = $("#container canvas")[0].toDataURL('image/png');
+ $("#download").attr("href", data);
+ };
-$(function () {
+ $(function () {
+
+ if (isOpera) {
+ $('html').addClass('opera');
+ $('#radius').prop('disabled', true);
+ }
- if (isOpera) {
- $('html').addClass('opera');
- $('#radius').prop('disabled', true);
- }
+ $("#download").on("click", download);
+ $("#image").on('change', onImageInput);
+ $("input, textarea, select").on("input change", update);
+ $(window).load(update);
+ update();
+ });
- $("#download").on("click", download);
- $("#image").on('change', onImageInput);
- $("input, textarea, select").on("input change", update);
- $(window).load(update);
- update();
-});
+}(jQuery));
diff --git a/src/demo/styles.css b/src/demo/styles.css
index b75470b..e36876c 100644
--- a/src/demo/styles.css
+++ b/src/demo/styles.css
@@ -101,10 +101,7 @@ input, textarea, select {
input[type="range"] {
-webkit-appearance: none;
-/* height: 8px;
- margin-top: 4px;
- margin-bottom: 4px;
-*/ cursor: pointer;
+ cursor: pointer;
}
input::-webkit-slider-thumb {
-webkit-appearance: none;