Refactored and lots of modification. See README.md.

This commit is contained in:
Lars Jung 2012-04-16 12:53:54 +02:00
parent 859a680e19
commit 71ed41fa69
85 changed files with 3191 additions and 2969 deletions

View file

@ -0,0 +1,56 @@
module.define('ext/qrcode', [jQuery, 'core/settings', 'core/event'], function ($, allsettings, event) {
var defaults = {
enabled: false,
size: 150
},
settings = _.extend({}, defaults, allsettings.qrcode),
template = '<div id="context"><div class="qrcode" /></div>',
$context, hideTimeoutId,
update = function (entry) {
$context.find('.qrcode').empty().qrcode({
render: Modernizr.canvas ? 'canvas' : 'div',
width: settings.size,
height: settings.size,
color: '#333',
text: 'http://' + document.domain + entry.absHref
});
},
onMouseenter = function (entry) {
if (!entry.isFolder()) {
update(entry);
clearTimeout(hideTimeoutId);
$context.stop(true, true).fadeIn(400);
}
},
onMouseleave = function (entry) {
hideTimeoutId = setTimeout(function () {
$context.stop(true, true).fadeOut(400);
}, 200);
},
init = function () {
if (!settings.enabled) {
return;
}
$context = $(template).appendTo('body');
event.sub('entry.mouseenter', onMouseenter);
event.sub('entry.mouseleave', onMouseleave);
};
init();
});