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

pull/4085/head
Angel Fernando Quiroz Campos 4 years ago
parent adf972ce3c
commit 36e5edae21
  1. 14
      main/inc/lib/display.lib.php
  2. 7
      main/inc/lib/javascript/jquery.frameready.js
  3. 10
      main/lp/lp_view.php
  4. 5
      main/template/default/learnpath/view.tpl

@ -2866,13 +2866,11 @@ HTML;
return $content;
}
/**
* @param string $frameName
*
* @return string
*/
public static function getFrameReadyBlock($frameName, $itemType = '')
{
public static function getFrameReadyBlock(
string $frameName,
string $itemType = '',
string $jsConditionalFunction = 'function () { return false; }'
): string {
$webPublicPath = api_get_path(WEB_PUBLIC_PATH);
$webJsPath = api_get_path(WEB_LIBRARY_JS_PATH);
@ -2980,7 +2978,7 @@ HTML;
{type:"stylesheet", src:"'.$webPublicPath.'css/dialog.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.css"},
]);';
], '.$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) {

@ -620,7 +620,15 @@ $template->assign(
)
);
$frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank', $itemType);
$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);
$view = $template->get_template('learnpath/view.tpl');

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

Loading…
Cancel
Save