From 4e594dd57345b0aec5402052f9c4cdb089862b43 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 27 Feb 2015 10:26:57 +0100 Subject: [PATCH] Fixed dialog pos and expand. --- js/h5p.js | 20 ++++++++++++-------- styles/h5p.css | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 15a9f97..4183e1c 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -159,8 +159,7 @@ H5P.init = function () { // When resize has been prepared tell parent window to resize H5P.communicator.on('resizePrepared', function (data) { H5P.communicator.send('resize', { - height: document.body.scrollHeight, - parentHeight: data.parentHeight + height: document.body.scrollHeight }); }); @@ -722,13 +721,18 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) { // Selecting embed code when dialog is opened H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) { var $inner = $dialog.find('.h5p-inner'); + var $scroll = $inner.find('.h5p-scroll-content'); + var diff = $scroll.outerHeight() - $scroll.innerHeight(); var positionInner = function () { - $inner.css('height', ''); - var h = $inner.height(); - if (Math.floor($dialog.height()) === h) { - $inner.css('height', '100%'); + var height = $inner.height(); + if ($scroll[0].scrollHeight + diff > height) { + $inner.css('height', ''); // 100% } - $inner.css('marginTop', '-' + (h / 2) + 'px'); + else { + $inner.css('height', 'auto'); + height = $inner.height(); + } + $inner.css('marginTop', '-' + (height / 2) + 'px'); }; // Handle changing of width/height @@ -781,7 +785,7 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) { }; $dialog.find('.h5p-expander').click(expand).keypress(function (event) { if (event.keyCode === 32) { - expand(); + expand.apply(this); } }); }); diff --git a/styles/h5p.css b/styles/h5p.css index 1925892..b4478b9 100644 --- a/styles/h5p.css +++ b/styles/h5p.css @@ -252,7 +252,6 @@ div.h5p-fullscreen { width: 300px; left: 50%; top: 50%; - height: auto; margin: 0 0 0 -150px; } .h5p-embed-dialog .h5p-embed-code-container,