From 7e65facd0756a0970ff0c66c0a6b32f7b3f6dfdb 2015-01-26 02:08:33 From: Jonathan Frederic Date: 2015-01-26 02:08:33 Subject: [PATCH] Add actions dropdown to tree view --- diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 10a937b..f8026cc 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -290,23 +290,20 @@ define([ path ) ); + + var can_duplicate = (model.type != 'directory'); + var can_rename = (model.type == 'directory'); + var can_delete = (model.type != 'notebook' || this.sessions[path] === undefined); + if (!can_delete) { + this.add_shutdown_button(item, this.sessions[path]); + } + this.add_actions_button(item, can_delete, can_duplicate, can_rename); + // directory nav doesn't open new tabs // files, notebooks do if (model.type !== "directory") { link.attr('target','_blank'); } - if (model.type !== 'directory') { - this.add_duplicate_button(item); - } - if (model.type == 'file') { - this.add_delete_button(item); - } else if (model.type == 'notebook') { - if (this.sessions[path] === undefined){ - this.add_delete_button(item); - } else { - this.add_shutdown_button(item, this.sessions[path]); - } - } }; @@ -357,68 +354,163 @@ define([ item.find(".item_buttons").append(shutdown_button); }; - NotebookList.prototype.add_duplicate_button = function (item) { + NotebookList.prototype.add_actions_button = function (item, can_delete, can_duplicate, can_rename) { + var group = $("
") + .addClass('btn-group') + .css('float', 'none') + .appendTo(item.find(".item_buttons")); + + var actions_button = $("