Show More
@@ -1,515 +1,498 b'' | |||
|
1 | 1 | // Copyright (c) IPython Development Team. |
|
2 | 2 | // Distributed under the terms of the Modified BSD License. |
|
3 | 3 | |
|
4 | 4 | define([ |
|
5 | 5 | 'base/js/namespace', |
|
6 | 6 | 'jquery', |
|
7 | 7 | 'base/js/utils', |
|
8 | 8 | 'base/js/dialog', |
|
9 | 9 | ], function(IPython, $, utils, dialog) { |
|
10 | 10 | "use strict"; |
|
11 | 11 | |
|
12 | 12 | var NotebookList = function (selector, options) { |
|
13 | 13 | // Constructor |
|
14 | 14 | // |
|
15 | 15 | // Parameters: |
|
16 | 16 | // selector: string |
|
17 | 17 | // options: dictionary |
|
18 | 18 | // Dictionary of keyword arguments. |
|
19 | 19 | // session_list: SessionList instance |
|
20 | 20 | // element_name: string |
|
21 | 21 | // base_url: string |
|
22 | 22 | // notebook_path: string |
|
23 | 23 | // contents: Contents instance |
|
24 | 24 | var that = this; |
|
25 | 25 | this.session_list = options.session_list; |
|
26 | 26 | // allow code re-use by just changing element_name in kernellist.js |
|
27 | 27 | this.element_name = options.element_name || 'notebook'; |
|
28 | 28 | this.selector = selector; |
|
29 | 29 | if (this.selector !== undefined) { |
|
30 | 30 | this.element = $(selector); |
|
31 | 31 | this.style(); |
|
32 | 32 | this.bind_events(); |
|
33 | 33 | } |
|
34 | 34 | this.notebooks_list = []; |
|
35 | 35 | this.sessions = {}; |
|
36 | 36 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
37 | 37 | this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); |
|
38 | 38 | this.contents = options.contents; |
|
39 | 39 | if (this.session_list && this.session_list.events) { |
|
40 | 40 | this.session_list.events.on('sessions_loaded.Dashboard', |
|
41 | 41 | function(e, d) { that.sessions_loaded(d); }); |
|
42 | 42 | } |
|
43 | 43 | }; |
|
44 | 44 | |
|
45 | 45 | NotebookList.prototype.style = function () { |
|
46 | 46 | var prefix = '#' + this.element_name; |
|
47 | 47 | $(prefix + '_toolbar').addClass('list_toolbar'); |
|
48 | 48 | $(prefix + '_list_info').addClass('toolbar_info'); |
|
49 | 49 | $(prefix + '_buttons').addClass('toolbar_buttons'); |
|
50 | 50 | $(prefix + '_list_header').addClass('list_header'); |
|
51 | 51 | this.element.addClass("list_container"); |
|
52 | 52 | }; |
|
53 | 53 | |
|
54 | 54 | |
|
55 | 55 | NotebookList.prototype.bind_events = function () { |
|
56 | 56 | var that = this; |
|
57 | 57 | $('#refresh_' + this.element_name + '_list').click(function () { |
|
58 | 58 | that.load_sessions(); |
|
59 | 59 | }); |
|
60 | 60 | this.element.bind('dragover', function () { |
|
61 | 61 | return false; |
|
62 | 62 | }); |
|
63 | 63 | this.element.bind('drop', function(event){ |
|
64 | 64 | that.handleFilesUpload(event,'drop'); |
|
65 | 65 | return false; |
|
66 | 66 | }); |
|
67 | 67 | }; |
|
68 | 68 | |
|
69 | 69 | NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) { |
|
70 | 70 | var that = this; |
|
71 | 71 | var files; |
|
72 | 72 | if(dropOrForm =='drop'){ |
|
73 | 73 | files = event.originalEvent.dataTransfer.files; |
|
74 | 74 | } else |
|
75 | 75 | { |
|
76 | 76 | files = event.originalEvent.target.files; |
|
77 | 77 | } |
|
78 | 78 | for (var i = 0; i < files.length; i++) { |
|
79 | 79 | var f = files[i]; |
|
80 | 80 | var name_and_ext = utils.splitext(f.name); |
|
81 | 81 | var file_ext = name_and_ext[1]; |
|
82 | 82 | |
|
83 | 83 | var reader = new FileReader(); |
|
84 | 84 | if (file_ext === '.ipynb') { |
|
85 | 85 | reader.readAsText(f); |
|
86 | 86 | } else { |
|
87 | 87 | // read non-notebook files as binary |
|
88 | 88 | reader.readAsArrayBuffer(f); |
|
89 | 89 | } |
|
90 | 90 | var item = that.new_item(0); |
|
91 | 91 | item.addClass('new-file'); |
|
92 | 92 | that.add_name_input(f.name, item, file_ext == '.ipynb' ? 'notebook' : 'file'); |
|
93 | 93 | // Store the list item in the reader so we can use it later |
|
94 | 94 | // to know which item it belongs to. |
|
95 | 95 | $(reader).data('item', item); |
|
96 | 96 | reader.onload = function (event) { |
|
97 | 97 | var item = $(event.target).data('item'); |
|
98 | 98 | that.add_file_data(event.target.result, item); |
|
99 | 99 | that.add_upload_button(item); |
|
100 | 100 | }; |
|
101 | 101 | reader.onerror = function (event) { |
|
102 | 102 | var item = $(event.target).data('item'); |
|
103 | 103 | var name = item.data('name'); |
|
104 | 104 | item.remove(); |
|
105 | 105 | dialog.modal({ |
|
106 | 106 | title : 'Failed to read file', |
|
107 | 107 | body : "Failed to read file '" + name + "'", |
|
108 | 108 | buttons : {'OK' : { 'class' : 'btn-primary' }} |
|
109 | 109 | }); |
|
110 | 110 | }; |
|
111 | 111 | } |
|
112 | 112 | // Replace the file input form wth a clone of itself. This is required to |
|
113 | 113 | // reset the form. Otherwise, if you upload a file, delete it and try to |
|
114 | 114 | // upload it again, the changed event won't fire. |
|
115 | 115 | var form = $('input.fileinput'); |
|
116 | 116 | form.replaceWith(form.clone(true)); |
|
117 | 117 | return false; |
|
118 | 118 | }; |
|
119 | 119 | |
|
120 | 120 | NotebookList.prototype.clear_list = function (remove_uploads) { |
|
121 | 121 | // Clears the navigation tree. |
|
122 | 122 | // |
|
123 | 123 | // Parameters |
|
124 | 124 | // remove_uploads: bool=False |
|
125 | 125 | // Should upload prompts also be removed from the tree. |
|
126 | 126 | if (remove_uploads) { |
|
127 | 127 | this.element.children('.list_item').remove(); |
|
128 | 128 | } else { |
|
129 | 129 | this.element.children('.list_item:not(.new-file)').remove(); |
|
130 | 130 | } |
|
131 | 131 | }; |
|
132 | 132 | |
|
133 | 133 | NotebookList.prototype.load_sessions = function(){ |
|
134 | 134 | this.session_list.load_sessions(); |
|
135 | 135 | }; |
|
136 | 136 | |
|
137 | 137 | |
|
138 | 138 | NotebookList.prototype.sessions_loaded = function(data){ |
|
139 | 139 | this.sessions = data; |
|
140 | 140 | this.load_list(); |
|
141 | 141 | }; |
|
142 | 142 | |
|
143 | 143 | NotebookList.prototype.load_list = function () { |
|
144 | 144 | var that = this; |
|
145 | 145 | this.contents.list_contents(that.notebook_path).then( |
|
146 | 146 | $.proxy(this.draw_notebook_list, this), |
|
147 | 147 | function(error) { |
|
148 | 148 | that.draw_notebook_list({content: []}, "Server error: " + error.message); |
|
149 | 149 | } |
|
150 | 150 | ); |
|
151 | 151 | }; |
|
152 | 152 | |
|
153 | 153 | /** |
|
154 | 154 | * Draw the list of notebooks |
|
155 | 155 | * @method draw_notebook_list |
|
156 | 156 | * @param {Array} list An array of dictionaries representing files or |
|
157 | 157 | * directories. |
|
158 | 158 | * @param {String} error_msg An error message |
|
159 | 159 | */ |
|
160 | 160 | NotebookList.prototype.draw_notebook_list = function (list, error_msg) { |
|
161 | 161 | var message = error_msg || 'Notebook list empty.'; |
|
162 | 162 | var item = null; |
|
163 | 163 | var model = null; |
|
164 | 164 | var len = list.content.length; |
|
165 | 165 | this.clear_list(); |
|
166 | 166 | var n_uploads = this.element.children('.list_item').length; |
|
167 | 167 | if (len === 0) { |
|
168 | 168 | item = this.new_item(0); |
|
169 | 169 | var span12 = item.children().first(); |
|
170 | 170 | span12.empty(); |
|
171 | 171 | span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message)); |
|
172 | 172 | } |
|
173 | 173 | var path = this.notebook_path; |
|
174 | 174 | var offset = n_uploads; |
|
175 | 175 | if (path !== '') { |
|
176 | 176 | item = this.new_item(offset); |
|
177 | 177 | model = { |
|
178 | 178 | type: 'directory', |
|
179 | 179 | name: '..', |
|
180 | 180 | path: utils.url_path_split(path)[0], |
|
181 | 181 | }; |
|
182 | 182 | this.add_link(model, item); |
|
183 | 183 | offset += 1; |
|
184 | 184 | } |
|
185 | 185 | for (var i=0; i<len; i++) { |
|
186 | 186 | model = list.content[i]; |
|
187 | 187 | item = this.new_item(i+offset); |
|
188 | 188 | this.add_link(model, item); |
|
189 | 189 | } |
|
190 | 190 | }; |
|
191 | 191 | |
|
192 | 192 | |
|
193 | 193 | NotebookList.prototype.new_item = function (index) { |
|
194 | 194 | var item = $('<div/>').addClass("list_item").addClass("row"); |
|
195 | 195 | // item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix'); |
|
196 | 196 | // item.css('border-top-style','none'); |
|
197 | 197 | item.append($("<div/>").addClass("col-md-12").append( |
|
198 | 198 | $('<i/>').addClass('item_icon') |
|
199 | 199 | ).append( |
|
200 | 200 | $("<a/>").addClass("item_link").append( |
|
201 | 201 | $("<span/>").addClass("item_name") |
|
202 | 202 | ) |
|
203 | 203 | ).append( |
|
204 | 204 | $('<div/>').addClass("item_buttons btn-group pull-right") |
|
205 | 205 | )); |
|
206 | 206 | |
|
207 | 207 | if (index === -1) { |
|
208 | 208 | this.element.append(item); |
|
209 | 209 | } else { |
|
210 | 210 | this.element.children().eq(index).after(item); |
|
211 | 211 | } |
|
212 | 212 | return item; |
|
213 | 213 | }; |
|
214 | 214 | |
|
215 | 215 | |
|
216 | 216 | NotebookList.icons = { |
|
217 | 217 | directory: 'folder_icon', |
|
218 | 218 | notebook: 'notebook_icon', |
|
219 | 219 | file: 'file_icon', |
|
220 | 220 | }; |
|
221 | 221 | |
|
222 | 222 | NotebookList.uri_prefixes = { |
|
223 | 223 | directory: 'tree', |
|
224 | 224 | notebook: 'notebooks', |
|
225 | 225 | file: 'files', |
|
226 | 226 | }; |
|
227 | 227 | |
|
228 | 228 | |
|
229 | 229 | NotebookList.prototype.add_link = function (model, item) { |
|
230 | 230 | var path = model.path, |
|
231 | 231 | name = model.name; |
|
232 | 232 | item.data('name', name); |
|
233 | 233 | item.data('path', path); |
|
234 | 234 | item.find(".item_name").text(name); |
|
235 | 235 | var icon = NotebookList.icons[model.type]; |
|
236 | 236 | var uri_prefix = NotebookList.uri_prefixes[model.type]; |
|
237 | 237 | item.find(".item_icon").addClass(icon).addClass('icon-fixed-width'); |
|
238 | 238 | var link = item.find("a.item_link") |
|
239 | 239 | .attr('href', |
|
240 | 240 | utils.url_join_encode( |
|
241 | 241 | this.base_url, |
|
242 | 242 | uri_prefix, |
|
243 | 243 | path |
|
244 | 244 | ) |
|
245 | 245 | ); |
|
246 | 246 | // directory nav doesn't open new tabs |
|
247 | 247 | // files, notebooks do |
|
248 | 248 | if (model.type !== "directory") { |
|
249 | 249 | link.attr('target','_blank'); |
|
250 | 250 | } |
|
251 | 251 | if (model.type !== 'directory') { |
|
252 | 252 | this.add_duplicate_button(item); |
|
253 | 253 | } |
|
254 | 254 | if (model.type == 'file') { |
|
255 | 255 | this.add_delete_button(item); |
|
256 | 256 | } else if (model.type == 'notebook') { |
|
257 | 257 | if (this.sessions[path] === undefined){ |
|
258 | 258 | this.add_delete_button(item); |
|
259 | 259 | } else { |
|
260 | 260 | this.add_shutdown_button(item, this.sessions[path]); |
|
261 | 261 | } |
|
262 | 262 | } |
|
263 | 263 | }; |
|
264 | 264 | |
|
265 | 265 | |
|
266 | 266 | NotebookList.prototype.add_name_input = function (name, item, icon_type) { |
|
267 | 267 | item.data('name', name); |
|
268 | 268 | item.find(".item_icon").addClass(NotebookList.icons[icon_type]).addClass('icon-fixed-width'); |
|
269 | 269 | item.find(".item_name").empty().append( |
|
270 | 270 | $('<input/>') |
|
271 | 271 | .addClass("filename_input") |
|
272 | 272 | .attr('value', name) |
|
273 | 273 | .attr('size', '30') |
|
274 | 274 | .attr('type', 'text') |
|
275 | 275 | .keyup(function(event){ |
|
276 | 276 | if(event.keyCode == 13){item.find('.upload_button').click();} |
|
277 | 277 | else if(event.keyCode == 27){item.remove();} |
|
278 | 278 | }) |
|
279 | 279 | ); |
|
280 | 280 | }; |
|
281 | 281 | |
|
282 | 282 | |
|
283 | 283 | NotebookList.prototype.add_file_data = function (data, item) { |
|
284 | 284 | item.data('filedata', data); |
|
285 | 285 | }; |
|
286 | 286 | |
|
287 | 287 | |
|
288 | 288 | NotebookList.prototype.add_shutdown_button = function (item, session) { |
|
289 | 289 | var that = this; |
|
290 | 290 | var shutdown_button = $("<button/>").text("Shutdown").addClass("btn btn-xs btn-danger"). |
|
291 | 291 | click(function (e) { |
|
292 | 292 | var settings = { |
|
293 | 293 | processData : false, |
|
294 | 294 | cache : false, |
|
295 | 295 | type : "DELETE", |
|
296 | 296 | dataType : "json", |
|
297 | 297 | success : function () { |
|
298 | 298 | that.load_sessions(); |
|
299 | 299 | }, |
|
300 | 300 | error : utils.log_ajax_error, |
|
301 | 301 | }; |
|
302 | 302 | var url = utils.url_join_encode( |
|
303 | 303 | that.base_url, |
|
304 | 304 | 'api/sessions', |
|
305 | 305 | session |
|
306 | 306 | ); |
|
307 | 307 | $.ajax(url, settings); |
|
308 | 308 | return false; |
|
309 | 309 | }); |
|
310 | // var new_buttons = item.find('a'); // shutdown_button; | |
|
311 | 310 | item.find(".item_buttons").append(shutdown_button); |
|
312 | 311 | }; |
|
313 | 312 | |
|
314 | 313 | NotebookList.prototype.add_duplicate_button = function (item) { |
|
315 | 314 | var notebooklist = this; |
|
316 | 315 | var duplicate_button = $("<button/>").text("Duplicate").addClass("btn btn-default btn-xs"). |
|
317 | 316 | click(function (e) { |
|
318 | 317 | // $(this) is the button that was clicked. |
|
319 | 318 | 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 name = parent_item.data('name'); | |
|
324 | var path = parent_item.data('path'); | |
|
319 | var name = item.data('name'); | |
|
320 | var path = item.data('path'); | |
|
325 | 321 | var message = 'Are you sure you want to duplicate ' + name + '?'; |
|
326 | 322 | var copy_from = {copy_from : path}; |
|
327 | 323 | IPython.dialog.modal({ |
|
328 | 324 | title : "Duplicate " + name, |
|
329 | 325 | body : message, |
|
330 | 326 | buttons : { |
|
331 | 327 | Duplicate : { |
|
332 | 328 | class: "btn-primary", |
|
333 | 329 | click: function() { |
|
334 | var settings = { | |
|
335 |
|
|
|
336 |
|
|
|
337 | type : "POST", | |
|
338 | dataType : "json", | |
|
339 | data : JSON.stringify(copy_from), | |
|
340 | success : function () { | |
|
341 | notebooklist.load_list(); | |
|
342 | } | |
|
343 | }; | |
|
344 | var url = utils.url_join_encode( | |
|
345 | notebooklist.base_url, | |
|
346 | 'api/contents', | |
|
347 | notebooklist.notebook_path | |
|
348 | ); | |
|
349 | $.ajax(url, settings); | |
|
330 | notebooklist.contents.copy(path, notebooklist.notebook_path).then(function () { | |
|
331 | notebooklist.load_list(); | |
|
332 | }); | |
|
350 | 333 | } |
|
351 | 334 | }, |
|
352 | 335 | Cancel : {} |
|
353 | 336 | } |
|
354 | 337 | }); |
|
355 | 338 | return false; |
|
356 | 339 | }); |
|
357 | 340 | item.find(".item_buttons").append(duplicate_button); |
|
358 | 341 | }; |
|
359 | 342 | |
|
360 | 343 | NotebookList.prototype.add_delete_button = function (item) { |
|
361 | 344 | var notebooklist = this; |
|
362 | 345 | var delete_button = $("<button/>").text("Delete").addClass("btn btn-default btn-xs"). |
|
363 | 346 | click(function (e) { |
|
364 | 347 | // $(this) is the button that was clicked. |
|
365 | 348 | var that = $(this); |
|
366 | 349 | // We use the filename from the parent list_item element's |
|
367 | 350 | // data because the outer scope's values change as we iterate through the loop. |
|
368 | 351 | var parent_item = that.parents('div.list_item'); |
|
369 | 352 | var name = parent_item.data('name'); |
|
370 | 353 | var path = parent_item.data('path'); |
|
371 | 354 | var message = 'Are you sure you want to permanently delete the file: ' + name + '?'; |
|
372 | 355 | dialog.modal({ |
|
373 | 356 | title : "Delete file", |
|
374 | 357 | body : message, |
|
375 | 358 | buttons : { |
|
376 | 359 | Delete : { |
|
377 | 360 | class: "btn-danger", |
|
378 | 361 | click: function() { |
|
379 | 362 | notebooklist.contents.delete(path).then( |
|
380 | 363 | function() { |
|
381 | 364 | notebooklist.notebook_deleted(path); |
|
382 | 365 | } |
|
383 | 366 | ); |
|
384 | 367 | } |
|
385 | 368 | }, |
|
386 | 369 | Cancel : {} |
|
387 | 370 | } |
|
388 | 371 | }); |
|
389 | 372 | return false; |
|
390 | 373 | }); |
|
391 | 374 | item.find(".item_buttons").append(delete_button); |
|
392 | 375 | }; |
|
393 | 376 | |
|
394 | 377 | NotebookList.prototype.notebook_deleted = function(path) { |
|
395 | 378 | // Remove the deleted notebook. |
|
396 | 379 | $( ":data(path)" ).each(function() { |
|
397 | 380 | var element = $(this); |
|
398 | 381 | if (element.data("path") == path) { |
|
399 | 382 | element.remove(); |
|
400 | 383 | } |
|
401 | 384 | }); |
|
402 | 385 | }; |
|
403 | 386 | |
|
404 | 387 | |
|
405 | 388 | NotebookList.prototype.add_upload_button = function (item) { |
|
406 | 389 | var that = this; |
|
407 | 390 | var upload_button = $('<button/>').text("Upload") |
|
408 | 391 | .addClass('btn btn-primary btn-xs upload_button') |
|
409 | 392 | .click(function (e) { |
|
410 | 393 | var filename = item.find('.item_name > input').val(); |
|
411 | 394 | var path = utils.url_path_join(that.notebook_path, filename); |
|
412 | 395 | var filedata = item.data('filedata'); |
|
413 | 396 | var format = 'text'; |
|
414 | 397 | if (filename.length === 0 || filename[0] === '.') { |
|
415 | 398 | dialog.modal({ |
|
416 | 399 | title : 'Invalid file name', |
|
417 | 400 | body : "File names must be at least one character and not start with a dot", |
|
418 | 401 | buttons : {'OK' : { 'class' : 'btn-primary' }} |
|
419 | 402 | }); |
|
420 | 403 | return false; |
|
421 | 404 | } |
|
422 | 405 | if (filedata instanceof ArrayBuffer) { |
|
423 | 406 | // base64-encode binary file data |
|
424 | 407 | var bytes = ''; |
|
425 | 408 | var buf = new Uint8Array(filedata); |
|
426 | 409 | var nbytes = buf.byteLength; |
|
427 | 410 | for (var i=0; i<nbytes; i++) { |
|
428 | 411 | bytes += String.fromCharCode(buf[i]); |
|
429 | 412 | } |
|
430 | 413 | filedata = btoa(bytes); |
|
431 | 414 | format = 'base64'; |
|
432 | 415 | } |
|
433 | 416 | var model = {}; |
|
434 | 417 | |
|
435 | 418 | var name_and_ext = utils.splitext(filename); |
|
436 | 419 | var file_ext = name_and_ext[1]; |
|
437 | 420 | var content_type; |
|
438 | 421 | if (file_ext === '.ipynb') { |
|
439 | 422 | model.type = 'notebook'; |
|
440 | 423 | model.format = 'json'; |
|
441 | 424 | try { |
|
442 | 425 | model.content = JSON.parse(filedata); |
|
443 | 426 | } catch (e) { |
|
444 | 427 | dialog.modal({ |
|
445 | 428 | title : 'Cannot upload invalid Notebook', |
|
446 | 429 | body : "The error was: " + e, |
|
447 | 430 | buttons : {'OK' : { |
|
448 | 431 | 'class' : 'btn-primary', |
|
449 | 432 | click: function () { |
|
450 | 433 | item.remove(); |
|
451 | 434 | } |
|
452 | 435 | }} |
|
453 | 436 | }); |
|
454 | 437 | return false; |
|
455 | 438 | } |
|
456 | 439 | content_type = 'application/json'; |
|
457 | 440 | } else { |
|
458 | 441 | model.type = 'file'; |
|
459 | 442 | model.format = format; |
|
460 | 443 | model.content = filedata; |
|
461 | 444 | content_type = 'application/octet-stream'; |
|
462 | 445 | } |
|
463 | 446 | filedata = item.data('filedata'); |
|
464 | 447 | |
|
465 | 448 | var on_success = function () { |
|
466 | 449 | item.removeClass('new-file'); |
|
467 | 450 | that.add_link(model, item); |
|
468 | 451 | that.add_delete_button(item); |
|
469 | 452 | that.session_list.load_sessions(); |
|
470 | 453 | }; |
|
471 | 454 | |
|
472 | 455 | var exists = false; |
|
473 | 456 | $.each(that.element.find('.list_item:not(.new-file)'), function(k,v){ |
|
474 | 457 | if ($(v).data('name') === filename) { exists = true; return false; } |
|
475 | 458 | }); |
|
476 | 459 | |
|
477 | 460 | if (exists) { |
|
478 | 461 | dialog.modal({ |
|
479 | 462 | title : "Replace file", |
|
480 | 463 | body : 'There is already a file named ' + filename + ', do you want to replace it?', |
|
481 | 464 | buttons : { |
|
482 | 465 | Overwrite : { |
|
483 | 466 | class: "btn-danger", |
|
484 | 467 | click: function () { |
|
485 | 468 | that.contents.save(path, model).then(on_success); |
|
486 | 469 | } |
|
487 | 470 | }, |
|
488 | 471 | Cancel : { |
|
489 | 472 | click: function() { item.remove(); } |
|
490 | 473 | } |
|
491 | 474 | } |
|
492 | 475 | }); |
|
493 | 476 | } else { |
|
494 | 477 | that.contents.save(path, model).then(on_success); |
|
495 | 478 | } |
|
496 | 479 | |
|
497 | 480 | return false; |
|
498 | 481 | }); |
|
499 | 482 | var cancel_button = $('<button/>').text("Cancel") |
|
500 | 483 | .addClass("btn btn-default btn-xs") |
|
501 | 484 | .click(function (e) { |
|
502 | 485 | item.remove(); |
|
503 | 486 | return false; |
|
504 | 487 | }); |
|
505 | 488 | item.find(".item_buttons").empty() |
|
506 | 489 | .append(upload_button) |
|
507 | 490 | .append(cancel_button); |
|
508 | 491 | }; |
|
509 | 492 | |
|
510 | 493 | |
|
511 | 494 | // Backwards compatability. |
|
512 | 495 | IPython.NotebookList = NotebookList; |
|
513 | 496 | |
|
514 | 497 | return {'NotebookList': NotebookList}; |
|
515 | 498 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now