-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️(iframe) precalculate iframe height to improve user visual feeling
As iframeResizer may take a few seconds to initialize and set correct iframe height, we calculate probable height regarding available width and configuration given ratio. We also use more comprehensive settings and drop deprecated XBlock.fragment library in favor of web_fragment.fragment
- Loading branch information
Showing
5 changed files
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 13 additions & 8 deletions
21
configurable_lti_consumer/static/js/configurable_xblock_lti_consumer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
function configurableLTIConsumerXblockIframeResizerInit() { | ||
$(function ($) { | ||
LtiConsumerXBlock(); // call inherited lti_consumer javascript initialization | ||
$('.ltiLaunchFrame').iFrameResize({ // Initialize IframeResizer on lti_consumer iframe class | ||
checkOrigin: false, | ||
log: false | ||
}) | ||
}); | ||
function configurableLTIConsumerXblockIframeResizerInit(runtime, element, json_args) { | ||
var $element = $("#" + json_args["element_id"]); | ||
LtiConsumerXBlock(); // call inherited lti_consumer javascript initialization | ||
// Estimate LTI consumer xblock height regarding available width using given ratio | ||
// to presize iframe before iframeResizer initialization | ||
var ratio = parseFloat($element.find("div").data('ratio')); | ||
var $iframe = $element.find('iframe'); | ||
var width = $('.content-primary,.vert-mod').width(); | ||
var probable_height = width * ratio; | ||
$iframe.iFrameResize({ // Initialize IframeResizer on lti_consumer iframe class | ||
checkOrigin: false, | ||
log: false | ||
}).height(probable_height); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters