From 7f7e5b27968b6c35661f5137caca7f05e3375d8f 2015-01-28 20:26:13 From: Jonathan Frederic Date: 2015-01-28 20:26:13 Subject: [PATCH] Add some more comments... --- diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 2b47872..3ada771 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -329,7 +329,14 @@ define([ file: 'edit', }; + /** + * Handles when any row selector checkbox is toggled. + */ NotebookList.prototype._selection_changed = function() { + + // Use a JQuery selector to find each row with a checked checkbox. If + // we decide to add more checkboxes in the future, this code will need + // to be changed to distinguish which checkbox is the row selector. var selected = []; var has_running_notebook = false; var has_directory = false; @@ -337,6 +344,8 @@ define([ var that = this; $('.list_item :checked').each(function(index, item) { var parent = $(item).parent().parent(); + + // If the item doesn't have an upload button, it can be selected. if (parent.find('.upload_button').length === 0) { selected.push({ name: parent.data('name'), @@ -344,6 +353,8 @@ define([ type: parent.data('type') }); + // Set flags according to what is selected. Flags are later + // used to decide which action buttons are visible. has_running_notebook = has_running_notebook || (parent.data('type') == 'notebook' && that.sessions[parent.data('path')] !== undefined); has_file = has_file || parent.data('type') == 'file'; @@ -359,14 +370,15 @@ define([ $('.rename-button').css('display', 'none'); } - // Shutdown is only visible when one or more notebooks are visible. + // 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)) { $('.shutdown-button').css('display', 'inline-block'); } else { $('.shutdown-button').css('display', 'none'); } - // Duplicate isn't visible if a directory is selected. + // Duplicate isn't visible when a directory is selected. if (selected.length > 0 && !has_directory) { $('.duplicate-button').css('display', 'inline-block'); } else {