Merge pull request #4842 from Carreau/fix-JG-complaint

more subtle kernel indicator
This commit is contained in:
Min RK 2014-02-04 09:16:08 -08:00
commit e322d96481
8 changed files with 1745 additions and 57 deletions

View File

@ -69,17 +69,17 @@ var IPython = (function (IPython) {
NotificationArea.prototype.init_notification_widgets = function() {
var knw = this.new_notification_widget('kernel');
var $kernel_indic = $("#kernel_indicator");
// Kernel events
$([IPython.events]).on('status_idle.Kernel',function () {
IPython.save_widget.update_document_title();
knw.set_message('Kernel Idle',200);
}
);
$kernel_indic.attr('class','icon-circle-blank').attr('title','Kernel Idle');
});
$([IPython.events]).on('status_busy.Kernel',function () {
window.document.title='(Busy) '+window.document.title;
knw.set_message("Kernel busy");
$kernel_indic.attr('class','icon-circle').attr('title','Kernel Busy');
});
$([IPython.events]).on('status_restarting.Kernel',function () {

View File

@ -26,6 +26,9 @@ var IPython = (function (IPython) {
this.element.hide();
var that = this;
this.inner = $('<span/>');
this.element.append(this.inner);
};
@ -40,10 +43,13 @@ var IPython = (function (IPython) {
// if timeout <= 0
// click_callback : function called if user click on notification
// could return false to prevent the notification to be dismissed
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback) {
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) {
var opts = opts || {};
var callback = click_callback || function() {return false;};
var that = this;
this.element.text(msg);
this.inner.attr('class', opts.icon);
this.inner.attr('title', opts.title);
this.inner.text(msg);
this.element.fadeIn(100);
if (this.timeout !== null) {
clearTimeout(this.timeout);
@ -51,13 +57,13 @@ var IPython = (function (IPython) {
}
if (timeout !== undefined && timeout >=0) {
this.timeout = setTimeout(function () {
that.element.fadeOut(100, function () {that.element.text('');});
that.element.fadeOut(100, function () {that.inner.text('');});
that.timeout = null;
}, timeout);
} else {
this.element.click(function() {
if( callback() != false ) {
that.element.fadeOut(100, function () {that.element.text('');});
that.element.fadeOut(100, function () {that.inner.text('');});
that.element.unbind('click');
}
if (that.timeout !== undefined) {
@ -70,7 +76,7 @@ var IPython = (function (IPython) {
NotificationWidget.prototype.get_message = function () {
return this.element.html();
return this.inner.html();
};

View File

@ -6,5 +6,17 @@
border: 1px solid #ccc;
border-radius: @baseBorderRadius;
background: rgba(240, 240, 240, 0.5);
&.span {
padding-right:2px;
}
}
#indicator_area{
color: @navbarLinkColor;
padding: 2px 2px;
margin: 2px -9px 2px 4px;
z-index: 10;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -248,6 +248,9 @@ class="notebook_app"
</ul>
</li>
</ul>
<div class='pull-right' id="indicator_area">
<div id="kernel_indicator"></div>
</div>
<div id="notification_area"></div>
</div>
</div>

View File

@ -12,12 +12,7 @@ casper.notebook_test(function () {
cell.execute();
});
this.waitFor(function(){
return this.evaluate(function() {
return $("#notification_kernel")[0].textContent.indexOf('busy') !== -1;
});
});
this.wait_for_busy();
// interrupt using menu item (Kernel -> Interrupt)
this.thenClick('li#int_kernel');

View File

@ -58,6 +58,14 @@ casper.delete_current_notebook = function () {
});
};
casper.wait_for_busy = function () {
this.waitFor(function () {
return this.evaluate(function () {
return IPython._status == 'busy';
});
});
};
casper.wait_for_idle = function () {
this.waitFor(function () {
return this.evaluate(function () {