Replace media-tag.js with the new one

pull/1/head
yflory 7 years ago
parent 38887eb088
commit bc57f8c274

@ -5,7 +5,7 @@ www/common/tippy/
www/common/jquery-ui/
server.js
www/common/media-tag.js
www/common/old-media-tag.js
www/scratch
www/common/toolbar.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -22,6 +22,14 @@
}
};
var fixHTML = function (str) {
if (!str) { return ''; }
return str.replace(/[<>&"']/g, function (x) {
return ({ "<": "&lt;", ">": "&gt", "&": "&amp;", '"': "&#34;", "'": "&#39;" })[x];
});
};
// Default config, can be overriden per media-tag call
var config = {
allowed: [
@ -48,6 +56,7 @@
image: function (metadata, url, content, cfg, cb) {
var img = document.createElement('img');
img.setAttribute('src', url);
img.blob = content;
cb(void 0, img);
},
video: function (metadata, url, content, cfg, cb) {
@ -74,7 +83,8 @@
},
download: function (metadata, url, content, cfg, cb) {
var btn = document.createElement('button');
btn.innerHTML = cfg.download.text;
btn.innerHTML = cfg.download.text + '<br>' +
metadata.name ? '<b>' + fixHTML(metadata.name) + '</b>' : '';
btn.addEventListener('click', function () {
saveFile(content, url, metadata.name);
});

@ -601,8 +601,8 @@ define([
var $clone = $(inner).clone();
nThen(function (waitFor) {
$(inner).find('media-tag').each(function (i, el) {
if (!$(el).data('blob')) { return; }
Util.blobToImage($(el).data('blob'), waitFor(function (imgSrc) {
if (!$(el).data('blob') || !el.blob) { return; }
Util.blobToImage(el.blob || $(el).data('blob'), waitFor(function (imgSrc) {
$clone.find('media-tag[src="' + $(el).attr('src') + '"] img')
.attr('src', imgSrc);
$clone.find('media-tag').parent()

Loading…
Cancel
Save