diff --git a/IPython/html/static/notebook/js/savewidget.js b/IPython/html/static/notebook/js/savewidget.js
index f2cfb5c56..8c7f3338a 100644
--- a/IPython/html/static/notebook/js/savewidget.js
+++ b/IPython/html/static/notebook/js/savewidget.js
@@ -77,7 +77,6 @@ define([
notebook: options.notebook,
keyboard_manager: this.keyboard_manager,
buttons : {
- "Cancel": {},
"OK": {
class: "btn-primary",
click: function () {
@@ -92,7 +91,8 @@ define([
} else {
that.notebook.rename(new_name);
}
- }}
+ }},
+ "Cancel": {}
},
open : function (event, ui) {
var that = $(this);
diff --git a/IPython/html/static/style/style.min.css b/IPython/html/static/style/style.min.css
index 2430e1f85..8a9a28bcf 100644
--- a/IPython/html/static/style/style.min.css
+++ b/IPython/html/static/style/style.min.css
@@ -8070,6 +8070,9 @@ ul.breadcrumb span {
.item_buttons {
line-height: 1em;
}
+.item_buttons .btn {
+ min-width: 13ex;
+}
.toolbar_info {
height: 24px;
line-height: 24px;
diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js
index a4c318f58..f522a8b79 100644
--- a/IPython/html/static/tree/js/kernellist.js
+++ b/IPython/html/static/tree/js/kernellist.js
@@ -25,22 +25,25 @@ define([
KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
+ KernelList.prototype.add_duplicate_button = function () {
+ // do nothing
+ };
+
KernelList.prototype.sessions_loaded = function (d) {
this.sessions = d;
this.clear_list();
- var item, path_name;
- for (path_name in d) {
- if (!d.hasOwnProperty(path_name)) {
+ var item, path;
+ for (path in d) {
+ if (!d.hasOwnProperty(path)) {
// nothing is safe in javascript
continue;
}
item = this.new_item(-1);
this.add_link({
- name: path_name,
- path: '',
+ name: path,
+ path: path,
type: 'notebook',
}, item);
- this.add_shutdown_button(item, this.sessions[path_name]);
}
$('#running_list_header').toggle($.isEmptyObject(d));
};
diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js
index 8e727f50e..0447e615f 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -248,14 +248,16 @@ define([
if (model.type !== "directory") {
link.attr('target','_blank');
}
- var path_name = utils.url_path_join(path, name);
+ 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_name] === undefined){
+ if (this.sessions[path] === undefined){
this.add_delete_button(item);
} else {
- this.add_shutdown_button(item, this.sessions[path_name]);
+ this.add_shutdown_button(item, this.sessions[path]);
}
}
};
@@ -305,8 +307,37 @@ define([
$.ajax(url, settings);
return false;
});
- // var new_buttons = item.find('a'); // shutdown_button;
- item.find(".item_buttons").text("").append(shutdown_button);
+ item.find(".item_buttons").append(shutdown_button);
+ };
+
+ NotebookList.prototype.add_duplicate_button = function (item) {
+ var notebooklist = this;
+ var duplicate_button = $("").text("Duplicate").addClass("btn btn-default btn-xs").
+ click(function (e) {
+ // $(this) is the button that was clicked.
+ var that = $(this);
+ var name = item.data('name');
+ var path = item.data('path');
+ var message = 'Are you sure you want to duplicate ' + name + '?';
+ var copy_from = {copy_from : path};
+ IPython.dialog.modal({
+ title : "Duplicate " + name,
+ body : message,
+ buttons : {
+ Duplicate : {
+ class: "btn-primary",
+ click: function() {
+ notebooklist.contents.copy(path, notebooklist.notebook_path).then(function () {
+ notebooklist.load_list();
+ });
+ }
+ },
+ Cancel : {}
+ }
+ });
+ return false;
+ });
+ item.find(".item_buttons").append(duplicate_button);
};
NotebookList.prototype.add_delete_button = function (item) {
@@ -340,7 +371,7 @@ define([
});
return false;
});
- item.find(".item_buttons").text("").append(delete_button);
+ item.find(".item_buttons").append(delete_button);
};
NotebookList.prototype.notebook_deleted = function(path) {
diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js
index 2f3e62302..34ef78c8d 100644
--- a/IPython/html/static/tree/js/sessionlist.js
+++ b/IPython/html/static/tree/js/sessionlist.js
@@ -40,10 +40,7 @@ define([
var len = data.length;
var nb_path;
for (var i=0; i