Skip to content

Commit f03797b

Browse files
committed
Tweak upload button to give feedback
For files below 25MB there was no visual feedback to the user when uploading a file. This leads to confusion when uploading files that are big but not huge over a slow network connection.
1 parent 588b1f8 commit f03797b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

notebook/static/tree/js/notebooklist.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ define([
425425
}
426426
);
427427
};
428-
428+
429429
NotebookList.prototype.update_location = function (path) {
430430
this.notebook_path = path;
431431
$('body').attr('data-notebook-path', path);
@@ -525,7 +525,7 @@ define([
525525
var item = $("<div/>")
526526
.addClass("col-md-12")
527527
.appendTo(row);
528-
528+
529529
var checkbox;
530530
if (selectable !== undefined) {
531531
checkbox = $('<input/>')
@@ -624,7 +624,7 @@ define([
624624
var ipynb_extensions = ['ipynb'];
625625
return includes_extension(model.path, ipynb_extensions);
626626
};
627-
627+
628628
NotebookList.prototype._is_editable = function(model) {
629629
// Allow any file to be "edited"
630630
// Non-text files will display the following error:
@@ -633,17 +633,17 @@ define([
633633
// See Console for more details.
634634
return true;
635635
};
636-
636+
637637
NotebookList.prototype._is_viewable = function(model) {
638638
var html_types = ['htm', 'html', 'xhtml', 'xml', 'mht', 'mhtml'];
639639
var media_extension = ['3gp', 'avi', 'mov', 'mp4', 'm4v', 'm4a', 'mp3', 'mkv', 'ogv', 'ogm', 'ogg', 'oga', 'webm', 'wav'];
640640
var image_type = ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp'];
641641
var other_type = ['ico'];
642642
var viewable_extensions = [].concat(html_types, media_extension, image_type, other_type);
643-
return model.mimetype === 'text/html'
643+
return model.mimetype === 'text/html'
644644
|| includes_extension(model.path, viewable_extensions);
645645
};
646-
646+
647647
// Files like PDF that should be opened using `/files` prefix
648648
NotebookList.prototype._is_pdflike = function(model) {
649649
var pdflike_extensions = ['pdf'];
@@ -862,7 +862,7 @@ define([
862862
return false;
863863
});
864864
}
865-
865+
866866
// Add in the date that the file was last modified
867867
item.find(".item_modified").text(utils.format_datetime(model.last_modified));
868868
item.find(".item_modified").attr("title", moment(model.last_modified).format("YYYY-MM-DD HH:mm"));
@@ -962,7 +962,7 @@ define([
962962
).append(
963963
$("<br/>")
964964
).append(input);
965-
965+
966966
// This statement is used simply so that message extraction
967967
// will pick up the strings. The actual setting of the text
968968
// for the button is in dialog.js.
@@ -1271,7 +1271,7 @@ define([
12711271
});
12721272
return false;
12731273
}
1274-
1274+
12751275
var check_exist = function () {
12761276
var exists = false;
12771277
$.each(that.element.find('.list_item:not(.new-file)'), function(k,v){
@@ -1280,7 +1280,7 @@ define([
12801280
return exists
12811281
};
12821282
var exists = check_exist();
1283-
1283+
12841284
var add_uploading_button = function (f, item) {
12851285
// change buttons, add a progress bar
12861286
var uploading_button = item.find('.upload_button').text("Uploading");
@@ -1301,7 +1301,7 @@ define([
13011301
var offset = 0;
13021302
var chunk = 0;
13031303
var chunk_reader = null;
1304-
1304+
13051305
var large_reader_onload = function (event) {
13061306
if (stop_signal === true) {
13071307
return;
@@ -1374,7 +1374,7 @@ define([
13741374

13751375
model.chunk = chunk;
13761376
model.content = filedata;
1377-
1377+
13781378
var on_success = function () {
13791379
if (offset < f.size) {
13801380
// of to the next chunk
@@ -1434,6 +1434,7 @@ define([
14341434
var upload_button = $('<button/>').text(i18n.msg._("Upload"))
14351435
.addClass('btn btn-primary btn-xs upload_button')
14361436
.click(function (e) {
1437+
item.find('.upload_button').text("Uploading...");
14371438
var filename = item.find('.item_name > input').val();
14381439
var path = utils.url_path_join(that.notebook_path, filename);
14391440
var filedata = item.data('filedata');

0 commit comments

Comments
 (0)