mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 06:25:18 -04:00
Cosmetics.
This commit is contained in:
parent
7494491637
commit
c71f891af2
311 changed files with 55 additions and 46 deletions
54
src/_h5ai/client/js/inc/ext/qrcode.js
Normal file
54
src/_h5ai/client/js/inc/ext/qrcode.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
size: 150
|
||||
}, allsettings.qrcode),
|
||||
|
||||
template = '<div id="qrcode"/>',
|
||||
|
||||
$qrcode, hideTimeoutId,
|
||||
|
||||
update = function (entry) {
|
||||
|
||||
$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);
|
||||
$qrcode.stop(true, true).fadeIn(400);
|
||||
}
|
||||
},
|
||||
|
||||
onMouseleave = function (entry) {
|
||||
|
||||
hideTimeoutId = setTimeout(function () {
|
||||
|
||||
$qrcode.stop(true, true).fadeOut(400);
|
||||
}, 200);
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$qrcode = $(template).appendTo('body');
|
||||
|
||||
event.sub('entry.mouseenter', onMouseenter);
|
||||
event.sub('entry.mouseleave', onMouseleave);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue