Automatic positioning.

d6
Frode Petterson 2015-02-25 13:05:45 +01:00
parent 1861f696c1
commit fabde2f1ce
2 changed files with 15 additions and 2 deletions

View File

@ -721,6 +721,16 @@ 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 positionInner = function () {
$inner.css('height', '');
var h = $inner.height();
if (Math.floor($dialog.height()) === h) {
$inner.css('height', '100%');
}
$inner.css('marginTop', '-' + (h / 2) + 'px');
};
// Handle changing of width/height
var $w = $dialog.find('.h5p-embed-size:eq(0)');
var $h = $dialog.find('.h5p-embed-size:eq(1)');
@ -749,8 +759,10 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
// Select text and expand textareas
$dialog.find('.h5p-embed-code-container').focus(function () {
H5P.jQuery(this).select().css('height', this.scrollHeight + 'px');
positionInner();
}).blur(function () {
H5P.jQuery(this).css('height', '');
positionInner();
}).select();
// Expand advanced embed
@ -765,6 +777,7 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
$expander.addClass('h5p-open').text(H5P.t('hideAdvanced'));
$content.show();
}
positionInner();
});
});

View File

@ -252,8 +252,8 @@ div.h5p-fullscreen {
width: 300px;
left: 50%;
top: 50%;
height: 180px;
margin: -90px 0 0 -150px;
height: auto;
margin: 0 0 0 -150px;
}
.h5p-embed-dialog .h5p-embed-code-container,
.h5p-embed-size {