Finished making tree.html requirejs friendly

pull/37/head
Jonathan Frederic 12 years ago committed by Jonathan Frederic
parent 9f4a03ce79
commit b1c8d2662c

@ -87,7 +87,7 @@ define([
return modal.modal(options);
};
var edit_metadata = function (md, callback, name) {
var edit_metadata = function (md, callback, name, keyboard_manager, notebook) {
name = name || "Cell";
var error_div = $('<div/>').css('color', 'red');
var message =
@ -141,7 +141,7 @@ define([
},
Cancel: {}
}
});
}, keyboard_manager, notebook);
modal.on('shown.bs.modal', function(){ editor.refresh(); });
};

@ -17,5 +17,9 @@ define(['base/js/namespace'], function(IPython) {
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;
});

@ -1,18 +1,12 @@
//----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
//============================================================================
// NotebookList
//============================================================================
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',
'base/js/utils',
], function(IPython, $, Utils) {
"use strict";
var utils = IPython.utils;
var ClusterList = function (selector, options) {
this.selector = selector;
@ -23,8 +17,8 @@ var IPython = (function (IPython) {
}
options = options || {};
this.options = options;
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
this.base_url = options.base_url || Utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || Utils.get_body_data("notebookPath");
};
ClusterList.prototype.style = function () {
@ -50,9 +44,9 @@ var IPython = (function (IPython) {
type : "GET",
dataType : "json",
success : $.proxy(this.load_list_success, this),
error : utils.log_ajax_error,
error : Utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'clusters');
var url = Utils.url_join_encode(this.base_url, 'clusters');
$.ajax(url, settings);
};
@ -76,8 +70,8 @@ var IPython = (function (IPython) {
var ClusterItem = function (element, options) {
this.element = $(element);
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
this.base_url = options.base_url || Utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || Utils.get_body_data("notebookPath");
this.data = null;
this.style();
};
@ -132,11 +126,11 @@ var IPython = (function (IPython) {
},
error : function (xhr, status, error) {
status_col.text("error starting cluster");
utils.log_ajax_error(xhr, status, error);
Utils.log_ajax_error(xhr, status, error);
}
};
status_col.text('starting');
var url = utils.url_join_encode(
var url = Utils.url_join_encode(
that.base_url,
'clusters',
that.data.profile,
@ -188,11 +182,9 @@ var IPython = (function (IPython) {
});
};
// For backwards compatability.
IPython.ClusterList = ClusterList;
IPython.ClusterItem = ClusterItem;
return IPython;
}(IPython));
return ClusterList;
});

@ -1,24 +1,18 @@
//----------------------------------------------------------------------------
// Copyright (C) 2014 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.
//----------------------------------------------------------------------------
//============================================================================
// Running Kernels List
//============================================================================
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',
'tree/js/notebooklist',
], function(IPython, $, NotebookList) {
"use strict";
var utils = IPython.utils;
var KernelList = function (selector, options) {
IPython.NotebookList.call(this, selector, options, 'running');
var KernelList = function (selector, options, session_list) {
NotebookList.call(this, selector, options, 'running', session_list);
};
KernelList.prototype = Object.create(IPython.NotebookList.prototype);
KernelList.prototype = Object.create(NotebookList.prototype);
KernelList.prototype.sessions_loaded = function (d) {
this.sessions = d;
@ -31,10 +25,10 @@ var IPython = (function (IPython) {
}
$('#running_list_header').toggle($.isEmptyObject(d));
}
};
// Backwards compatability.
IPython.KernelList = KernelList;
return IPython;
}(IPython));
return KernelList;
});

@ -13,7 +13,6 @@ define([
'auth/js/loginwidget',
'components/jquery-ui/ui/minified/jquery-ui.min',
'components/bootstrap/js/bootstrap.min',
'base/js/dialog',
], function(
IPython,
$,
@ -28,13 +27,13 @@ define([
page = new Page();
var opts = {
base_url : Utils.get_body_data("baseUrl"),
notebook_path : Utils.get_body_data("notebookPath"),
base_url: Utils.get_body_data("baseUrl"),
notebook_path: Utils.get_body_data("notebookPath"),
};
session_list = new SesssionList(opts);
notebook_list = new NotebookList('#notebook_list', opts, undefined, session_list);
cluster_list = new ClusterList('#cluster_list', opts);
kernel_list = new KernelList('#running_list', opts);
kernel_list = new KernelList('#running_list', opts, session_list);
login_widget = new LoginWidget('#login_widget', opts);
$('#new_notebook').button().click(function (e) {

@ -1,22 +1,17 @@
//----------------------------------------------------------------------------
// Copyright (C) 2014 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.
//============================================================================
// Running Kernels List
//============================================================================
var IPython = (function (IPython) {
define([
'base/js/namespace',
'components/jquery/jquery.min',
'base/js/utils',
'base/js/events',
], function(IPython, $, Utils, Events) {
"use strict";
var utils = IPython.utils;
var SesssionList = function (options) {
this.sessions = {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.base_url = options.base_url || Utils.get_body_data("baseUrl");
};
SesssionList.prototype.load_sessions = function(){
@ -27,9 +22,9 @@ var IPython = (function (IPython) {
type : "GET",
dataType : "json",
success : $.proxy(that.sessions_loaded, this),
error : utils.log_ajax_error,
error : Utils.log_ajax_error,
};
var url = utils.url_join_encode(this.base_url, 'api/sessions');
var url = Utils.url_join_encode(this.base_url, 'api/sessions');
$.ajax(url, settings);
};
@ -38,16 +33,17 @@ var IPython = (function (IPython) {
var len = data.length;
var nb_path;
for (var i=0; i<len; i++) {
nb_path = utils.url_path_join(
nb_path = Utils.url_path_join(
data[i].notebook.path,
data[i].notebook.name
);
this.sessions[nb_path] = data[i].id;
}
$([IPython.events]).trigger('sessions_loaded.Dashboard', this.sessions);
Events.trigger('sessions_loaded.Dashboard', this.sessions);
};
IPython.SesssionList = SesssionList;
return IPython;
// Backwards compatability.
IPython.SesssionList = SesssionList;
}(IPython));
return SesssionList;
});

Loading…
Cancel
Save