From 9bfe5fc06c925da5a7f67f02c35eb2cc29fa719a Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 12 Jun 2014 15:40:00 -0700 Subject: [PATCH] Use ipython namepsace for instances. --- IPython/html/static/auth/js/loginmain.js | 7 ++++--- IPython/html/static/auth/js/logoutmain.js | 7 ++++--- IPython/html/static/base/js/events.js | 11 +++-------- IPython/html/static/base/js/pagemain.js | 7 ++++--- IPython/html/static/notebook/js/main.js | 21 ++++++++++----------- IPython/html/static/tree/js/main.js | 17 ++++++++--------- IPython/html/templates/tree.html | 2 +- 7 files changed, 34 insertions(+), 38 deletions(-) diff --git a/IPython/html/static/auth/js/loginmain.js b/IPython/html/static/auth/js/loginmain.js index b95d70a07..5e1dd17ff 100644 --- a/IPython/html/static/auth/js/loginmain.js +++ b/IPython/html/static/auth/js/loginmain.js @@ -1,9 +1,10 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. -require(['base/js/namespace', 'base/js/page'], function(IPython, Page) { - IPython.page = new Page(); +var ipython = ipython || {}; +require(['base/js/page'], function(Page) { + ipython.page = new Page(); $('button#login_submit').addClass("btn btn-default"); - IPython.page.show(); + ipython.page.show(); $('input#password_input').focus(); }); diff --git a/IPython/html/static/auth/js/logoutmain.js b/IPython/html/static/auth/js/logoutmain.js index aa6808201..7ee2db3e0 100644 --- a/IPython/html/static/auth/js/logoutmain.js +++ b/IPython/html/static/auth/js/logoutmain.js @@ -1,8 +1,9 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. +var ipython = ipython || {}; -require(['base/js/namespace', 'base/js/page'], function(IPython, Page) { - IPython.page = new Page(); +require(['base/js/page'], function(Page) { + ipython.page = new Page(); $('#ipython-main-app').addClass('border-box-sizing'); - IPython.page.show(); + ipython.page.show(); }); diff --git a/IPython/html/static/base/js/events.js b/IPython/html/static/base/js/events.js index 34c95122b..f96cbb306 100644 --- a/IPython/html/static/base/js/events.js +++ b/IPython/html/static/base/js/events.js @@ -11,15 +11,10 @@ define(['base/js/namespace'], function(IPython) { "use strict"; var Events = function () {}; - events = new Events(); - + // Backwards compatability. IPython.Events = Events; - IPython.events = events; - // This behavior is an akward exception to the normal design pattern of - // returning the namespace. Events are used eveywhere in IPython, - // and only one instance is ever used. For convenience, create and - // return that instance here instead of the namespace. - return events; + // TODO: Fix events. + return Events; }); diff --git a/IPython/html/static/base/js/pagemain.js b/IPython/html/static/base/js/pagemain.js index 6643669c3..177f4c750 100644 --- a/IPython/html/static/base/js/pagemain.js +++ b/IPython/html/static/base/js/pagemain.js @@ -1,7 +1,8 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. -require(['base/js/namespace', 'base/js/page'], function(IPython, Page) { - IPython.page = new Page(); - IPython.page.show(); +var ipython = ipython || {}; +require(['base/js/page'], function(Page) { + ipython.page = new Page(); + ipython.page.show(); }); diff --git a/IPython/html/static/notebook/js/main.js b/IPython/html/static/notebook/js/main.js index 7332a1c0b..789ce9596 100644 --- a/IPython/html/static/notebook/js/main.js +++ b/IPython/html/static/notebook/js/main.js @@ -1,6 +1,7 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. +var ipython = ipython || {}; require([ 'base/js/namespace', 'notebook/js/notebook', @@ -83,15 +84,13 @@ require([ $([Events]).trigger('app_initialized.NotebookApp'); notebook.load_notebook(opts.notebook_name, opts.notebook_path); - // Backwards compatability. - IPython.page = page; - IPython.layout_manager = layout_manager; - IPython.notebook = notebook; - IPython.pager = pager; - IPython.quick_help = quick_help; - IPython.login_widget = login_widget; - IPython.menubar = menubar; - IPython.toolbar = toolbar; - IPython.notification_area = notification_area; - IPython.notification_area = notification_area; + ipython.page = page; + ipython.layout_manager = layout_manager; + ipython.notebook = notebook; + ipython.pager = pager; + ipython.quick_help = quick_help; + ipython.login_widget = login_widget; + ipython.menubar = menubar; + ipython.toolbar = toolbar; + ipython.notification_area = notification_area; }); diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index 4d38e0485..b9493a564 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -1,7 +1,8 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. -define([ +var ipython = ipython || {}; +require([ 'base/js/namespace', 'components/jquery/jquery.min', 'base/js/page', @@ -100,12 +101,10 @@ define([ } // For backwards compatability. - IPython.page = page; - IPython.notebook_list = notebook_list; - IPython.cluster_list = cluster_list; - IPython.session_list = session_list; - IPython.kernel_list = kernel_list; - IPython.login_widget = login_widget; - - return page; + ipython.page = page; + ipython.notebook_list = notebook_list; + ipython.cluster_list = cluster_list; + ipython.session_list = session_list; + ipython.kernel_list = kernel_list; + ipython.login_widget = login_widget; }); diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index d87aa2de3..b757e33fa 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -110,5 +110,5 @@ data-notebook-path="{{notebook_path}}" {% endblock %} {% block script %} - + {% endblock %}