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. 3
      main/template/default/learnpath/view.tpl
  5. 4
      main/template/rainbow/learnpath/view.tpl

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

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

@ -212,11 +212,11 @@ if ($debug) {
$get_toc_list = $lp->get_toc();
$get_teacher_buttons = $lp->get_teacher_toc_buttons();
$itemType = '';
$type_quiz = false;
foreach ($get_toc_list as $toc) {
if ($toc['id'] == $lp_item_id && $toc['type'] == 'quiz') {
$type_quiz = true;
if ($toc['id'] == $lp_item_id) {
$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.
if ($debug) {
error_log('$type_quiz: '.$type_quiz);
error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId']));
error_log('$lp_id: '.$lp_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);
// Ofaj

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

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

Loading…
Cancel
Save