LP: Don't load frameReady resources for external content - refs BT#19446

pull/4128/head
Angel Fernando Quiroz Campos 4 years ago
parent 0bad2d866b
commit 34d45f6b3b
  1. 16
      main/inc/lib/display.lib.php
  2. 7
      main/inc/lib/javascript/jquery.frameready.js
  3. 17
      main/lp/lp_view.php
  4. 5
      main/template/default/learnpath/view.tpl
  5. 10
      main/template/rainbow/learnpath/view.tpl

@ -2887,13 +2887,11 @@ HTML;
return $content; return $content;
} }
/** public static function getFrameReadyBlock(
* @param string $frameName string $frameName,
* string $itemType = '',
* @return string string $jsConditionalFunction = 'function () { return false; }'
*/ ): string {
public static function getFrameReadyBlock($frameName)
{
$webPublicPath = api_get_path(WEB_PUBLIC_PATH); $webPublicPath = api_get_path(WEB_PUBLIC_PATH);
$videoFeatures = [ $videoFeatures = [
@ -2989,8 +2987,8 @@ HTML;
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"}, {type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/plugins/vrview/vrview.css"}, {type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/plugins/vrview/vrview.css"},
'.$fileCustomCssMedia.', '.$fileCustomCssMedia.',
'.$translateHtml.' '.$translateHtml.',
]);'; ], '.$jsConditionalFunction.');';
return $frameReady; return $frameReady;
} }

@ -2,9 +2,10 @@
* @param {function} callback * @param {function} callback
* @param {string} target * @param {string} target
* @param {Array} resources * @param {Array} resources
* @param {function} conditional
* @constructor * @constructor
*/ */
$.frameReady = function (callback, targetSelector, resources) { $.frameReady = function (callback, targetSelector, resources, conditional) {
/** /**
* @type {window} * @type {window}
*/ */
@ -46,6 +47,10 @@ $.frameReady = function (callback, targetSelector, resources) {
targetWindow.onload = function () { targetWindow.onload = function () {
scripsLoadedCount = 0; scripsLoadedCount = 0;
if (typeof conditional === 'function' && conditional()) {
return;
}
targetDocument = targetWindow.contentDocument; targetDocument = targetWindow.contentDocument;
scripts.forEach(function (script) { scripts.forEach(function (script) {

@ -212,11 +212,11 @@ if ($debug) {
$get_toc_list = $lp->get_toc(); $get_toc_list = $lp->get_toc();
$get_teacher_buttons = $lp->get_teacher_toc_buttons(); $get_teacher_buttons = $lp->get_teacher_toc_buttons();
$itemType = '';
$type_quiz = false;
foreach ($get_toc_list as $toc) { foreach ($get_toc_list as $toc) {
if ($toc['id'] == $lp_item_id && $toc['type'] == 'quiz') { if ($toc['id'] == $lp_item_id) {
$type_quiz = true; $itemType = $toc['type'];
} }
} }
@ -290,7 +290,6 @@ $autostart = 'true';
// Update status, total_time from lp_item_view table when you finish the exercises in learning path. // Update status, total_time from lp_item_view table when you finish the exercises in learning path.
if ($debug) { if ($debug) {
error_log('$type_quiz: '.$type_quiz);
error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId'])); error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId']));
error_log('$lp_id: '.$lp_id); error_log('$lp_id: '.$lp_id);
error_log('$_GET[lp_item_id]: '.intval($_GET['lp_item_id'])); error_log('$_GET[lp_item_id]: '.intval($_GET['lp_item_id']));
@ -630,7 +629,15 @@ $template->assign(
) )
); );
$frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank'); $frameReady = Display::getFrameReadyBlock(
'#content_id, #content_id_blank',
$itemType,
'function () {
var arr = ["link", "sco", "xapi"];
return $.inArray(olms.lms_item_type, arr) !== -1;
}'
);
$template->assign('frame_ready', $frameReady); $template->assign('frame_ready', $frameReady);
// Ofaj // Ofaj

@ -376,10 +376,7 @@
{% endif %} {% endif %}
{% if disable_js_in_lp_view == 0 %} {% if disable_js_in_lp_view == 0 %}
$(function() { $(function() {
var arr = ['link', 'sco']; {{ frame_ready }}
if ($.inArray(olms.lms_item_type, arr) == -1) {
{{ frame_ready }}
}
}); });
{% endif %} {% endif %}

@ -330,13 +330,9 @@
})(); })();
{% endif %} {% endif %}
{% if disable_js_in_lp_view == 0 %} {% if disable_js_in_lp_view == 0 %}
$(function() { $(function() {
var arr = ['link', 'sco']; {{ frame_ready }}
});
if ($.inArray(olms.lms_item_type, arr) == -1) {
{{ frame_ready }}
}
});
{% endif %} {% endif %}
$(window).on('resize', function () { $(window).on('resize', function () {

Loading…
Cancel
Save