Merge branch 'master' into improved-file-handling

pull/22/head
Frode Petterson 2016-05-09 13:21:47 +02:00
commit cbfa2913bc
1 changed files with 14 additions and 13 deletions

View File

@ -154,9 +154,13 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
/** /**
* Fit popup to container. Makes sure it doesn't overflow. * Fit popup to container. Makes sure it doesn't overflow.
* @params {number} [offsetTop] Offset of popup
*/ */
var fitToContainer = function () { var fitToContainer = function (offsetTop) {
var popupOffsetTop = parseInt(popup.style.top, 10); var popupOffsetTop = parseInt(popup.style.top, 10);
if (offsetTop) {
popupOffsetTop = offsetTop;
}
// Overflows height // Overflows height
if (popupOffsetTop + popup.offsetHeight > wrapperElement.offsetHeight) { if (popupOffsetTop + popup.offsetHeight > wrapperElement.offsetHeight) {
@ -178,30 +182,27 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
* @returns {H5P.ConfirmationDialog} * @returns {H5P.ConfirmationDialog}
*/ */
this.show = function (offsetTop) { this.show = function (offsetTop) {
popup.style.top = offsetTop + 'px';
popupBackground.classList.remove('hidden'); popupBackground.classList.remove('hidden');
fitToContainer(); fitToContainer(offsetTop);
setTimeout(function () { setTimeout(function () {
popup.classList.remove('hidden'); popup.classList.remove('hidden');
popupBackground.classList.remove('hiding'); popupBackground.classList.remove('hiding');
// Resize iFrame if necessary setTimeout(function () {
if (resizeIFrame && options.instance) { // Focus confirm button
setTimeout(function () { confirmButton.focus();
// Resize iFrame if necessary
if (resizeIFrame && options.instance) {
var minHeight = parseInt(popup.offsetHeight, 10) + var minHeight = parseInt(popup.offsetHeight, 10) +
exitButtonOffset + (2 * shadowOffset); exitButtonOffset + (2 * shadowOffset);
wrapperElement.style.minHeight = minHeight + 'px'; wrapperElement.style.minHeight = minHeight + 'px';
options.instance.trigger('resize'); options.instance.trigger('resize');
resizeIFrame = false; resizeIFrame = false;
}, 100); }
} }, 100);
}, 0); }, 0);
// Programmatically focus popup
popup.setAttribute('tabindex', '-1');
popup.focus();
return this; return this;
}; };