re-add download button for file app

pull/1/head
ansuz 8 years ago
parent f02a381e32
commit 7fd36a72f3

@ -7,12 +7,14 @@ define([
'/common/visible.js', '/common/visible.js',
'/common/notify.js', '/common/notify.js',
'/file/file-crypto.js', '/file/file-crypto.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/tweetnacl/nacl-fast.min.js', '/bower_components/tweetnacl/nacl-fast.min.js',
], function ($, Crypto, realtimeInput, Toolbar, Cryptpad, Visible, Notify, FileCrypto) { ], function ($, Crypto, realtimeInput, Toolbar, Cryptpad, Visible, Notify, FileCrypto) {
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
var saveAs = window.saveAs;
var Nacl = window.nacl; var Nacl = window.nacl;
var APP = {}; var APP = window.APP = {};
$(function () { $(function () {
@ -84,6 +86,7 @@ define([
var cryptKey = secret.keys && secret.keys.fileKeyStr; var cryptKey = secret.keys && secret.keys.fileKeyStr;
var key = Nacl.util.decodeBase64(cryptKey); var key = Nacl.util.decodeBase64(cryptKey);
FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) { FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
var title = document.title = metadata.name; var title = document.title = metadata.name;
@ -99,6 +102,8 @@ define([
$(window.document).on('decryption', function (e) { $(window.document).on('decryption', function (e) {
var decrypted = e.originalEvent; var decrypted = e.originalEvent;
if (decrypted.callback) { decrypted.callback(); } if (decrypted.callback) { decrypted.callback(); }
console.log(decrypted);
$dlview.show(); $dlview.show();
$dlform.hide(); $dlform.hide();
var $dlButton = $dlview.find('media-tag button'); var $dlButton = $dlview.find('media-tag button');
@ -108,6 +113,10 @@ define([
} }
$dlButton.addClass('btn btn-success'); $dlButton.addClass('btn btn-success');
toolbar.$rightside.append(Cryptpad.createButton('export', true, {}, function () {
saveAs(decrypted.blob, decrypted.metadata.name);
}));
// make pdfs big // make pdfs big
$iframe.find('media-tag iframe').css({ $iframe.find('media-tag iframe').css({
'height': 'calc(100vh - 64px)', 'height': 'calc(100vh - 64px)',

Loading…
Cancel
Save