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
* adds image support for fore- and background
* adds label and image positioning
* updates build process
+71 -112
View File
@@ -2,17 +2,61 @@
'use strict';
module.exports = function (make) {
var path = require('path'),
child_process = require('child_process');
pkg = require('./package.json'),
var pkg = require('./package.json'),
$ = make.fQuery,
root = path.resolve(__dirname),
src = path.resolve(root, 'src'),
build = path.resolve(root, 'build'),
src = path.join(root, 'src'),
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
bitwise: true,
curly: true,
@@ -26,128 +70,43 @@ var pkg = require('./package.json'),
undef: true,
// Environments
browser: true,
// Globals
predef: [
"jQuery", "qrcode"
]
browser: true
},
mapperSrc = function (blob) {
return blob.source.replace(src, build);
},
mapperRoot = function (blob) {
return blob.source.replace(root, build);
global = {
'jQuery': true,
'qrcode': true
};
module.exports = function (make) {
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 });
$(src + ': jquery.qrcode.js, demo/scripts.js').log(-3)
.jshint(options, global);
});
make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
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 () {
make.target('build', ['check-version'], 'build all updated files').sync(function () {
$(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()
.handlebars(replacements)
.write($.OVERWRITE, path.join(build, scriptName + '-' + pkg.version + '.js'))
.write($.OVERWRITE, path.join(build, 'demo', scriptName + '.js'))
.handlebars(make.env)
.WRITE($.map.p(src, build).s('.js', '-' + pkg.version + '.js'))
.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*')
.write($.OVERWRITE, mapperRoot);
.handlebars(make.env)
.WRITE($.map.p(root, build));
});
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
});
});
};
+9 -1
View File
@@ -1,5 +1,13 @@
{
"name": "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='styles.css' rel='stylesheet'>
<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="scripts.js"></script>
</head>
+9 -5
View File
@@ -1,5 +1,8 @@
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
(function ($) {
'use strict';
var isOpera = Object.prototype.toString.call(window.opera) === '[object Opera]',
guiValuePairs = [
["size", "px"],
@@ -13,13 +16,12 @@ var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
updateGui = function () {
for (var idx in guiValuePairs) {
$.each(guiValuePairs, function (idx, pair) {
var pair = guiValuePairs[idx],
$label = $('label[for="' + pair[0] + '"]');
var $label = $('label[for="' + pair[0] + '"]');
$label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
}
});
},
updateQrCode = function () {
@@ -97,3 +99,5 @@ $(function () {
$(window).load(update);
update();
});
}(jQuery));
+1 -4
View File
@@ -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;