Skip to content
Snippets Groups Projects
Commit 5c4699cf authored by Douglas Hall's avatar Douglas Hall
Browse files

PHX-255 Launch LTI provider on modal window open

parent b8921a19
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ function LtiConsumerXBlock(runtime, element) { ...@@ -16,6 +16,9 @@ function LtiConsumerXBlock(runtime, element) {
return this.each(function () { return this.each(function () {
var o = options; var o = options;
$(this).click(function (e) { $(this).click(function (e) {
var $modal = $(modal_id);
// Set iframe src attribute to launch LTI provider
$modal.find('iframe').attr('src', $modal.data('launch-url'));
$("#" + overlay_id).click(function () { $("#" + overlay_id).click(function () {
close_modal(modal_id) close_modal(modal_id)
}); });
...@@ -56,10 +59,12 @@ function LtiConsumerXBlock(runtime, element) { ...@@ -56,10 +59,12 @@ function LtiConsumerXBlock(runtime, element) {
}); });
}); });
function close_modal(modal_id) { function close_modal(modal_id) {
var $modal = $(modal_id);
$('select, input, textarea, button, a').off('focus'); $('select, input, textarea, button, a').off('focus');
$("#" + overlay_id).fadeOut(200); $("#" + overlay_id).fadeOut(200);
$(modal_id).css({"display": "none"}); $modal.css({"display": "none"});
$(modal_id).attr('aria-hidden', true); $modal.attr('aria-hidden', true);
$modal.find('iframe').attr('src', '');
$('body').css('overflow', 'auto'); $('body').css('overflow', 'auto');
$trigger.focus(); $trigger.focus();
} }
......
<%page args="initial_launch_url" expression_filter="h"/>
<iframe <iframe
title="${display_name}" title="${display_name}"
class="ltiLaunchFrame" class="ltiLaunchFrame"
name="ltiFrame-${element_id}" name="ltiFrame-${element_id}"
src="${form_url}" src="${initial_launch_url}"
allowfullscreen="true" allowfullscreen="true"
webkitallowfullscreen="true" webkitallowfullscreen="true"
mozallowfullscreen="true" mozallowfullscreen="true"
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
class="modal lti-modal" class="modal lti-modal"
aria-hidden="true" aria-hidden="true"
style="width:${modal_width}%; left:${modal_horizontal_offset}%; top:${modal_vertical_offset}%; bottom:${modal_vertical_offset}%;" style="width:${modal_width}%; left:${modal_horizontal_offset}%; top:${modal_vertical_offset}%; bottom:${modal_vertical_offset}%;"
data-launch-url="${form_url}"
> >
<div class="inner-wrapper" role="dialog"> <div class="inner-wrapper" role="dialog">
<button class="close-modal"> <button class="close-modal">
...@@ -58,14 +59,17 @@ ...@@ -58,14 +59,17 @@
<span class="sr">Close</span> <span class="sr">Close</span>
</button> </button>
## The result of the LTI launch form submit will be rendered here. ## The result of the LTI launch form submit will be rendered here.
<%include file="templates/html/lti_iframe.html"/> ## initial_launch_url is set to an empty string here because
## in "modal" launch mode, we use javascript to set the src
## attribute of the iframe when the modal window is opened.
<%include file="templates/html/lti_iframe.html" args="initial_launch_url=''"/>
</div> </div>
</section> </section>
% endif % endif
% if launch_target == 'iframe': % if launch_target == 'iframe':
<div style="height:${inline_height}px;"> <div style="height:${inline_height}px;">
## The result of the LTI launch form submit will be rendered here. ## The result of the LTI launch form submit will be rendered here.
<%include file="templates/html/lti_iframe.html"/> <%include file="templates/html/lti_iframe.html" args="initial_launch_url=form_url"/>
</div> </div>
% endif % endif
% elif not hide_launch: % elif not hide_launch:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment