##// END OF EJS Templates
Make Contents.new more generic
Thomas Kluyver -
Show More
@@ -89,8 +89,8 b' define(['
89 this.element.find('#new_notebook').click(function () {
89 this.element.find('#new_notebook').click(function () {
90 // Create a new notebook in the same path as the current
90 // Create a new notebook in the same path as the current
91 // notebook's path.
91 // notebook's path.
92 that.contents.new_notebook(that.notebook.notebook_path,
92 that.contents.new(that.notebook.notebook_path, null, {
93 {
93 ext: ".ipynb",
94 success: function (data) {
94 success: function (data) {
95 window.open(
95 window.open(
96 utils.url_join_encode(
96 utils.url_join_encode(
@@ -97,12 +97,23 b' define(['
97 *
97 *
98 * @method scroll_to_cell
98 * @method scroll_to_cell
99 * @param {String} path The path to create the new notebook at
99 * @param {String} path The path to create the new notebook at
100 * @param {String} name Name for new file. Chosen by server if unspecified.
101 * @param {Object} options:
102 * ext: file extension to use if name unspecified
100 */
103 */
101 Contents.prototype.new_notebook = function(path, options) {
104 Contents.prototype.new = function(path, name, options) {
102 var error = options.error || function() {};
105 var method, data;
106 if (name) {
107 method = "PUT";
108 } else {
109 method = "POST";
110 data = JSON.stringify({ext: options.ext || ".ipynb"});
111 }
112
103 var settings = {
113 var settings = {
104 processData : false,
114 processData : false,
105 type : "POST",
115 type : method,
116 data: data,
106 dataType : "json",
117 dataType : "json",
107 success : options.success || function() {},
118 success : options.success || function() {},
108 error : this.create_basic_error_handler(options.error)
119 error : this.create_basic_error_handler(options.error)
@@ -60,8 +60,8 b' require(['
60 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
60 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
61
61
62 $('#new_notebook').click(function (e) {
62 $('#new_notebook').click(function (e) {
63 contents.new_notebook(common_options.notebook_path,
63 contents.new(common_options.notebook_path, null, {
64 {
64 ext: ".ipynb",
65 success: function (data) {
65 success: function (data) {
66 window.open(
66 window.open(
67 utils.url_join_encode(
67 utils.url_join_encode(
General Comments 0
You need to be logged in to leave comments. Login now