Updates demo.

pull/18/head
Lars Jung 12 years ago
parent 974002f950
commit ceac699d47

@ -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

@ -2,152 +2,111 @@
'use strict'; 'use strict';
var path = require('path'), module.exports = function (make) {
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) {
return blob.source.replace(root, build);
};
module.exports = function (make) { var path = require('path'),
pkg = require('./package.json'),
var Event = make.Event,
$ = make.fQuery, $ = 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.defaults('release');
make.before(function () { make.before(function () {
stamp = moment(); var moment = make.moment();
replacements = { make.env = {
pkg: pkg, 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) { make.target('check-version', [], 'add git info to dev builds').async(function (done, fail) {
if (!/-dev$/.test(pkg.version)) { if (!/\+$/.test(pkg.version)) {
done(); done();
return; return;
} }
$.git(root, function (err, result) { $.git(root, function (err, result) {
pkg.version += '-' + result.revListOriginMasterHead.length + '-' + result.revParseHead.slice(0, 7); pkg.version += result.buildSuffix;
Event.info({ $.info({ method: 'check-version', message: 'version set to ' + pkg.version });
method: 'check-version',
message: 'version set to ' + pkg.version
});
done(); done();
}); });
}); });
make.target('clean', [], 'delete build folder') make.target('clean', [], 'delete build folder').sync(function () {
.sync(function () {
$.rmfr($.I_AM_SURE, build); $.DELETE(build);
}); });
make.target('lint', [], 'lint all JavaScript files with JSHint') make.target('lint', [], 'lint all JavaScript files with JSHint').sync(function () {
.sync(function () {
$(src + ': jquery.qrcode.js') var options = {
.jshint(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
},
global = {
'jQuery': true,
'qrcode': true
};
make.target('build', ['check-version'], 'build all updated files') $(src + ': jquery.qrcode.js, demo/scripts.js').log(-3)
.sync(function () { .jshint(options, global);
});
var scriptName = pkg.name;
$(src + '/demo/*') make.target('build', ['check-version'], 'build all updated files').sync(function () {
.handlebars(replacements)
.write($.OVERWRITE, mapperSrc);
$(src + ': ' + scriptName + '.js') $(src + ': jquery.qrcode.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'),
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) { $(build + ': **').shzip({
process.stderr.write(data); target: path.join(build, pkg.name + '-' + pkg.version + '.zip'),
}); dir: build,
proc.on('exit', function (code) { callback: done
if (code) {
Event.error({ method: 'exec', message: cmd + ' exit code ' + code });
fail();
} else {
Event.ok({ method: 'exec', message: 'created zipball ' + target });
done();
}
}); });
}); });
}; };

@ -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"
}
} }

@ -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>

@ -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 = [ guiValuePairs = [
["size", "px"], ["size", "px"],
@ -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 () {
@ -97,3 +99,5 @@ $(function () {
$(window).load(update); $(window).load(update);
update(); update();
}); });
}(jQuery));

@ -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;

Loading…
Cancel
Save