1
0
Fork 0
mirror of https://github.com/lrsjng/h5ai synced 2025-12-06 08:52:45 +01:00
This commit is contained in:
mptr 2021-02-11 00:31:11 +01:00 committed by GitHub
commit 876590e61d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 0 deletions

View file

@ -283,6 +283,14 @@
}
},
/*
Object-Tag for e.g. PDFs
*/
"preview-object": {
"enabled": true,
"types": ["x-pdf"]
},
/*
Play a video preview on click.

View file

@ -0,0 +1,11 @@
#pv-content-object {
padding: 0;
overflow: hidden;
object {
width: calc(100% - 230px);
height: 100%;
@media (max-aspect-ratio: ~"1/1") { /* escape to avoid convert to literal 1 */
width: 100%;
}
}
}

View file

@ -1,5 +1,6 @@
require('./preview');
require('./preview-aud');
require('./preview-img');
require('./preview-object');
require('./preview-txt');
require('./preview-vid');

View file

@ -0,0 +1,41 @@
const {dom} = require('../../util');
const allsettings = require('../../core/settings');
const preview = require('./preview');
const settings = Object.assign({
enabled: false,
types: []
}, allsettings['preview-object']);
const tpl = '<div id="pv-content-object"></div>';
const updateGui = () => {
const el = dom('#pv-content-object')[0];
if (!el) {
return;
}
const container = dom('#pv-container')[0];
el.style.height = container.offsetHeight + 'px';
preview.setLabels([
preview.item.label,
preview.item.size + ' bytes'
]);
};
const load = item => {
console.log("loading");
const $el = dom("<object><p>Your browser does not support in-frame PDF rendering. :/</p></object>")
.attr("data", item.absHref)
.attr("type", "application/pdf");
return dom(tpl).app($el);
};
const init = () => {
if (settings.enabled) {
console.log("registered");
preview.register(settings.types, load, updateGui);
}
};
init();