diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 79e2b822c..995b8fb13 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -129,6 +129,7 @@ define([ // Bind events for action buttons. $('.rename-button').click($.proxy(this.rename_selected, this)); + $('.move-button').click($.proxy(this.move_selected, this)); $('.shutdown-button').click($.proxy(this.shutdown_selected, this)); $('.duplicate-button').click($.proxy(this.duplicate_selected, this)); $('.delete-button').click($.proxy(this.delete_selected, this)); @@ -550,6 +551,15 @@ define([ $('.rename-button').css('display', 'none'); } + // Move is only visible when one item is selected, and it is not a + // running notebook. + // TODO(nhdaly): Add support for moving multiple items at once. + if (selected.length === 1 && !has_running_notebook) { + $('.move-button').css('display', 'inline-block'); + } else { + $('.move-button').css('display', 'none'); + } + // Shutdown is only visible when one or more notebooks running notebooks // are selected and no non-notebook items are selected. if (has_running_notebook && !(has_file || has_directory)) { @@ -765,6 +775,7 @@ define([ } }); input.focus(); + // Highlight the filename (up to the filetype suffix) in the input field. if (input.val().indexOf(".") > 0) { input[0].setSelectionRange(0,input.val().indexOf(".")); } else { @@ -774,6 +785,71 @@ define([ }); }; + NotebookList.prototype.move_selected = function() { + var that = this; + + // TODO(nhdaly): Support moving multiple items at once. + if (that.selected.length !== 1){ + return; + } + + var item_path = that.selected[0].path; + var item_name = that.selected[0].name; + var item_type = that.selected[0].type; + + // Open a dialog to enter the new path, with current path as default. + var input = $('').attr('type','text').attr('size','25').addClass('form-control') + .val(utils.url_path_join('/', that.notebook_path)); + var dialog_body = $('
').append( + $("").addClass("rename-message") + .text('Enter new destination directory path for '+ item_type + ':') + ).append( + $("