From 084a87c15e79c21fe0a64249a5aafd6fe9de8dae 2014-11-03 18:18:28 From: Thomas Kluyver Date: 2014-11-03 18:18:28 Subject: [PATCH] Some more event cleanup --- diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 0f63b32..9527f89 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -2132,6 +2132,7 @@ define([ Notebook.prototype.load_notebook = function (notebook_name, notebook_path) { this.notebook_name = notebook_name; this.notebook_path = notebook_path; + this.events.trigger('notebook_loading.Notebook'); this.contents.load_file(notebook_path, notebook_name, { success_callback: $.proxy(this.load_notebook_success, this), error_callback: $.proxy(this.load_notebook_error, this) diff --git a/IPython/html/static/services/contents.js b/IPython/html/static/services/contents.js index 60bf5c3..d953572 100644 --- a/IPython/html/static/services/contents.js +++ b/IPython/html/static/services/contents.js @@ -17,9 +17,7 @@ define([ // Parameters: // options: dictionary // Dictionary of keyword arguments. - // events: $(Events) instance // base_url: string - this.events = options.events; this.base_url = options.base_url; }; @@ -54,7 +52,6 @@ define([ success : options.success_callback, error : options.error_callback || function() {} }; - this.events.trigger('notebook_loading.Notebook'); var url = this.api_url(path, name); $.ajax(url, settings); }; diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index cc7e88c..5361e19 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -40,21 +40,6 @@ define([ this.session_list.events.on('sessions_loaded.Dashboard', function(e, d) { that.sessions_loaded(d); }); } - - - if (this.contents && this.contents.events) { - this.contents.events.on('notebook_deleted.Contents', - function(e, d) { - // Remove the deleted notebook. - $( ":data(nbname)" ).each(function() { - var element = $( this ); - if (element.data( "nbname" ) == d.name && - element.data( "path" ) == d.path) { - element.remove(); - } - }); - }); - } }; NotebookList.prototype.style = function () { @@ -348,9 +333,7 @@ define([ click: function() { notebooklist.contents.delete_file(nbname, path, { success_callback: function() { - that.events.trigger('notebook_deleted.Contents', - {name: name, path: path}); - } + notebooklist.notebook_deleted(path, nbname); }); } }, @@ -362,6 +345,17 @@ define([ item.find(".item_buttons").text("").append(delete_button); }; + NotebookList.prototype.notebook_deleted = function(path, name) { + // Remove the deleted notebook. + $( ":data(nbname)" ).each(function() { + var element = $( this ); + if (element.data( "nbname" ) == d.name && + element.data( "path" ) == d.path) { + element.remove(); + } + }); + } + NotebookList.prototype.add_upload_button = function (item, type) { var that = this;