##// END OF EJS Templates
handle undefined or closed zmq_stream in on_message...
handle undefined or closed zmq_stream in on_message can happen if a message is waiting in a pipe and the web socket is closed before the message is handled. And give ZMQChannels a nice repr with their kernel ID

File last commit:

r17391:9e80835b
r17647:5e9f12e7
Show More
notificationwidget.js
104 lines | 3.4 KiB | application/javascript | JavascriptLexer
/ IPython / html / static / notebook / js / notificationwidget.js
Jonathan Frederic
MWE,...
r17200 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
Brian Granger
Major refactoring of saving, notification....
r6047
Jonathan Frederic
MWE,...
r17200 define([
'base/js/namespace',
'jquery',
], function(IPython, $) {
Matthias BUSSONNIER
use strict in notificationwidget.js
r8206 "use strict";
Brian Granger
Major refactoring of saving, notification....
r6047
var NotificationWidget = function (selector) {
this.selector = selector;
this.timeout = null;
this.busy = false;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
}
Matthias BUSSONNIER
prototype sticky notification
r8025 this.element.hide();
var that = this;
Matthias BUSSONNIER
tweek notebook notification behavior
r8074
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 this.inner = $('<span/>');
this.element.append(this.inner);
Brian Granger
Major refactoring of saving, notification....
r6047 };
NotificationWidget.prototype.style = function () {
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368 this.element.addClass('notification_widget');
Brian Granger
Major refactoring of saving, notification....
r6047 };
Matthias BUSSONNIER
tweek notebook notification behavior
r8074 // msg : message to display
// timeout : time in ms before diseapearing
//
// if timeout <= 0
// click_callback : function called if user click on notification
// could return false to prevent the notification to be dismissed
Jonathan Frederic
More review changes
r17214 NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, options) {
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368 var options = options || {};
var callback = click_callback || function() {return true;};
Brian Granger
Major refactoring of saving, notification....
r6047 var that = this;
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368 // unbind potential previous callback
this.element.unbind('click');
Jonathan Frederic
More review changes
r17214 this.inner.attr('class', options.icon);
this.inner.attr('title', options.title);
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 this.inner.text(msg);
Brian Granger
Major refactoring of saving, notification....
r6047 this.element.fadeIn(100);
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368
// reset previous set style
Matthias BUSSONNIER
fix missing semicolons
r17391 this.element.removeClass();
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368 this.style();
if (options.class){
this.element.addClass(options.class)
}
Brian Granger
Major refactoring of saving, notification....
r6047 if (this.timeout !== null) {
clearTimeout(this.timeout);
this.timeout = null;
Matthias BUSSONNIER
jslint 2
r8205 }
Matthias BUSSONNIER
prototype sticky notification
r8025 if (timeout !== undefined && timeout >=0) {
Brian Granger
Major refactoring of saving, notification....
r6047 this.timeout = setTimeout(function () {
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 that.element.fadeOut(100, function () {that.inner.text('');});
Brian Granger
Major refactoring of saving, notification....
r6047 that.timeout = null;
Matthias BUSSONNIER
prototype sticky notification
r8025 }, timeout);
Matthias BUSSONNIER
tweek notebook notification behavior
r8074 } else {
Matthias BUSSONNIER
jslint 2
r8205 this.element.click(function() {
Jonathan Frederic
MWE,...
r17200 if( callback() !== false ) {
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 that.element.fadeOut(100, function () {that.inner.text('');});
Matthias BUSSONNIER
jslint 2
r8205 that.element.unbind('click');
Matthias BUSSONNIER
tweek notebook notification behavior
r8074 }
if (that.timeout !== undefined) {
Matthias BUSSONNIER
jslint 2
r8205 that.timeout = undefined;
Matthias BUSSONNIER
tweek notebook notification behavior
r8074 clearTimeout(that.timeout);
}
});
}
Brian Granger
Major refactoring of saving, notification....
r6047 };
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368
NotificationWidget.prototype.info = function (msg, timeout, click_callback, options) {
var options = options || {};
options.class = options.class +' info';
var timeout = timeout || 3500;
this.set_message(msg, timeout, click_callback, options);
}
NotificationWidget.prototype.warning = function (msg, timeout, click_callback, options) {
var options = options || {};
options.class = options.class +' warning';
this.set_message(msg, timeout, click_callback, options);
}
NotificationWidget.prototype.danger = function (msg, timeout, click_callback, options) {
var options = options || {};
options.class = options.class +' danger';
this.set_message(msg, timeout, click_callback, options);
}
Brian Granger
Major refactoring of saving, notification....
r6047 NotificationWidget.prototype.get_message = function () {
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 return this.inner.html();
Brian Granger
Major refactoring of saving, notification....
r6047 };
Matthias BUSSONNIER
Introduce info/warning/danger to notification area...
r17368 // For backwards compatibility.
Brian Granger
Major refactoring of saving, notification....
r6047 IPython.NotificationWidget = NotificationWidget;
Jonathan Frederic
Return dicts instead of classes,...
r17201 return {'NotificationWidget': NotificationWidget};
Jonathan Frederic
MWE,...
r17200 });