diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js
index a4c318f..f522a8b 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 7ef34be..a592aeb 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -248,15 +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);
- this.add_duplicate_button(item);
} else {
- this.add_shutdown_button(item, this.sessions[path_name]);
+ this.add_shutdown_button(item, this.sessions[path]);
}
}
};
@@ -311,20 +312,20 @@ define([
};
NotebookList.prototype.add_duplicate_button = function (item) {
- var new_buttons = $('').addClass("btn-group pull-right");
var notebooklist = this;
- var duplicate_button = $("").text("Duplicate").addClass("btn btn-defaultbtn-xs").
+ var duplicate_button = $("").text("Duplicate").addClass("btn btn-default btn-xs").
click(function (e) {
// $(this) is the button that was clicked.
var that = $(this);
// We use the nbname and notebook_id from the parent notebook_item element's
// data because the outer scopes values change as we iterate through the loop.
var parent_item = that.parents('div.list_item');
- var nbname = parent_item.data('nbname');
- var message = 'Are you sure you want to duplicate the notebook: ' + nbname + '?';
- var copy_from = {'copy_from' : nbname}
+ var name = parent_item.data('name');
+ var path = parent_item.data('path');
+ var message = 'Are you sure you want to duplicate ' + name + '?';
+ var copy_from = {copy_from : path};
IPython.dialog.modal({
- title : "Duplicate notebook",
+ title : "Duplicate " + name,
body : message,
buttons : {
Duplicate : {
@@ -336,13 +337,13 @@ define([
type : "POST",
dataType : "json",
data : JSON.stringify(copy_from),
- success : function (data, status, xhr) {
+ success : function () {
notebooklist.load_list();
}
};
var url = utils.url_join_encode(
notebooklist.base_url,
- 'api/notebooks',
+ 'api/contents',
notebooklist.notebook_path
);
$.ajax(url, settings);
diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js
index 2f3e623..34ef78c 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