Show More
@@ -68,39 +68,20 define([ | |||
|
68 | 68 | * @method scroll_to_cell |
|
69 | 69 | * @param {String} path The path to create the new notebook at |
|
70 | 70 | */ |
|
71 | Contents.prototype.new_notebook = function(path) { | |
|
71 | Contents.prototype.new_notebook = function(path, options) { | |
|
72 | 72 | var base_url = this.base_url; |
|
73 | var success_callback = options.success_callback || function(data, status, xhr) {}; | |
|
74 | var error_callback = options.error_callback || function(xhr, status, error) {}; | |
|
73 | 75 | var settings = { |
|
74 | 76 | processData : false, |
|
75 | 77 | cache : false, |
|
76 | 78 | type : "POST", |
|
77 | 79 | dataType : "json", |
|
78 | 80 | async : false, |
|
79 |
success : |
|
|
80 | var notebook_name = data.name; | |
|
81 | window.open( | |
|
82 | utils.url_join_encode( | |
|
83 | base_url, | |
|
84 | 'notebooks', | |
|
85 | path, | |
|
86 | notebook_name | |
|
87 | ), | |
|
88 | '_blank' | |
|
89 | ); | |
|
90 | }, | |
|
81 | success : success_callback, | |
|
91 | 82 | error : function(xhr, status, error) { |
|
92 | 83 | utils.log_ajax_error(xhr, status, error); |
|
93 | var msg; | |
|
94 | if (xhr.responseJSON && xhr.responseJSON.message) { | |
|
95 | msg = xhr.responseJSON.message; | |
|
96 | } else { | |
|
97 | msg = xhr.statusText; | |
|
98 | } | |
|
99 | dialog.modal({ | |
|
100 | title : 'Creating Notebook Failed', | |
|
101 | body : "The error was: " + msg, | |
|
102 | buttons : {'OK' : {'class' : 'btn-primary'}} | |
|
103 | }); | |
|
84 | error_callback(xhr, status, error); | |
|
104 | 85 | } |
|
105 | 86 | }; |
|
106 | 87 | var url = utils.url_join_encode( |
@@ -89,7 +89,29 define([ | |||
|
89 | 89 | this.element.find('#new_notebook').click(function () { |
|
90 | 90 | // Create a new notebook in the same path as the current |
|
91 | 91 | // notebook's path. |
|
92 |
that.contents.new_notebook(that.notebook.notebook_path |
|
|
92 | that.contents.new_notebook(that.notebook.notebook_path, | |
|
93 | { | |
|
94 | success_callback: function (data, status, xhr) { | |
|
95 | window.open( | |
|
96 | utils.url_join_encode( | |
|
97 | common_options.base_url, 'notebooks', | |
|
98 | data.path, data.name | |
|
99 | ), '_blank'); | |
|
100 | }, | |
|
101 | error_callback: function(xhr, status, error) { | |
|
102 | var msg; | |
|
103 | if (xhr.responseJSON && xhr.responseJSON.message) { | |
|
104 | msg = xhr.responseJSON.message; | |
|
105 | } else { | |
|
106 | msg = xhr.statusText; | |
|
107 | } | |
|
108 | dialog.modal({ | |
|
109 | title : 'Creating Notebook Failed', | |
|
110 | body : "The error was: " + msg, | |
|
111 | buttons : {'OK' : {'class' : 'btn-primary'}} | |
|
112 | }); | |
|
113 | } | |
|
114 | }); | |
|
93 | 115 | }); |
|
94 | 116 | this.element.find('#open_notebook').click(function () { |
|
95 | 117 | window.open(utils.url_join_encode( |
@@ -60,7 +60,29 require([ | |||
|
60 | 60 | login_widget = new loginwidget.LoginWidget('#login_widget', common_options); |
|
61 | 61 | |
|
62 | 62 | $('#new_notebook').button().click(function (e) { |
|
63 |
contents.new_notebook(common_options.notebook_path |
|
|
63 | contents.new_notebook(common_options.notebook_path, | |
|
64 | { | |
|
65 | success_callback: function (data, status, xhr) { | |
|
66 | window.open( | |
|
67 | utils.url_join_encode( | |
|
68 | common_options.base_url, 'notebooks', | |
|
69 | data.path, data.name | |
|
70 | ), '_blank'); | |
|
71 | }, | |
|
72 | error_callback: function(xhr, status, error) { | |
|
73 | var msg; | |
|
74 | if (xhr.responseJSON && xhr.responseJSON.message) { | |
|
75 | msg = xhr.responseJSON.message; | |
|
76 | } else { | |
|
77 | msg = xhr.statusText; | |
|
78 | } | |
|
79 | dialog.modal({ | |
|
80 | title : 'Creating Notebook Failed', | |
|
81 | body : "The error was: " + msg, | |
|
82 | buttons : {'OK' : {'class' : 'btn-primary'}} | |
|
83 | }); | |
|
84 | } | |
|
85 | }); | |
|
64 | 86 | }); |
|
65 | 87 | |
|
66 | 88 | var interval_id=0; |
General Comments 0
You need to be logged in to leave comments.
Login now