##// END OF EJS Templates
Rename callback parameters to success/error
Thomas Kluyver -
Show More
@@ -91,14 +91,14 b' define(['
91 91 // notebook's path.
92 92 that.contents.new_notebook(that.notebook.notebook_path,
93 93 {
94 success_callback: function (data, status, xhr) {
94 success: function (data, status, xhr) {
95 95 window.open(
96 96 utils.url_join_encode(
97 97 that.base_url, 'notebooks',
98 98 data.path, data.name
99 99 ), '_blank');
100 100 },
101 error_callback: function(xhr, status, error) {
101 error: function(xhr, status, error) {
102 102 var msg;
103 103 if (xhr.responseJSON && xhr.responseJSON.message) {
104 104 msg = xhr.responseJSON.message;
@@ -1922,8 +1922,8 b' define(['
1922 1922 var that = this;
1923 1923 this.contents.save_file(this.notebook_path, this.notebook_name, model, {
1924 1924 extra_settings: extra_settings,
1925 success_callback: $.proxy(this.save_notebook_success, this, start),
1926 error_callback: function (xhr, status, error) {
1925 success: $.proxy(this.save_notebook_success, this, start),
1926 error: function (xhr, status, error) {
1927 1927 that.events.trigger('notebook_save_failed.Notebook');
1928 1928 }
1929 1929 });
@@ -2078,12 +2078,12 b' define(['
2078 2078 var that = this;
2079 2079 this.contents.rename_file(this.notebook_path, this.notebook_name,
2080 2080 this.notebook_path, new_name, {
2081 success_callback: function (json, status, xhr) {
2081 success: function (json, status, xhr) {
2082 2082 var name = that.notebook_name = json.name;
2083 2083 that.session.rename_notebook(name, json.path);
2084 2084 that.events.trigger('notebook_renamed.Notebook', json);
2085 2085 },
2086 error_callback: $.proxy(this.rename_error, this)
2086 error: $.proxy(this.rename_error, this)
2087 2087 });
2088 2088 };
2089 2089
@@ -2134,8 +2134,8 b' define(['
2134 2134 this.notebook_path = notebook_path;
2135 2135 this.events.trigger('notebook_loading.Notebook');
2136 2136 this.contents.load_file(notebook_path, notebook_name, {
2137 success_callback: $.proxy(this.load_notebook_success, this),
2138 error_callback: $.proxy(this.load_notebook_error, this)
2137 success: $.proxy(this.load_notebook_success, this),
2138 error: $.proxy(this.load_notebook_error, this)
2139 2139 });
2140 2140 };
2141 2141
@@ -2349,8 +2349,8 b' define(['
2349 2349 Notebook.prototype.list_checkpoints = function () {
2350 2350 var that = this;
2351 2351 this.contents.list_checkpoints(this.notebook_path, this.notebook_name, {
2352 success_callback: $.proxy(this.list_checkpoints_success, this),
2353 error_callback: function(xhr, status, error_msg) {
2352 success: $.proxy(this.list_checkpoints_success, this),
2353 error: function(xhr, status, error_msg) {
2354 2354 that.events.trigger('list_checkpoints_failed.Notebook');
2355 2355 }
2356 2356 });
@@ -2383,8 +2383,8 b' define(['
2383 2383 Notebook.prototype.create_checkpoint = function () {
2384 2384 var that = this;
2385 2385 this.contents.create_checkpoint(this.notebook_path, this.notebook_name, {
2386 success_callback: $.proxy(this.create_checkpoint_success, this),
2387 error_callback: function (xhr, status, error_msg) {
2386 success: $.proxy(this.create_checkpoint_success, this),
2387 error: function (xhr, status, error_msg) {
2388 2388 that.events.trigger('checkpoint_failed.Notebook');
2389 2389 }
2390 2390 });
@@ -2456,8 +2456,8 b' define(['
2456 2456 var that = this;
2457 2457 this.contents.restore_checkpoint(this.notebook_path, this.notebook_name,
2458 2458 checkpoint, {
2459 success_callback: $.proxy(this.create_checkpoint_success, this),
2460 error_callback: function (xhr, status, error_msg) {
2459 success: $.proxy(this.create_checkpoint_success, this),
2460 error: function (xhr, status, error_msg) {
2461 2461 that.events.trigger('checkpoint_restore_failed.Notebook');
2462 2462 }
2463 2463 });
@@ -2487,8 +2487,8 b' define(['
2487 2487 var that = this;
2488 2488 this.contents.delete_checkpoint(this.notebook_path, this.notebook_name,
2489 2489 checkpoint, {
2490 success_callback: $.proxy(this.create_checkpoint_success, this),
2491 error_callback: function (xhr, status, error_msg) {
2490 success: $.proxy(this.create_checkpoint_success, this),
2491 error: function (xhr, status, error_msg) {
2492 2492 that.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
2493 2493 }
2494 2494 });
@@ -34,13 +34,13 b' define(['
34 34 /**
35 35 * Load a file.
36 36 *
37 * Calls success_callback with file JSON model, or error_callback with error.
37 * Calls success with file JSON model, or error with error.
38 38 *
39 39 * @method load_notebook
40 40 * @param {String} path
41 41 * @param {String} name
42 * @param {Function} success_callback
43 * @param {Function} error_callback
42 * @param {Function} success
43 * @param {Function} error
44 44 */
45 45 Contents.prototype.load_file = function (path, name, options) {
46 46 // We do the call with settings so we can set cache to false.
@@ -49,8 +49,8 b' define(['
49 49 cache : false,
50 50 type : "GET",
51 51 dataType : "json",
52 success : options.success_callback,
53 error : options.error_callback || function() {}
52 success : options.success,
53 error : options.error || function() {}
54 54 };
55 55 var url = this.api_url(path, name);
56 56 $.ajax(url, settings);
@@ -64,30 +64,30 b' define(['
64 64 * @param {String} path The path to create the new notebook at
65 65 */
66 66 Contents.prototype.new_notebook = function(path, options) {
67 var error_callback = options.error_callback || function() {};
67 var error = options.error || function() {};
68 68 var settings = {
69 69 processData : false,
70 70 cache : false,
71 71 type : "POST",
72 72 dataType : "json",
73 success : options.success_callback || function() {},
74 error : options.error_callback || function() {}
73 success : options.success || function() {},
74 error : options.error || function() {}
75 75 };
76 76 $.ajax(this.api_url(path), settings);
77 77 };
78 78
79 79 Contents.prototype.delete_file = function(name, path, options) {
80 var error_callback = options.error_callback || function() {};
80 var error = options.error || function() {};
81 81 var that = this;
82 82 var settings = {
83 83 processData : false,
84 84 cache : false,
85 85 type : "DELETE",
86 86 dataType : "json",
87 success : options.success_callback || function() {},
87 success : options.success || function() {},
88 88 error : function(xhr, status, error) {
89 89 utils.log_ajax_error(xhr, status, error);
90 error_callback(xhr, status, error);
90 error(xhr, status, error);
91 91 }
92 92 };
93 93 var url = this.api_url(path, name);
@@ -103,8 +103,8 b' define(['
103 103 data : JSON.stringify(data),
104 104 dataType: "json",
105 105 contentType: 'application/json',
106 success : options.success_callback || function() {},
107 error : options.error_callback || function() {}
106 success : options.success || function() {},
107 error : options.error || function() {}
108 108 };
109 109 var url = this.api_url(path, name);
110 110 $.ajax(url, settings);
@@ -118,8 +118,8 b' define(['
118 118 type : "PUT",
119 119 data : JSON.stringify(model),
120 120 contentType: 'application/json',
121 success : options.success_callback || function() {},
122 error : options.error_callback || function() {}
121 success : options.success || function() {},
122 error : options.error || function() {}
123 123 };
124 124 if (options.extra_settings) {
125 125 $.extend(settings, options.extra_settings);
@@ -136,8 +136,8 b' define(['
136 136 var url = this.api_url(path, name, 'checkpoints');
137 137 var settings = {
138 138 type : "POST",
139 success: options.success_callback || function() {},
140 error: options.error_callback || function() {}
139 success: options.success || function() {},
140 error: options.error || function() {}
141 141 };
142 142 $.ajax(url, settings);
143 143 };
@@ -146,8 +146,8 b' define(['
146 146 var url = this.api_url(path, name, 'checkpoints');
147 147 var settings = {
148 148 type : "GET",
149 success: options.success_callback,
150 error: options.error_callback || function() {}
149 success: options.success,
150 error: options.error || function() {}
151 151 };
152 152 $.ajax(url, settings);
153 153 };
@@ -156,8 +156,8 b' define(['
156 156 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
157 157 var settings = {
158 158 type : "POST",
159 success: options.success_callback || function() {},
160 error: options.error_callback || function() {}
159 success: options.success || function() {},
160 error: options.error || function() {}
161 161 };
162 162 $.ajax(url, settings);
163 163 };
@@ -166,8 +166,8 b' define(['
166 166 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
167 167 var settings = {
168 168 type : "DELETE",
169 success: options.success_callback || function() {},
170 error: options.error_callback || function() {}
169 success: options.success || function() {},
170 error: options.error || function() {}
171 171 };
172 172 $.ajax(url, settings);
173 173 };
@@ -190,7 +190,7 b' define(['
190 190 * @method list_notebooks
191 191 * @param {String} path The path to list notebooks in
192 192 * @param {Function} load_callback called with list of notebooks on success
193 * @param {Function} error_callback called with ajax results on error
193 * @param {Function} error called with ajax results on error
194 194 */
195 195 Contents.prototype.list_contents = function(path, options) {
196 196 var settings = {
@@ -198,8 +198,8 b' define(['
198 198 cache : false,
199 199 type : "GET",
200 200 dataType : "json",
201 success : options.success_callback,
202 error : options.error_callback || function() {}
201 success : options.success,
202 error : options.error || function() {}
203 203 };
204 204
205 205 $.ajax(this.api_url(path), settings);
@@ -62,14 +62,14 b' require(['
62 62 $('#new_notebook').button().click(function (e) {
63 63 contents.new_notebook(common_options.notebook_path,
64 64 {
65 success_callback: function (data, status, xhr) {
65 success: function (data, status, xhr) {
66 66 window.open(
67 67 utils.url_join_encode(
68 68 common_options.base_url, 'notebooks',
69 69 data.path, data.name
70 70 ), '_blank');
71 71 },
72 error_callback: function(xhr, status, error) {
72 error: function(xhr, status, error) {
73 73 var msg;
74 74 if (xhr.responseJSON && xhr.responseJSON.message) {
75 75 msg = xhr.responseJSON.message;
@@ -143,8 +143,8 b' define(['
143 143 NotebookList.prototype.load_list = function () {
144 144 var that = this
145 145 this.contents.list_contents(that.notebook_path, {
146 success_callback: $.proxy(this.draw_notebook_list, this),
147 error_callback: function(xhr, status, error) {
146 success: $.proxy(this.draw_notebook_list, this),
147 error: function(xhr, status, error) {
148 148 utils.log_ajax_error(xhr, status, error);
149 149 that.draw_notebook_list([], "Error connecting to server.");
150 150 }
@@ -332,7 +332,7 b' define(['
332 332 class: "btn-danger",
333 333 click: function() {
334 334 notebooklist.contents.delete_file(nbname, path, {
335 success_callback: function() {
335 success: function() {
336 336 notebooklist.notebook_deleted(path, nbname);
337 337 }
338 338 });
General Comments 0
You need to be logged in to leave comments. Login now