Open or share a mediatag from a pad
parent
3f88e29f30
commit
4027e48fd2
|
@ -362,6 +362,9 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
Messages.pad_mediatagShare = "Share file"; // XXX
|
||||
Messages.pad_mediatagOpen = "Open file"; // XXX
|
||||
|
||||
var mediatagContextMenu;
|
||||
MT.importMediaTagMenu = function (common) {
|
||||
if (mediatagContextMenu) { return mediatagContextMenu; }
|
||||
|
@ -377,6 +380,14 @@ define([
|
|||
'tabindex': '-1',
|
||||
'data-icon': "fa-eye",
|
||||
}, Messages.pad_mediatagPreview)),
|
||||
h('li.cp-svg', h('a.cp-app-code-context-openin.dropdown-item', {
|
||||
'tabindex': '-1',
|
||||
'data-icon': "fa-external-link",
|
||||
}, Messages.pad_mediatagOpen)),
|
||||
h('li.cp-svg', h('a.cp-app-code-context-share.dropdown-item', {
|
||||
'tabindex': '-1',
|
||||
'data-icon': "fa-shhare-alt",
|
||||
}, Messages.pad_mediatagShare)),
|
||||
h('li', h('a.cp-app-code-context-saveindrive.dropdown-item', {
|
||||
'tabindex': '-1',
|
||||
'data-icon': "fa-cloud-upload",
|
||||
|
@ -419,6 +430,21 @@ define([
|
|||
else if ($this.hasClass("cp-app-code-context-open")) {
|
||||
$mt.trigger('preview');
|
||||
}
|
||||
else if ($this.hasClass("cp-app-code-context-openin")) {
|
||||
var hash = common.getHashFromMediaTag($mt);
|
||||
common.openURL(Hash.hashToHref(hash, 'file'));
|
||||
}
|
||||
else if ($this.hasClass("cp-app-code-context-share")) {
|
||||
var data = {
|
||||
file: true,
|
||||
pathname: '/file/',
|
||||
hashes: {
|
||||
fileHash: common.getHashFromMediaTag($mt)
|
||||
},
|
||||
title: Util.find($mt[0], ['_mediaObject', 'name']) || ''
|
||||
};
|
||||
common.getSframeChannel().event('EV_SHARE_OPEN', data);
|
||||
}
|
||||
});
|
||||
|
||||
return m;
|
||||
|
|
|
@ -142,7 +142,7 @@ define([
|
|||
}
|
||||
return;
|
||||
};
|
||||
funcs.importMediaTag = function ($mt) {
|
||||
var getMtData = function ($mt) {
|
||||
if (!$mt || !$mt.is('media-tag')) { return; }
|
||||
var chanStr = $mt.attr('src');
|
||||
var keyStr = $mt.attr('data-crypto-key');
|
||||
|
@ -154,10 +154,27 @@ define([
|
|||
var channel = src.replace(/\/blob\/[0-9a-f]{2}\//i, '');
|
||||
// Get key
|
||||
var key = keyStr.replace(/cryptpad:/i, '');
|
||||
return {
|
||||
channel: channel,
|
||||
key: key
|
||||
};
|
||||
};
|
||||
funcs.getHashFromMediaTag = function ($mt) {
|
||||
var data = getMtData($mt);
|
||||
if (!data) { return; }
|
||||
return Hash.getFileHashFromKeys({
|
||||
version: 1,
|
||||
channel: data.channel,
|
||||
keys: { fileKeyStr: data.key }
|
||||
});
|
||||
};
|
||||
funcs.importMediaTag = function ($mt) {
|
||||
var data = getMtData($mt);
|
||||
if (!data) { return; }
|
||||
var metadata = $mt[0]._mediaObject._blob.metadata;
|
||||
ctx.sframeChan.query('Q_IMPORT_MEDIATAG', {
|
||||
channel: channel,
|
||||
key: key,
|
||||
channel: data.channel,
|
||||
key: data.key,
|
||||
name: metadata.name,
|
||||
type: metadata.type,
|
||||
owners: metadata.owners
|
||||
|
|
|
@ -52,10 +52,10 @@ define([
|
|||
: Share.getShareModal;
|
||||
f(common, {
|
||||
origin: priv.origin,
|
||||
pathname: priv.pathname,
|
||||
password: priv.password,
|
||||
isTemplate: priv.isTemplate,
|
||||
hashes: priv.hashes,
|
||||
pathname: data.pathname || priv.pathname,
|
||||
password: data.hashes ? '' : priv.password,
|
||||
isTemplate: data.hashes ? false : priv.isTemplate,
|
||||
hashes: data.hashes || priv.hashes,
|
||||
common: common,
|
||||
title: data.title,
|
||||
versionHash: data.versionHash,
|
||||
|
@ -64,8 +64,8 @@ define([
|
|||
hideIframe();
|
||||
},
|
||||
fileData: {
|
||||
hash: priv.hashes.fileHash,
|
||||
password: priv.password
|
||||
hash: (data.hashes && data.hashes.fileHash) || priv.hashes.fileHash,
|
||||
password: data.hashes ? '' : priv.password
|
||||
}
|
||||
}, function (e, modal) {
|
||||
if (e) { console.error(e); }
|
||||
|
|
Loading…
Reference in New Issue