Show More
@@ -5,8 +5,9 b' define([' | |||
|
5 | 5 | 'base/js/namespace', |
|
6 | 6 | 'jquery', |
|
7 | 7 | 'base/js/utils', |
|
8 | 'base/js/dialog', | |
|
8 | 9 | 'bootstrap', |
|
9 | ], function(IPython, $, utils, bootstrap) { | |
|
10 | ], function(IPython, $, utils, dialog, bootstrap) { | |
|
10 | 11 | "use strict"; |
|
11 | 12 | |
|
12 | 13 | var MenuBar = function (selector, options) { |
@@ -38,11 +39,30 b' define([' | |||
|
38 | 39 | }; |
|
39 | 40 | |
|
40 | 41 | MenuBar.prototype.bind_events = function () { |
|
41 | /** | |
|
42 | * File | |
|
43 | */ | |
|
44 | 42 | var that = this; |
|
45 | 43 | var editor = that.editor; |
|
44 | ||
|
45 | // File | |
|
46 | this.element.find('#new-file').click(function () { | |
|
47 | var w = window.open(); | |
|
48 | // Create a new file in the current directory | |
|
49 | var parent = utils.url_path_split(editor.file_path)[0]; | |
|
50 | editor.contents.new_untitled(parent, {type: "file"}).then( | |
|
51 | function (data) { | |
|
52 | w.location = utils.url_join_encode( | |
|
53 | that.base_url, 'edit', data.path | |
|
54 | ); | |
|
55 | }, | |
|
56 | function(error) { | |
|
57 | w.close(); | |
|
58 | dialog.modal({ | |
|
59 | title : 'Creating New File Failed', | |
|
60 | body : "The error was: " + error.message, | |
|
61 | buttons : {'OK' : {'class' : 'btn-primary'}} | |
|
62 | }); | |
|
63 | } | |
|
64 | ); | |
|
65 | }); | |
|
46 | 66 | this.element.find('#save-file').click(function () { |
|
47 | 67 | editor.save(); |
|
48 | 68 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now