##// END OF EJS Templates
Cut out some superfluous events
Thomas Kluyver -
Show More
@@ -178,26 +178,6 define([
178 Notebook.prototype.bind_events = function () {
178 Notebook.prototype.bind_events = function () {
179 var that = this;
179 var that = this;
180
180
181 this.contents.events.on('notebook_rename_success.Contents',
182 function (event, data) {
183 var name = that.notebook_name = data.name;
184 var path = data.path;
185 that.session.rename_notebook(name, path);
186 that.events.trigger('notebook_renamed.Notebook', data);
187 });
188
189 this.contents.events.on('notebook_rename_error.Contents',
190 function (event, data) {
191 that.rename_error(data[0], data[1], data[2]);
192 });
193
194 this.contents.events.on('notebook_save_success.Contents',
195 $.proxy(this.save_notebook_success, this));
196
197 this.contents.events.on('notebook_save_error.Contents',
198 $.proxy(this.events.trigger, this.events,
199 'notebook_save_failed.Notebook'));
200
201 this.events.on('set_next_input.Notebook', function (event, data) {
181 this.events.on('set_next_input.Notebook', function (event, data) {
202 var index = that.find_cell_index(data.cell);
182 var index = that.find_cell_index(data.cell);
203 var new_cell = that.insert_cell_below('code',index);
183 var new_cell = that.insert_cell_below('code',index);
@@ -1942,12 +1922,9 define([
1942 var that = this;
1922 var that = this;
1943 this.contents.save_file(this.notebook_path, this.notebook_name, model, {
1923 this.contents.save_file(this.notebook_path, this.notebook_name, model, {
1944 extra_settings: extra_settings,
1924 extra_settings: extra_settings,
1945 success_callback: $.proxy(this.events.trigger, this.events,
1925 success_callback: $.proxy(this.save_notebook_success, this, start),
1946 'notebook_save_success.Contents',
1947 $.extend(model, { start : start })),
1948 error_callback: function (xhr, status, error) {
1926 error_callback: function (xhr, status, error) {
1949 that.events.trigger('notebook_save_error.Contents',
1927 that.events.trigger('notebook_save_failed.Notebook');
1950 [xhr, status, error, model]);
1951 }
1928 }
1952 });
1929 });
1953 };
1930 };
@@ -1956,11 +1933,12 define([
1956 * Success callback for saving a notebook.
1933 * Success callback for saving a notebook.
1957 *
1934 *
1958 * @method save_notebook_success
1935 * @method save_notebook_success
1959 * @param {Event} event The save notebook success event
1936 * @param {Integer} start Time when the save request start
1960 * @param {Object} data dictionary of event data
1937 * @param {Object} data JSON representation of a notebook
1961 * data.options start the time when the save request started
1938 * @param {String} status Description of response status
1939 * @param {jqXHR} xhr jQuery Ajax object
1962 */
1940 */
1963 Notebook.prototype.save_notebook_success = function (event, data) {
1941 Notebook.prototype.save_notebook_success = function (start, data, status, xhr) {
1964 this.set_dirty(false);
1942 this.set_dirty(false);
1965 if (data.message) {
1943 if (data.message) {
1966 // save succeeded, but validation failed.
1944 // save succeeded, but validation failed.
@@ -1987,7 +1965,7 define([
1987 });
1965 });
1988 }
1966 }
1989 this.events.trigger('notebook_saved.Notebook');
1967 this.events.trigger('notebook_saved.Notebook');
1990 this._update_autosave_interval(event.start);
1968 this._update_autosave_interval(start);
1991 if (this._checkpoint_after_save) {
1969 if (this._checkpoint_after_save) {
1992 this.create_checkpoint();
1970 this.create_checkpoint();
1993 this._checkpoint_after_save = false;
1971 this._checkpoint_after_save = false;
@@ -2013,18 +1991,6 define([
2013 }
1991 }
2014 }
1992 }
2015 };
1993 };
2016
2017 /**
2018 * Failure callback for saving a notebook.
2019 *
2020 * @method save_notebook_error
2021 * @param {jqXHR} xhr jQuery Ajax object
2022 * @param {String} status Description of response status
2023 * @param {String} error HTTP error message
2024 */
2025 Notebook.prototype.save_notebook_error = function (xhr, status, error) {
2026 this.events.trigger('notebook_save_failed.Notebook', [xhr, status, error]);
2027 };
2028
1994
2029 /**
1995 /**
2030 * Explicitly trust the output of this notebook.
1996 * Explicitly trust the output of this notebook.
@@ -2113,12 +2079,11 define([
2113 this.contents.rename_file(this.notebook_path, this.notebook_name,
2079 this.contents.rename_file(this.notebook_path, this.notebook_name,
2114 this.notebook_path, new_name, {
2080 this.notebook_path, new_name, {
2115 success_callback: function (json, status, xhr) {
2081 success_callback: function (json, status, xhr) {
2116 that.events.trigger('notebook_rename_success.Contents', json);
2082 var name = that.notebook_name = json.name;
2083 that.session.rename_notebook(name, json.path);
2084 that.events.trigger('notebook_renamed.Notebook', json);
2117 },
2085 },
2118 error_callback: function (xhr, status, error) {
2086 error_callback: $.proxy(this.rename_error, this)
2119 that.events.trigger('notebook_rename_error.Contents',
2120 [xhr, status, error]);
2121 }
2122 });
2087 });
2123 };
2088 };
2124
2089
General Comments 0
You need to be logged in to leave comments. Login now