##// END OF EJS Templates
Merge pull request #6855 from takluyver/new-notebook-async...
Min RK -
r18787:7155c4a1 merge
parent child Browse files
Show More
@@ -88,19 +88,19 b' define(['
88 // File
88 // File
89 var that = this;
89 var that = this;
90 this.element.find('#new_notebook').click(function () {
90 this.element.find('#new_notebook').click(function () {
91 var w = window.open();
91 // Create a new notebook in the same path as the current
92 // Create a new notebook in the same path as the current
92 // notebook's path.
93 // notebook's path.
93 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
94 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
94 that.contents.new_untitled(parent, {
95 that.contents.new_untitled(parent, {
95 type: "notebook",
96 type: "notebook",
96 extra_settings: {async: false}, // So we can open a new window afterwards
97 success: function (data) {
97 success: function (data) {
98 window.open(
98 w.location = utils.url_join_encode(
99 utils.url_join_encode(
100 that.base_url, 'notebooks', data.path
99 that.base_url, 'notebooks', data.path
101 ), '_blank');
100 );
102 },
101 },
103 error: function(error) {
102 error: function(error) {
103 w.close();
104 dialog.modal({
104 dialog.modal({
105 title : 'Creating Notebook Failed',
105 title : 'Creating Notebook Failed',
106 body : "The error was: " + error.message,
106 body : "The error was: " + error.message,
@@ -1892,7 +1892,7 b' define(['
1892 *
1892 *
1893 * @method save_notebook
1893 * @method save_notebook
1894 */
1894 */
1895 Notebook.prototype.save_notebook = function (extra_settings) {
1895 Notebook.prototype.save_notebook = function () {
1896 // Create a JSON model to be sent to the server.
1896 // Create a JSON model to be sent to the server.
1897 var model = {
1897 var model = {
1898 type : "notebook",
1898 type : "notebook",
@@ -1903,7 +1903,6 b' define(['
1903
1903
1904 var that = this;
1904 var that = this;
1905 this.contents.save(this.notebook_path, model, {
1905 this.contents.save(this.notebook_path, model, {
1906 extra_settings: extra_settings,
1907 success: $.proxy(this.save_notebook_success, this, start),
1906 success: $.proxy(this.save_notebook_success, this, start),
1908 error: function (error) {
1907 error: function (error) {
1909 that.events.trigger('notebook_save_failed.Notebook', error);
1908 that.events.trigger('notebook_save_failed.Notebook', error);
@@ -1977,7 +1976,7 b' define(['
1977 *
1976 *
1978 * @method trust_notebook
1977 * @method trust_notebook
1979 */
1978 */
1980 Notebook.prototype.trust_notebook = function (extra_settings) {
1979 Notebook.prototype.trust_notebook = function () {
1981 var body = $("<div>").append($("<p>")
1980 var body = $("<div>").append($("<p>")
1982 .text("A trusted IPython notebook may execute hidden malicious code ")
1981 .text("A trusted IPython notebook may execute hidden malicious code ")
1983 .append($("<strong>")
1982 .append($("<strong>")
@@ -2024,15 +2023,18 b' define(['
2024
2023
2025 Notebook.prototype.copy_notebook = function(){
2024 Notebook.prototype.copy_notebook = function(){
2026 var base_url = this.base_url;
2025 var base_url = this.base_url;
2026 var w = window.open();
2027 var parent = utils.url_path_split(this.notebook_path)[0];
2027 var parent = utils.url_path_split(this.notebook_path)[0];
2028 this.contents.copy(this.notebook_path, parent, {
2028 this.contents.copy(this.notebook_path, parent, {
2029 // synchronous so we can open a new window on success
2030 extra_settings: {async: false},
2031 success: function (data) {
2029 success: function (data) {
2032 window.open(utils.url_join_encode(
2030 w.location = utils.url_join_encode(
2033 base_url, 'notebooks', data.path
2031 base_url, 'notebooks', data.path
2034 ), '_blank');
2032 );
2035 }
2033 },
2034 error : function(error) {
2035 w.close();
2036 console.log(error);
2037 },
2036 });
2038 });
2037 };
2039 };
2038
2040
@@ -114,9 +114,6 b' define(['
114 success : options.success || function() {},
114 success : options.success || function() {},
115 error : this.create_basic_error_handler(options.error)
115 error : this.create_basic_error_handler(options.error)
116 };
116 };
117 if (options.extra_settings) {
118 $.extend(settings, options.extra_settings);
119 }
120 $.ajax(this.api_url(path), settings);
117 $.ajax(this.api_url(path), settings);
121 };
118 };
122
119
@@ -165,9 +162,6 b' define(['
165 success : options.success || function() {},
162 success : options.success || function() {},
166 error : this.create_basic_error_handler(options.error)
163 error : this.create_basic_error_handler(options.error)
167 };
164 };
168 if (options.extra_settings) {
169 $.extend(settings, options.extra_settings);
170 }
171 var url = this.api_url(path);
165 var url = this.api_url(path);
172 $.ajax(url, settings);
166 $.ajax(url, settings);
173 };
167 };
@@ -185,9 +179,6 b' define(['
185 success: options.success || function() {},
179 success: options.success || function() {},
186 error: this.create_basic_error_handler(options.error)
180 error: this.create_basic_error_handler(options.error)
187 };
181 };
188 if (options.extra_settings) {
189 $.extend(settings, options.extra_settings);
190 }
191 $.ajax(url, settings);
182 $.ajax(url, settings);
192 };
183 };
193
184
@@ -64,17 +64,16 b' require(['
64 var login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
64 var login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
65
65
66 $('#new_notebook').click(function (e) {
66 $('#new_notebook').click(function (e) {
67 var w = window.open();
67 contents.new_untitled(common_options.notebook_path, {
68 contents.new_untitled(common_options.notebook_path, {
68 type: "notebook",
69 type: "notebook",
69 extra_settings: {async: false}, // So we can open a new window afterwards
70 success: function (data) {
70 success: function (data) {
71 window.open(
71 w.location = utils.url_join_encode(
72 utils.url_join_encode(
72 common_options.base_url, 'notebooks', data.path
73 common_options.base_url, 'notebooks',
73 );
74 data.path
75 ), '_blank');
76 },
74 },
77 error: function(error) {
75 error: function(error) {
76 w.close();
78 dialog.modal({
77 dialog.modal({
79 title : 'Creating Notebook Failed',
78 title : 'Creating Notebook Failed',
80 body : "The error was: " + error.message,
79 body : "The error was: " + error.message,
@@ -318,7 +318,7 b' define(['
318 // We use the filename from the parent list_item element's
318 // We use the filename from the parent list_item element's
319 // data because the outer scope's values change as we iterate through the loop.
319 // data because the outer scope's values change as we iterate through the loop.
320 var parent_item = that.parents('div.list_item');
320 var parent_item = that.parents('div.list_item');
321 var name = parent_item.data('nbname');
321 var name = parent_item.data('name');
322 var path = parent_item.data('path');
322 var path = parent_item.data('path');
323 var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
323 var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
324 dialog.modal({
324 dialog.modal({
@@ -345,7 +345,7 b' define(['
345
345
346 NotebookList.prototype.notebook_deleted = function(path) {
346 NotebookList.prototype.notebook_deleted = function(path) {
347 // Remove the deleted notebook.
347 // Remove the deleted notebook.
348 $( ":data(nbname)" ).each(function() {
348 $( ":data(path)" ).each(function() {
349 var element = $(this);
349 var element = $(this);
350 if (element.data("path") == path) {
350 if (element.data("path") == path) {
351 element.remove();
351 element.remove();
General Comments 0
You need to be logged in to leave comments. Login now