Updates demo.

This commit is contained in:
Lars Jung
2013-08-17 21:13:59 +02:00
parent 974002f950
commit ceac699d47
6 changed files with 183 additions and 214 deletions
+1
View File
@@ -15,6 +15,7 @@ Uses [QR Code Generator](http://www.d-project.com/qrcode/index.html) (MIT). Kudo
* some fixes * some fixes
* adds image support for fore- and background * adds image support for fore- and background
* adds label and image positioning
* updates build process * updates build process
+71 -112
View File
@@ -2,17 +2,61 @@
'use strict'; 'use strict';
var path = require('path'), module.exports = function (make) {
child_process = require('child_process');
var pkg = require('./package.json'), var path = require('path'),
pkg = require('./package.json'),
$ = make.fQuery,
root = path.resolve(__dirname), root = path.resolve(__dirname),
src = path.resolve(root, 'src'), src = path.join(root, 'src'),
build = path.resolve(root, 'build'), build = path.join(root, 'build');
jshint = {
make.version('>=0.10.0');
make.defaults('release');
make.before(function () {
var moment = make.moment();
make.env = {
pkg: pkg,
stamp: moment.format('YYYY-MM-DD HH:mm:ss')
};
$.info({ method: 'before', message: pkg.version + ' ' + make.env.stamp });
});
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
if (!/\+$/.test(pkg.version)) {
done();
return;
}
$.git(root, function (err, result) {
pkg.version += result.buildSuffix;
$.info({ method: 'check-version', message: 'version set to ' + pkg.version });
done();
});
});
make.target('clean', [], 'delete build folder').sync(function () {
$.DELETE(build);
});
make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
var options = {
// Enforcing Options // Enforcing Options
bitwise: true, bitwise: true,
curly: true, curly: true,
@@ -26,128 +70,43 @@ var pkg = require('./package.json'),
undef: true, undef: true,
// Environments // Environments
browser: true, browser: true
// Globals
predef: [
"jQuery", "qrcode"
]
}, },
global = {
mapperSrc = function (blob) { 'jQuery': true,
'qrcode': true
return blob.source.replace(src, build);
},
mapperRoot = function (blob) {
return blob.source.replace(root, build);
}; };
$(src + ': jquery.qrcode.js, demo/scripts.js').log(-3)
module.exports = function (make) { .jshint(options, global);
var Event = make.Event,
$ = make.fQuery,
moment = make.moment,
stamp, replacements;
make.version('>=0.8.1');
make.defaults('release');
make.before(function () {
stamp = moment();
replacements = {
pkg: pkg,
stamp: stamp.format('YYYY-MM-DD HH:mm:ss')
};
Event.info({ method: 'before', message: pkg.version + ' ' + replacements.stamp });
}); });
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) { make.target('build', ['check-version'], 'build all updated files').sync(function () {
if (!/-dev$/.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
});
done();
});
});
make.target('clean', [], 'delete build folder')
.sync(function () {
$.rmfr($.I_AM_SURE, build);
});
make.target('lint', [], 'lint all JavaScript files with JSHint')
.sync(function () {
$(src + ': jquery.qrcode.js') $(src + ': jquery.qrcode.js')
.jshint(jshint);
});
make.target('build', ['check-version'], 'build all updated files')
.sync(function () {
var scriptName = pkg.name;
$(src + '/demo/*')
.handlebars(replacements)
.write($.OVERWRITE, mapperSrc);
$(src + ': ' + scriptName + '.js')
.includify() .includify()
.handlebars(replacements) .handlebars(make.env)
.write($.OVERWRITE, path.join(build, scriptName + '-' + pkg.version + '.js')) .WRITE($.map.p(src, build).s('.js', '-' + pkg.version + '.js'))
.write($.OVERWRITE, path.join(build, 'demo', scriptName + '.js'))
.uglifyjs() .uglifyjs()
.write($.OVERWRITE, path.join(build, scriptName + '-' + pkg.version + '.min.js')); .WRITE($.map.p(src, build).s('.js', '-' + pkg.version + '.min.js'));
$(src + ': **, ! *.js')
.handlebars(make.env)
.WRITE($.map.p(src, build));
$(root + ': README*, LICENSE*') $(root + ': README*, LICENSE*')
.write($.OVERWRITE, mapperRoot); .handlebars(make.env)
.WRITE($.map.p(root, build));
}); });
make.target('release', ['clean', 'build'], 'create a zipball') make.target('release', ['clean', 'build'], 'create a zipball').async(function (done, fail) {
.async(function (done, fail) {
var target = path.join(build, pkg.name + '-' + pkg.version + '.zip'), $(build + ': **').shzip({
cmd = 'zip', target: path.join(build, pkg.name + '-' + pkg.version + '.zip'),
args = ['-ro', target, '.'], dir: build,
options = { cwd: build }, callback: done
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();
}
}); });
}); });
}; };
+9 -1
View File
@@ -1,5 +1,13 @@
{ {
"name": "jquery.qrcode", "name": "jquery.qrcode",
"displayName": "jQuery.qrcode", "displayName": "jQuery.qrcode",
"version": "0.6.0-dev" "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"
}
} }
+1 -1
View File
@@ -15,7 +15,7 @@
<link href='http://fonts.googleapis.com/css?family=Ubuntu:400,700' rel='stylesheet'> <link href='http://fonts.googleapis.com/css?family=Ubuntu:400,700' rel='stylesheet'>
<link href='styles.css' rel='stylesheet'> <link href='styles.css' rel='stylesheet'>
<script src="jquery-1.10.2.js"></script> <script src="jquery-1.10.2.js"></script>
<script src="jquery.qrcode.js"></script> <script src="../jquery.qrcode-{{pkg.version}}.js"></script>
<script src="ff-range.js"></script> <script src="ff-range.js"></script>
<script src="scripts.js"></script> <script src="scripts.js"></script>
</head> </head>
+12 -8
View File
@@ -1,10 +1,13 @@
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]', (function ($) {
'use strict';
var isOpera = Object.prototype.toString.call(window.opera) === '[object Opera]',
guiValuePairs = [ guiValuePairs = [
["size", "px"], ["size", "px"],
["minversion", ""], ["minversion", ""],
["quiet", "modules"], ["quiet", " modules"],
["radius", "%"], ["radius", "%"],
["msize", "%"], ["msize", "%"],
["mposx", "%"], ["mposx", "%"],
@@ -13,13 +16,12 @@ var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
updateGui = function () { updateGui = function () {
for (var idx in guiValuePairs) { $.each(guiValuePairs, function (idx, pair) {
var pair = guiValuePairs[idx], var $label = $('label[for="' + pair[0] + '"]');
$label = $('label[for="' + pair[0] + '"]');
$label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1])); $label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
} });
}, },
updateQrCode = function () { updateQrCode = function () {
@@ -84,7 +86,7 @@ var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
}; };
$(function () { $(function () {
if (isOpera) { if (isOpera) {
$('html').addClass('opera'); $('html').addClass('opera');
@@ -96,4 +98,6 @@ $(function () {
$("input, textarea, select").on("input change", update); $("input, textarea, select").on("input change", update);
$(window).load(update); $(window).load(update);
update(); update();
}); });
}(jQuery));
+1 -4
View File
@@ -101,10 +101,7 @@ input, textarea, select {
input[type="range"] { input[type="range"] {
-webkit-appearance: none; -webkit-appearance: none;
/* height: 8px; cursor: pointer;
margin-top: 4px;
margin-bottom: 4px;
*/ cursor: pointer;
} }
input::-webkit-slider-thumb { input::-webkit-slider-thumb {
-webkit-appearance: none; -webkit-appearance: none;