##// END OF EJS Templates
Backport PR #5459: Fix interact animation page jump FF...
Backport PR #5459: Fix interact animation page jump FF Firefox doesn't render images immediately as the data is available. When animating the way that we animate, this causes the output area to collapse quickly before returning to its original size. When the output area collapses, FireFox scrolls upwards in attempt to compensate for the lost vertical content (so it looks like you are on the same spot in the page, with respect to the contents below the image's prior location). The solution is to resize the image output after the `img onload` event has fired. This PR: - Releases the `clear_output` height lock after the image has been loaded (instead of immediately or using a timeout). - Removes a `setTimeout` call in the `append_output` method. - `clear_output` in zmqshell no longer sends `\r` to the stream outputs. closes #5128

File last commit:

r15042:036b6a9b
r16229:ff1462d3
Show More
notificationwidget.js
88 lines | 2.8 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) {
"use strict";
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.element.button();
this.element.hide();
var that = this;
this.inner = $('<span/>');
this.element.append(this.inner);
};
NotificationWidget.prototype.style = function () {
this.element.addClass('notification_widget pull-right');
this.element.addClass('border-box-sizing');
};
// 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
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) {
var opts = opts || {};
var callback = click_callback || function() {return false;};
var that = this;
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);
this.timeout = null;
}
if (timeout !== undefined && timeout >=0) {
this.timeout = setTimeout(function () {
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.inner.text('');});
that.element.unbind('click');
}
if (that.timeout !== undefined) {
that.timeout = undefined;
clearTimeout(that.timeout);
}
});
}
};
NotificationWidget.prototype.get_message = function () {
return this.inner.html();
};
IPython.NotificationWidget = NotificationWidget;
return IPython;
}(IPython));