Skip to content

Commit

Permalink
Merge pull request #75 from openequella/iframe-sizing
Browse files Browse the repository at this point in the history
adjust iframe width based on window size
  • Loading branch information
mrblippy authored Mar 23, 2020
2 parents 4b56ec0 + 30acbc8 commit b442781
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-03-16 Nick Charles

Make selection session window 80% of window width

2020-03-13 Nick Charles

GDPR compliance
Expand Down
17 changes: 13 additions & 4 deletions module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ M.mod_equella.submitform = function(Y, formid) {
frm.submit();
};

M.mod_equella.display_equella = function(Y, equellaContainer, width, minheight,
M.mod_equella.display_equella = function(Y, equellaContainer, minwidth, minheight,
title, redirecturl) {
var bodyNode = Y.one('body');
var iframeid = 'resourceobject';
var initialheight = Y.one('body').get('winHeight') * 0.9;
var initialwidth = Y.one('body').get('winWidth') * 0.8;
bodyNode.addClass('equella-page');

var generate_html = function(append) {
Expand Down Expand Up @@ -52,6 +53,7 @@ M.mod_equella.display_equella = function(Y, equellaContainer, width, minheight,
obj.setStyle('width', '0px');
obj.setStyle('height', '0px');
var newwidth = get_htmlelement_size(parentContainer, 'width') - 25;


if (newwidth > 500) {
obj.setStyle('width', newwidth + 'px');
Expand All @@ -62,14 +64,21 @@ M.mod_equella.display_equella = function(Y, equellaContainer, width, minheight,
var headerheight = get_htmlelement_size('page-header', 'height');
var footerheight = get_htmlelement_size('page-footer', 'height');
var newheight;
var newwidth;
if (initialize) {
if (initialheight < minheight) {
newheight = minheight;
} else {
newheight = initialheight;
}
if (initialwidth < minwidth) {
newwidth = minwidth;
} else {
newwidth = initialwidth;
}
} else {
newheight = get_htmlelement_size(parentContainer, 'height');
newwidth = get_htmlelement_size(parentContainer, 'width');
}
newheight = newheight - 50;
obj.setStyle('height', newheight + 'px');
Expand All @@ -84,17 +93,17 @@ M.mod_equella.display_equella = function(Y, equellaContainer, width, minheight,
bodywidth = body.getComputedStyle('width');
}
bodywidth = parseInt(bodywidth);
var x = (bodywidth - width) / 2;
var x = (bodywidth - minwidth) / 2;
var y = 20;

generate_html(true);
var panel = new Y.Panel({
srcNode : '#' + equellaContainer,
width : width,
width : initialwidth,
height : initialheight,
zIndex : 4031,
xy : [ x, y ],
centered : false,
centered : true,
modal : true,
visible : true,
render : true,
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2020031301;
$plugin->version = 2020031600;
$plugin->requires = 2014041101; // Requires this Moodle version
$plugin->component = 'mod_equella'; // Full name of the plugin (used for diagnostics)
$plugin->release = '1.0';

0 comments on commit b442781

Please sign in to comment.