##// END OF EJS Templates
Update IPython kernel spec
Update IPython kernel spec

File last commit:

r17214:c0cbf124
r17378:edef819f
Show More
notificationwidget.js
77 lines | 2.5 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.button();
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 () {
MinRK
bootstrapify notification widget
r10932 this.element.addClass('notification_widget pull-right');
Brian Granger
Major refactoring of saving, notification....
r6047 this.element.addClass('border-box-sizing');
};
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) {
options = options || {};
Matthias BUSSONNIER
jslint 2
r8205 var callback = click_callback || function() {return false;};
Brian Granger
Major refactoring of saving, notification....
r6047 var that = this;
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);
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 };
NotificationWidget.prototype.get_message = function () {
Matthias BUSSONNIER
more subtle kernel indicator...
r15042 return this.inner.html();
Brian Granger
Major refactoring of saving, notification....
r6047 };
Jonathan Frederic
MWE,...
r17200 // For backwards compatability.
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 });