##// END OF EJS Templates
Major refactoring of the Notebook, Kernel and CodeCell JavaScript....
Major refactoring of the Notebook, Kernel and CodeCell JavaScript. * Kernel doesn't depend on Notebook or CodeCell. * CodeCell doesn't depend on Notebook, only Kernel. * All of the kernel management logic has been moved out of the Notebook into the Kernel. * Public methods of the Kernel (execute, complete, etc) take a callbacks object that registers the callbacks for that msg. (rebased, cherrypicked, by Bussonnier Matthias <bussonniermatthias@gmail.com>) (and tabs removed) Conflicts: IPython/frontend/html/notebook/static/js/codecell.js IPython/frontend/html/notebook/static/js/completer.js IPython/frontend/html/notebook/static/js/tooltip.js

File last commit:

r7168:cf831228
r7168:cf831228
Show More
notificationwidget.js
119 lines | 4.0 KiB | application/javascript | JavascriptLexer
//----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
//============================================================================
// Notification widget
//============================================================================
var IPython = (function (IPython) {
var utils = IPython.utils;
var NotificationWidget = function (selector) {
this.selector = selector;
this.timeout = null;
this.busy = false;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
};
NotificationWidget.prototype.style = function () {
this.element.addClass('ui-widget ui-widget-content ui-corner-all');
this.element.addClass('border-box-sizing');
};
NotificationWidget.prototype.bind_events = function () {
var that = this;
// Kernel events
$([IPython.events]).on('status_idle.Kernel',function () {
IPython.save_widget.update_document_title();
if (that.get_message() === 'Kernel busy') {
that.element.fadeOut(100, function () {
that.element.html('');
});
};
});
$([IPython.events]).on('status_busy.Kernel',function () {
window.document.title='(Busy) '+window.document.title;
that.set_message("Kernel busy");
});
$([IPython.events]).on('status_restarting.Kernel',function () {
that.set_message("Restarting kernel",500);
});
$([IPython.events]).on('status_interrupting.Kernel',function () {
that.set_message("Interrupting kernel",500);
});
$([IPython.events]).on('status_dead.Kernel',function () {
IPython.notebook.start_kernel();
that.set_message("Restarting kernel",500);
var dialog = $('<div/>');
dialog.html('The kernel has died and is being restarted.');
$(document).append(dialog);
dialog.dialog({
resizable: false,
modal: true,
title: "Dead kernel",
buttons : {
"OK": function () {
$(this).dialog('close');
}
}
});
});
// Notebook events
$([IPython.events]).on('notebook_loading.Notebook', function () {
that.set_message("Loading notebook",500);
});
$([IPython.events]).on('notebook_loaded.Notebook', function () {
that.set_message("Notebook loaded",500);
});
$([IPython.events]).on('notebook_saving.Notebook', function () {
that.set_message("Saving notebook",500);
});
$([IPython.events]).on('notebook_saved.Notebook', function () {
that.set_message("Notebook saved",500);
});
$([IPython.events]).on('notebook_save_failed.Notebook', function () {
that.set_message("Notebook save failed",500);
});
};
NotificationWidget.prototype.set_message = function (msg, timeout) {
var that = this;
this.element.html(msg);
this.element.fadeIn(100);
if (this.timeout !== null) {
clearTimeout(this.timeout);
this.timeout = null;
};
if (timeout !== undefined) {
this.timeout = setTimeout(function () {
that.element.fadeOut(100, function () {that.element.html('');});
that.timeout = null;
}, timeout)
};
};
NotificationWidget.prototype.get_message = function () {
return this.element.html();
};
IPython.NotificationWidget = NotificationWidget;
return IPython;
}(IPython));