mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 20:44:53 -04:00
Cosmetics.
This commit is contained in:
parent
7494491637
commit
c71f891af2
311 changed files with 55 additions and 46 deletions
61
src/_h5ai/client/js/inc/ext/thumbnails.js
Normal file
61
src/_h5ai/client/js/inc/ext/thumbnails.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
|
||||
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/event', 'core/ajax'], function (_, allsettings, entry, event, ajax) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
img: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
|
||||
mov: ['video'],
|
||||
doc: ['pdf', 'ps'],
|
||||
delay: 1000
|
||||
}, allsettings.thumbnails),
|
||||
|
||||
checkEntry = function (entry) {
|
||||
|
||||
if (entry.$extended) {
|
||||
|
||||
var type = null;
|
||||
|
||||
if (_.indexOf(settings.img, entry.type) >= 0) {
|
||||
type = 'img';
|
||||
} else if (_.indexOf(settings.mov, entry.type) >= 0) {
|
||||
type = 'mov';
|
||||
} else if (_.indexOf(settings.doc, entry.type) >= 0) {
|
||||
type = 'doc';
|
||||
}
|
||||
|
||||
if (type) {
|
||||
ajax.getThumbSrcSmall(type, entry.absHref, function (src) {
|
||||
|
||||
if (src) {
|
||||
entry.$extended.find('.icon.small img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
ajax.getThumbSrcBig(type, entry.absHref, function (src) {
|
||||
|
||||
if (src) {
|
||||
entry.$extended.find('.icon.big img').addClass('thumb').attr('src', src);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
init = function (entry) {
|
||||
|
||||
if (!settings.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
_.each(entry.content, checkEntry);
|
||||
}, settings.delay);
|
||||
|
||||
event.sub('entry.created', function (entry) {
|
||||
|
||||
checkEntry(entry);
|
||||
});
|
||||
};
|
||||
|
||||
init(entry);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue