Make page.html require.js friendly.

Jonathan Frederic 12 years ago committed by Jonathan Frederic
parent 3e3be268f9
commit 855815d207

@ -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;
});

@ -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<parts.length; i+=1) {
// Create property if it doesn't exist
if (typeof parent[parts[i]] === "undefined") {
parent[parts[i]] = {};
}
}
return parent;
};
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([], function(){
var IPython = IPython || {};
IPython.version = "3.0.0-dev";
return IPython;
});

@ -1,15 +1,13 @@
//----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
//============================================================================
// Global header/site setup.
//============================================================================
var IPython = (function (IPython) {
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'base/js/namespace',
'components/jquery/jquery.min',
'components/jquery-ui/ui/minified/jquery-ui.min',
'components/bootstrap/js/bootstrap.min',
'auth/js/loginwidget'
], function(IPython, $){
"use strict";
var Page = function () {
@ -22,11 +20,9 @@ var IPython = (function (IPython) {
$('div#site').addClass('border-box-sizing');
};
Page.prototype.bind_events = function () {
};
Page.prototype.show = function () {
// The header and site divs start out hidden to prevent FLOUC.
// Main scripts should call this method after styling everything.
@ -34,23 +30,19 @@ var IPython = (function (IPython) {
this.show_site();
};
Page.prototype.show_header = function () {
// The header and site divs start out hidden to prevent FLOUC.
// Main scripts should call this method after styling everything.
$('div#header').css('display','block');
};
Page.prototype.show_site = function () {
// The header and site divs start out hidden to prevent FLOUC.
// Main scripts should call this method after styling everything.
$('div#site').css('display','block');
};
// Register self in the global namespace for convenience.
IPython.Page = Page;
return IPython;
}(IPython));
return Page;
});

@ -1,20 +1,7 @@
//----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
//============================================================================
// On document ready
//============================================================================
$(document).ready(function () {
"use strict";
IPython.page = new IPython.Page();
require(['base/js/namespace', 'base/js/page'], function(IPython, Page) {
IPython.page = new Page();
IPython.page.show();
});

@ -1,13 +1,10 @@
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
//============================================================================
// Utilities
//============================================================================
IPython.namespace('IPython.utils');
IPython.utils = (function (IPython) {
define([
'base/js/namespace',
'components/jquery/jquery.min',
], function(IPython, $){
"use strict";
IPython.load_extensions = function () {
@ -528,8 +525,8 @@ IPython.utils = (function (IPython) {
}
console.log(msg);
};
return {
var Utils = {
regex_split : regex_split,
uuid : uuid,
fixConsole : fixConsole,
@ -553,5 +550,7 @@ IPython.utils = (function (IPython) {
log_ajax_error : log_ajax_error,
};
}(IPython));
// Register self in the global namespace for convenience.
IPython.Utils = Utils;
return Utils;
});

@ -20,8 +20,8 @@
baseUrl: '{{static_url("", include_version=False)}}',
paths: {
nbextensions : '{{ base_url }}nbextensions',
underscore : '{{static_url("components/underscore/underscore-min.js")}}',
backbone : '{{static_url("components/backbone/backbone-min.js")}}',
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
},
shim: {
underscore: {
@ -75,14 +75,8 @@
{% endblock %}
</div>
<script src="{{static_url("components/jquery/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/jquery-ui/ui/minified/jquery-ui.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/bootstrap/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("base/js/namespace.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("base/js/page.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("auth/js/loginwidget.js") }}" type="text/javascript" charset="utf-8"></script>
{% block script %}
<script src="{{static_url("base/js/pagemain.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
<script src="{{static_url("custom/custom.js") }}" type="text/javascript" charset="utf-8"></script>

Loading…
Cancel
Save