Show More
@@ -254,6 +254,7 b' define([' | |||||
254 | } else if (model.type == 'notebook') { |
|
254 | } else if (model.type == 'notebook') { | |
255 | if(this.sessions[path_name] === undefined){ |
|
255 | if(this.sessions[path_name] === undefined){ | |
256 | this.add_delete_button(item); |
|
256 | this.add_delete_button(item); | |
|
257 | this.add_duplicate_button(item); | |||
257 | } else { |
|
258 | } else { | |
258 | this.add_shutdown_button(item, this.sessions[path_name]); |
|
259 | this.add_shutdown_button(item, this.sessions[path_name]); | |
259 | } |
|
260 | } | |
@@ -306,7 +307,53 b' define([' | |||||
306 | return false; |
|
307 | return false; | |
307 | }); |
|
308 | }); | |
308 | // var new_buttons = item.find('a'); // shutdown_button; |
|
309 | // var new_buttons = item.find('a'); // shutdown_button; | |
309 |
item.find(".item_buttons"). |
|
310 | item.find(".item_buttons").append(shutdown_button); | |
|
311 | }; | |||
|
312 | ||||
|
313 | NotebookList.prototype.add_duplicate_button = function (item) { | |||
|
314 | var new_buttons = $('<span/>').addClass("btn-group pull-right"); | |||
|
315 | var notebooklist = this; | |||
|
316 | var duplicate_button = $("<button/>").text("Duplicate").addClass("btn btn-defaultbtn-xs"). | |||
|
317 | click(function (e) { | |||
|
318 | // $(this) is the button that was clicked. | |||
|
319 | var that = $(this); | |||
|
320 | // We use the nbname and notebook_id from the parent notebook_item element's | |||
|
321 | // data because the outer scopes values change as we iterate through the loop. | |||
|
322 | var parent_item = that.parents('div.list_item'); | |||
|
323 | var nbname = parent_item.data('nbname'); | |||
|
324 | var message = 'Are you sure you want to duplicate the notebook: ' + nbname + '?'; | |||
|
325 | var copy_from = {'copy_from' : nbname} | |||
|
326 | IPython.dialog.modal({ | |||
|
327 | title : "Duplicate notebook", | |||
|
328 | body : message, | |||
|
329 | buttons : { | |||
|
330 | Duplicate : { | |||
|
331 | class: "btn-primary", | |||
|
332 | click: function() { | |||
|
333 | var settings = { | |||
|
334 | processData : false, | |||
|
335 | cache : false, | |||
|
336 | type : "POST", | |||
|
337 | dataType : "json", | |||
|
338 | data : JSON.stringify(copy_from), | |||
|
339 | success : function (data, status, xhr) { | |||
|
340 | notebooklist.load_list(); | |||
|
341 | } | |||
|
342 | }; | |||
|
343 | var url = utils.url_join_encode( | |||
|
344 | notebooklist.base_url, | |||
|
345 | 'api/notebooks', | |||
|
346 | notebooklist.notebook_path | |||
|
347 | ); | |||
|
348 | $.ajax(url, settings); | |||
|
349 | } | |||
|
350 | }, | |||
|
351 | Cancel : {} | |||
|
352 | } | |||
|
353 | }); | |||
|
354 | return false; | |||
|
355 | }); | |||
|
356 | item.find(".item_buttons").append(duplicate_button); | |||
310 | }; |
|
357 | }; | |
311 |
|
358 | |||
312 | NotebookList.prototype.add_delete_button = function (item) { |
|
359 | NotebookList.prototype.add_delete_button = function (item) { | |
@@ -340,7 +387,7 b' define([' | |||||
340 | }); |
|
387 | }); | |
341 | return false; |
|
388 | return false; | |
342 | }); |
|
389 | }); | |
343 |
item.find(".item_buttons"). |
|
390 | item.find(".item_buttons").append(delete_button); | |
344 | }; |
|
391 | }; | |
345 |
|
392 | |||
346 | NotebookList.prototype.notebook_deleted = function(path) { |
|
393 | NotebookList.prototype.notebook_deleted = function(path) { |
General Comments 0
You need to be logged in to leave comments.
Login now