save images drawn with whiteboard to your CryptDrive

pull/1/head
ansuz 8 years ago
parent fe826133b3
commit 8b0831ac5d

@ -254,6 +254,7 @@ define([
var createAreaHandlers = File.createDropArea = function ($area, $hoverArea) {
var counter = 0;
if (!$hoverArea) { $hoverArea = $area; }
if (!$area) { return; }
$hoverArea
.on('dragenter', function (e) {
e.preventDefault();

@ -1243,6 +1243,13 @@ define([
style: 'font:'+size+' FontAwesome'
});
break;
case 'savetodrive':
button = $('<button>', {
'class': 'fa fa-cloud-upload',
title: Messages.canvas_saveToDrive,
})
.click(prepareFeedback(type));
break;
default:
button = $('<button>', {
'class': "fa fa-question",

@ -212,6 +212,18 @@ window.canvas = canvas;
});
};
module.FM = Cryptpad.createFileManager({});
module.upload = function (title) {
$canvas[0].toBlob(function (blob) {
blob.name = title;
var reader = new FileReader();
reader.onloadend = function () {
module.FM.handleFile(blob);
};
reader.readAsArrayBuffer(blob);
});
};
var initializing = true;
var $bar = $('#toolbar');
@ -337,6 +349,15 @@ window.canvas = canvas;
var $export = Cryptpad.createButton('export', true, {}, saveImage);
$rightside.append($export);
Cryptpad.createButton('savetodrive', true, {}, function () {})
.click(function () {
Cryptpad.prompt(Messages.exportPrompt, document.title + '.png',
function (name) {
if (name === null || !name.trim()) { return; }
module.upload(name);
});
}).appendTo($rightside);
var $forget = Cryptpad.createButton('forget', true, {}, function (err) {
if (err) { return; }
setEditable(false);
@ -344,7 +365,6 @@ window.canvas = canvas;
});
$rightside.append($forget);
var editHash;
if (!readOnly) {

Loading…
Cancel
Save