##// END OF EJS Templates
Move saving to contentmanager...
Jeff Hemmelgarn -
Show More
@@ -118,6 +118,7 b' define(['
118 118 };
119 119
120 120 ContentManager.prototype.save_notebook = function(notebook, extra_settings) {
121 var that = notebook;
121 122 // Create a JSON model to be sent to the server.
122 123 var model = {};
123 124 model.name = notebook.notebook_name;
@@ -134,8 +135,8 b' define(['
134 135 type : "PUT",
135 136 data : JSON.stringify(model),
136 137 contentType: 'application/json',
137 success : $.proxy(notebook.save_notebook_success, this, start),
138 error : $.proxy(notebook.save_notebook_error, this)
138 success : $.proxy(notebook.save_notebook_success, that, start),
139 error : $.proxy(notebook.save_notebook_error, that)
139 140 };
140 141 if (extra_settings) {
141 142 for (var key in extra_settings) {
@@ -1904,41 +1904,7 b' define(['
1904 1904 * @method save_notebook
1905 1905 */
1906 1906 Notebook.prototype.save_notebook = function (extra_settings) {
1907 // Create a JSON model to be sent to the server.
1908 var model = {};
1909 model.name = this.notebook_name;
1910 model.path = this.notebook_path;
1911 model.type = 'notebook';
1912 model.format = 'json';
1913 model.content = this.toJSON();
1914 model.content.nbformat = this.nbformat;
1915 model.content.nbformat_minor = this.nbformat_minor;
1916 // time the ajax call for autosave tuning purposes.
1917 var start = new Date().getTime();
1918 // We do the call with settings so we can set cache to false.
1919 var settings = {
1920 processData : false,
1921 cache : false,
1922 type : "PUT",
1923 data : JSON.stringify(model),
1924 contentType: 'application/json',
1925 dataType : "json",
1926 success : $.proxy(this.save_notebook_success, this, start),
1927 error : $.proxy(this.save_notebook_error, this)
1928 };
1929 if (extra_settings) {
1930 for (var key in extra_settings) {
1931 settings[key] = extra_settings[key];
1932 }
1933 }
1934 this.events.trigger('notebook_saving.Notebook');
1935 var url = utils.url_join_encode(
1936 this.base_url,
1937 'api/contents',
1938 this.notebook_path,
1939 this.notebook_name
1940 );
1941 $.ajax(url, settings);
1907 this.content_manager.save_notebook(this, extra_settings);
1942 1908 };
1943 1909
1944 1910 /**
General Comments 0
You need to be logged in to leave comments. Login now