Display the file size before downloading it

pull/1/head
yflory 8 years ago
parent 594405de73
commit 5bfd8470cb

@ -63,6 +63,19 @@ media-tag img {
height: 50vh; height: 50vh;
box-sizing: border-box; box-sizing: border-box;
} }
#download-form label {
display: flex;
justify-content: center;
align-items: center;
white-space: normal;
word-wrap: break-word;
}
#download-form label span {
width: 50vh;
max-width: 80vw;
text-align: center;
line-height: 1.5em;
}
.hovering { .hovering {
background-color: rgba(255, 0, 115, 0.5) !important; background-color: rgba(255, 0, 115, 0.5) !important;
} }
@ -92,5 +105,4 @@ body #uploadStatusContainer {
background-color: rgba(255, 255, 255, 0.9); background-color: rgba(255, 255, 255, 0.9);
color: black; color: black;
opacity: 0.9; opacity: 0.9;
display: block !important;
} }

@ -70,6 +70,21 @@ media-tag {
box-sizing: border-box; box-sizing: border-box;
} }
} }
#download-form {
label {
display: flex;
justify-content: center;
align-items: center;
white-space: normal;
word-wrap: break-word;
span {
width: 50vh;
max-width: 80vw;
text-align: center;
line-height: 1.5em;
}
}
}
.hovering { .hovering {
background-color: rgba(255, 0, 115, 0.5) !important; background-color: rgba(255, 0, 115, 0.5) !important;
} }
@ -111,5 +126,4 @@ body #uploadStatusContainer {
background-color: rgba(255, 255, 255, 0.9); background-color: rgba(255, 255, 255, 0.9);
color: black; color: black;
opacity: 0.9; opacity: 0.9;
display: block !important;
} }

@ -18,8 +18,7 @@
</div> </div>
<div id="download-form" style="display: none;"> <div id="download-form" style="display: none;">
<input type="button" name="dl" id="dl" class="inputfile" /> <input type="button" name="dl" id="dl" class="inputfile" />
<label for="dl" class="btn btn-success block unselectable" data-localization-title="download_button" <label for="dl" class="btn btn-success block unselectable" data-localization-title="download_button"><span data-localization="download_button"></span></label>
data-localization="download_button"></label>
<span class="block" id="progress"></span> <span class="block" id="progress"></span>
</div> </div>
<div id="download-view" style="display: none;"> <div id="download-view" style="display: none;">

@ -26,6 +26,7 @@ define([
var $dlform = $iframe.find('#download-form'); var $dlform = $iframe.find('#download-form');
var $dlview = $iframe.find('#download-view'); var $dlview = $iframe.find('#download-view');
var $label = $form.find('label'); var $label = $form.find('label');
var $dllabel = $dlform.find('label span');
var $progress = $iframe.find('#progress'); var $progress = $iframe.find('#progress');
var $body = $iframe.find('body'); var $body = $iframe.find('body');
@ -60,13 +61,6 @@ define([
return data ? data.title : undefined; return data ? data.title : undefined;
}; };
var exportFile = function () {
var filename = Cryptpad.fixFileName(document.title);
if (!(typeof(filename) === 'string' && filename)) { return; }
var blob = new Blob([myFile], {type: myDataType});
saveAs(blob, filename);
};
Title = Cryptpad.createTitle({}, function(){}, Cryptpad); Title = Cryptpad.createTitle({}, function(){}, Cryptpad);
var displayed = ['title', 'useradmin', 'newpad', 'limit', 'upgrade']; var displayed = ['title', 'useradmin', 'newpad', 'limit', 'upgrade'];
@ -88,11 +82,6 @@ define([
if (uploadMode) { toolbar.title.hide(); } if (uploadMode) { toolbar.title.hide(); }
var $rightside = toolbar.$rightside;
var $export = Cryptpad.createButton('export', true, {}, exportFile);
$rightside.append($export);
Title.updateTitle(Cryptpad.initialName || getTitle() || Title.defaultTitle); Title.updateTitle(Cryptpad.initialName || getTitle() || Title.defaultTitle);
if (!uploadMode) { if (!uploadMode) {
@ -123,7 +112,6 @@ define([
$appContainer.css('background', 'white'); $appContainer.css('background', 'white');
} }
$dlButton.addClass('btn btn-success'); $dlButton.addClass('btn btn-success');
Cryptpad.removeLoadingScreen();
}) })
.on('decryptionError', function (e) { .on('decryptionError', function (e) {
var error = e.originalEvent; var error = e.originalEvent;
@ -167,6 +155,10 @@ define([
var todoBigFile = function (sizeMb) { var todoBigFile = function (sizeMb) {
$dlform.show(); $dlform.show();
Cryptpad.removeLoadingScreen(); Cryptpad.removeLoadingScreen();
$dllabel.append($('<br>'));
$dllabel.append(metadata.name);
$dllabel.append($('<br>'));
$dllabel.append(Messages._getKey('formattedMB', [sizeMb]));
var decrypting = false; var decrypting = false;
var onClick = function (ev) { var onClick = function (ev) {
if (decrypting) { return; } if (decrypting) { return; }
@ -175,7 +167,6 @@ define([
displayFile(ev); displayFile(ev);
}; };
if (sizeMb < 5) { return void onClick(); } if (sizeMb < 5) { return void onClick(); }
Cryptpad.removeLoadingScreen();
$dlform.find('#dl, #progress').click(onClick); $dlform.find('#dl, #progress').click(onClick);
}; };
Cryptpad.getFileSize(window.location.href, function (e, data) { Cryptpad.getFileSize(window.location.href, function (e, data) {

Loading…
Cancel
Save