diff --git a/.gitignore b/.gitignore index 591c2afc61..38381e1123 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ config.rst package-lock.json geckodriver.log *.ipynb -.vscode/settings.json \ No newline at end of file +*.iml +.vscode/settings.json diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 34617318b3..f2b784b650 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -15,25 +15,25 @@ define([ "use strict"; var extension = function(path){ - /** - * return the last pat after the dot in a filepath - * or the filepath itself if no dots present. - * Empty string if the filepath ends with a dot. - **/ - var parts = path.split('.'); - return parts[parts.length-1]; + /** + * return the last pat after the dot in a filepath + * or the filepath itself if no dots present. + * Empty string if the filepath ends with a dot. + **/ + var parts = path.split('.'); + return parts[parts.length-1]; }; var item_in = function(item, list) { - // Normalize list and item to lowercase - var normalized_list = list.map(function(_item) { - return _item.toLowerCase(); - }); - return normalized_list.indexOf(item.toLowerCase()) !== -1; + // Normalize list and item to lowercase + var normalized_list = list.map(function(_item) { + return _item.toLowerCase(); + }); + return normalized_list.indexOf(item.toLowerCase()) !== -1; }; var includes_extension = function(filepath, extensionslist) { - return item_in(extension(filepath), extensionslist); + return item_in(extension(filepath), extensionslist); }; function name_sorter(ascending) { @@ -58,7 +58,7 @@ define([ var order = ascending ? 1 : 0; return (function(a, b) { return utils.datetime_sort_helper(a.last_modified, b.last_modified, - order) + order) }); } @@ -66,23 +66,23 @@ define([ var order = ascending ? 1 : 0; // directories have file size of undefined return (function(a, b) { - if (a.size === undefined) { - return (ascending) ? -1 : 1; - } + if (a.size === undefined) { + return (ascending) ? -1 : 1; + } - if (b.size === undefined) { - return (ascending) ? 1 : -1; - } + if (b.size === undefined) { + return (ascending) ? 1 : -1; + } - if (a.size > b.size) { - return (ascending) ? -1 : 1; - } + if (a.size > b.size) { + return (ascending) ? -1 : 1; + } - if (b.size > a.size) { - return (ascending) ? 1 : -1; - } + if (b.size > a.size) { + return (ascending) ? 1 : -1; + } - return 0; + return 0; }); } @@ -134,9 +134,9 @@ define([ this.sort_direction = 1; this._max_upload_size_mb = 25; this.EDIT_MIMETYPES = [ - 'application/javascript', - 'application/x-sh', - 'application/vnd.groove-tool-template' + 'application/javascript', + 'application/x-sh', + 'application/vnd.groove-tool-template' ]; }; @@ -192,9 +192,9 @@ define([ }); $('#new-folder').click(function(e) { that.contents.new_untitled(that.notebook_path || '', {type: 'directory'}) - .then(function(){ - that.load_list(); - }).catch(function (e) { + .then(function(){ + that.load_list(); + }).catch(function (e) { dialog.modal({ title: i18n.msg._('Creating Folder Failed'), body: $('
') @@ -306,8 +306,8 @@ define([ var file_ext = name_and_ext[1]; if (f.size > that._max_upload_size_mb * 1024 * 1024) { - var body_msg = i18n.msg.sprintf(i18n.msg._("The file size is %d MB. Do you still want to upload it?"), - Math.round(f.size / (1024 * 1024))); + var body_msg = i18n.msg.sprintf(i18n.msg._("The file size is %d MB. Do you still want to upload it?"), + Math.round(f.size / (1024 * 1024))); dialog.modal({ title : i18n.msg._('Large file size warning'), body : body_msg, @@ -378,7 +378,7 @@ define([ // Add an event handler browser back and forward events window.onpopstate = function(e) { var path = (window.history.state && window.history.state.path) ? - window.history.state.path : that.initial_notebook_path; + window.history.state.path : that.initial_notebook_path; that.update_location(path); }; var breadcrumb = $('.breadcrumb'); @@ -387,26 +387,26 @@ define([ var root_url = utils.url_path_join(that.base_url, '/tree'); var root = $('').append( $("") - .attr('href', root_url) - .attr('title','Link to root folder'+root_url) - .append( - $("") - .addClass('fa fa-folder') - ) - .click(function(e) { - // Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click) - if(e.altKey || e.metaKey || e.shiftKey) { - return true; - } - var path = ''; - window.history.pushState( - {path: path}, - 'Home', - utils.url_path_join(that.base_url, 'tree') - ); - that.update_location(path); - return false; - }) + .attr('href', root_url) + .attr('title','Link to root folder'+root_url) + .append( + $("") + .addClass('fa fa-folder') + ) + .click(function(e) { + // Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click) + if(e.altKey || e.metaKey || e.shiftKey) { + return true; + } + var path = ''; + window.history.pushState( + {path: path}, + 'Home', + utils.url_path_join(that.base_url, 'tree') + ); + that.update_location(path); + return false; + }) ); breadcrumb.append(root); var path_parts = []; @@ -420,6 +420,7 @@ define([ ); var crumb = $('').append( $('') + .attr('href', url) .attr('title',"link to"+url) .text(path_part) @@ -567,15 +568,27 @@ define([ .addClass("item_name") .appendTo(link); - $("") - .addClass("file_size") - .addClass("pull-right") + var div = $('') + .addClass('pull-right') .appendTo(item); + var buttons = $('') + .addClass("item_buttons pull-left") + .appendTo(div); + + var div2 = $('') + .addClass('pull-right') + .appendTo(div); + $("") .addClass("item_modified") + .addClass("pull-left") + .appendTo(div2); + + $("") + .addClass("file_size") .addClass("pull-right") - .appendTo(item); + .appendTo(div2); if (selectable === false) { checkbox.css('visibility', 'hidden'); @@ -590,10 +603,6 @@ define([ }); } - var buttons = $('') - .addClass("item_buttons pull-right") - .appendTo(item); - $('') .addClass('running-indicator') .text(i18n.msg._('Running')) @@ -642,33 +651,33 @@ define([ }; NotebookList.prototype._is_notebook = function(model) { - var ipynb_extensions = ['ipynb']; - return includes_extension(model.path, ipynb_extensions); + var ipynb_extensions = ['ipynb']; + return includes_extension(model.path, ipynb_extensions); }; NotebookList.prototype._is_editable = function(model) { - // Allow any file to be "edited" - // Non-text files will display the following error: - // Error: [FILE] is not UTF-8 encoded - // Saving is disabled. - // See Console for more details. - return true; + // Allow any file to be "edited" + // Non-text files will display the following error: + // Error: [FILE] is not UTF-8 encoded + // Saving is disabled. + // See Console for more details. + return true; }; NotebookList.prototype._is_viewable = function(model) { - var html_types = ['htm', 'html', 'xhtml', 'xml', 'mht', 'mhtml']; - var media_extension = ['3gp', 'avi', 'mov', 'mp4', 'm4v', 'm4a', 'mp3', 'mkv', 'ogv', 'ogm', 'ogg', 'oga', 'webm', 'wav']; - var image_type = ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp']; - var other_type = ['ico']; - var viewable_extensions = [].concat(html_types, media_extension, image_type, other_type); - return model.mimetype === 'text/html' - || includes_extension(model.path, viewable_extensions); + var html_types = ['htm', 'html', 'xhtml', 'xml', 'mht', 'mhtml']; + var media_extension = ['3gp', 'avi', 'mov', 'mp4', 'm4v', 'm4a', 'mp3', 'mkv', 'ogv', 'ogm', 'ogg', 'oga', 'webm', 'wav']; + var image_type = ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp']; + var other_type = ['ico']; + var viewable_extensions = [].concat(html_types, media_extension, image_type, other_type); + return model.mimetype === 'text/html' + || includes_extension(model.path, viewable_extensions); }; // Files like PDF that should be opened using `/files` prefix NotebookList.prototype._is_pdflike = function(model) { - var pdflike_extensions = ['pdf']; - return includes_extension(model.path, pdflike_extensions); + var pdflike_extensions = ['pdf']; + return includes_extension(model.path, pdflike_extensions); }; /** @@ -914,14 +923,14 @@ define([ item.find(".item_icon").addClass(NotebookList.icons[icon_type]).addClass('icon-fixed-width'); item.find(".item_name").empty().append( $('') - .addClass("filename_input") - .attr('value', name) - .attr('size', '30') - .attr('type', 'text') - .keyup(function(event){ - if(event.keyCode === 13){item.find('.upload_button').click();} - else if(event.keyCode === 27){item.remove();} - }) + .addClass("filename_input") + .attr('value', name) + .attr('size', '30') + .attr('type', 'text') + .keyup(function(event){ + if(event.keyCode === 13){item.find('.upload_button').click();} + else if(event.keyCode === 27){item.remove();} + }) ); }; @@ -982,20 +991,20 @@ define([ .addClass('form-control') .val(item_name); var rename_msg = function (type) { - switch(type) { - case 'file': return i18n.msg._("Enter a new file name:"); - case 'directory': return i18n.msg._("Enter a new directory name:"); - case 'notebook': return i18n.msg._("Enter a new notebook name:"); - default: return i18n.msg._("Enter a new name:"); - } + switch(type) { + case 'file': return i18n.msg._("Enter a new file name:"); + case 'directory': return i18n.msg._("Enter a new directory name:"); + case 'notebook': return i18n.msg._("Enter a new notebook name:"); + default: return i18n.msg._("Enter a new name:"); + } }; var rename_title = function (type) { - switch(type) { - case 'file': return i18n.msg._("Rename file"); - case 'directory': return i18n.msg._("Rename directory"); - case 'notebook': return i18n.msg._("Rename notebook"); - default: return i18n.msg._("Rename"); - } + switch(type) { + case 'file': return i18n.msg._("Rename file"); + case 'directory': return i18n.msg._("Rename directory"); + case 'notebook': return i18n.msg._("Rename notebook"); + default: return i18n.msg._("Rename"); + } }; var dialog_body = $('').append( $("").addClass("rename-message") @@ -1024,8 +1033,8 @@ define([ // Deselect items after successful rename. that.select('select-none'); }).catch(function(e) { - var template = i18n.msg._("An error occurred while renaming \"%1$s\" to \"%2$s\"."); - var failmsg = i18n.msg.sprintf(template,item_name,input.val()); + var template = i18n.msg._("An error occurred while renaming \"%1$s\" to \"%2$s\"."); + var failmsg = i18n.msg.sprintf(template,item_name,input.val()); dialog.modal({ title: i18n.msg._("Rename Failed"), body: $('') @@ -1077,7 +1086,7 @@ define([ var dialog_body = $('').append( $("").addClass("rename-message") .text(i18n.msg.sprintf(i18n.msg.ngettext("Enter a new destination directory path for this item:", - "Enter a new destination directory path for these %d items:", num_items),num_items)) + "Enter a new destination directory path for these %d items:", num_items),num_items)) ).append( $("