From 855815d207b4510b2599f08994b1636beb9c0011 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Tue, 10 Jun 2014 12:42:51 -0700 Subject: [PATCH] Make page.html require.js friendly. --- IPython/html/static/auth/js/loginwidget.js | 31 +++++++--------- IPython/html/static/base/js/namespace.js | 42 +++++----------------- IPython/html/static/base/js/page.js | 34 +++++++----------- IPython/html/static/base/js/pagemain.js | 21 +++-------- IPython/html/static/base/js/utils.js | 21 ++++++----- IPython/html/templates/page.html | 12 ++----- 6 files changed, 51 insertions(+), 110 deletions(-) diff --git a/IPython/html/static/auth/js/loginwidget.js b/IPython/html/static/auth/js/loginwidget.js index 329ba0e0e..05e4fe99b 100644 --- a/IPython/html/static/auth/js/loginwidget.js +++ b/IPython/html/static/auth/js/loginwidget.js @@ -1,20 +1,16 @@ -//---------------------------------------------------------------------------- -// Copyright (C) 2008-2011 The IPython Development Team -// -// Distributed under the terms of the BSD License. The full license is in -// the file COPYING, distributed as part of this software. -//---------------------------------------------------------------------------- - -//============================================================================ -// Login button -//============================================================================ - -var IPython = (function (IPython) { +// Copyright (c) IPython Development Team. +// Distributed under the terms of the Modified BSD License. + +define([ + 'base/js/namespace', + 'base/js/utils', + 'components/jquery/jquery.min', +], function(IPython, Utils, $){ "use strict"; var LoginWidget = function (selector, options) { options = options || {}; - this.base_url = options.base_url || IPython.utils.get_body_data("baseUrl"); + this.base_url = options.base_url || Utils.get_body_data("baseUrl"); this.selector = selector; if (this.selector !== undefined) { this.element = $(selector); @@ -31,13 +27,13 @@ var IPython = (function (IPython) { LoginWidget.prototype.bind_events = function () { var that = this; this.element.find("button#logout").click(function () { - window.location = IPython.utils.url_join_encode( + window.location = Utils.url_join_encode( that.base_url, "logout" ); }); this.element.find("button#login").click(function () { - window.location = IPython.utils.url_join_encode( + window.location = Utils.url_join_encode( that.base_url, "login" ); @@ -47,6 +43,5 @@ var IPython = (function (IPython) { // Set module variables IPython.LoginWidget = LoginWidget; - return IPython; - -}(IPython)); + return LoginWidget; +}); \ No newline at end of file diff --git a/IPython/html/static/base/js/namespace.js b/IPython/html/static/base/js/namespace.js index 3b36198f5..b3d39afbc 100644 --- a/IPython/html/static/base/js/namespace.js +++ b/IPython/html/static/base/js/namespace.js @@ -1,34 +1,8 @@ -//---------------------------------------------------------------------------- -// Copyright (C) 2011 The IPython Development Team -// -// Distributed under the terms of the BSD License. The full license is in -// the file COPYING, distributed as part of this software. -//---------------------------------------------------------------------------- - -var IPython = IPython || {}; - -IPython.version = "3.0.0-dev"; - -IPython.namespace = function (ns_string) { - "use strict"; - - var parts = ns_string.split('.'), - parent = IPython, - i; - - // String redundant leading global - if (parts[0] === "IPython") { - parts = parts.slice(1); - } - - for (i=0; i