mirror of
https://github.com/lrsjng/h5ai
synced 2025-12-06 08:52:45 +01:00
Merge da2e174f30 into aa94de4945
This commit is contained in:
commit
876590e61d
4 changed files with 61 additions and 0 deletions
|
|
@ -283,6 +283,14 @@
|
|||
}
|
||||
},
|
||||
|
||||
/*
|
||||
Object-Tag for e.g. PDFs
|
||||
*/
|
||||
"preview-object": {
|
||||
"enabled": true,
|
||||
"types": ["x-pdf"]
|
||||
},
|
||||
|
||||
/*
|
||||
Play a video preview on click.
|
||||
|
||||
|
|
|
|||
11
src/_h5ai/public/css/lib/ext/preview-object.less
Normal file
11
src/_h5ai/public/css/lib/ext/preview-object.less
Normal 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%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
require('./preview');
|
||||
require('./preview-aud');
|
||||
require('./preview-img');
|
||||
require('./preview-object');
|
||||
require('./preview-txt');
|
||||
require('./preview-vid');
|
||||
|
|
|
|||
41
src/_h5ai/public/js/lib/ext/preview/preview-object.js
Normal file
41
src/_h5ai/public/js/lib/ext/preview/preview-object.js
Normal 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();
|
||||
Loading…
Reference in a new issue