From 8b08e1c53c5eb6e69169b4d99afdf43e2e376e2a Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Mon, 25 Nov 2013 14:50:23 -0800 Subject: [PATCH] Center modal view on show --- IPython/html/static/notebook/js/widgets/container.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/notebook/js/widgets/container.js b/IPython/html/static/notebook/js/widgets/container.js index 56a29c476..9a6c10738 100644 --- a/IPython/html/static/notebook/js/widgets/container.js +++ b/IPython/html/static/notebook/js/widgets/container.js @@ -120,9 +120,10 @@ define(["notebook/js/widget"], function(widget_manager) { show: function() { this.$window.show(); this.$show_button.addClass('btn-info'); - var position = this.$show_button.offset(); - this.$window.css('left', position.left + this.$show_button.outerWidth()); - this.$window.css('top', position.top); + this.$window.css("top", Math.max(0, (($(window).height() - this.$window.outerHeight()) / 2) + + $(window).scrollTop()) + "px"); + this.$window.css("left", Math.max(0, (($(window).width() - this.$window.outerWidth()) / 2) + + $(window).scrollLeft()) + "px"); }, update: function(){