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; 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, $itemType = '')
{
$webPublicPath = api_get_path(WEB_PUBLIC_PATH); $webPublicPath = api_get_path(WEB_PUBLIC_PATH);
$webJsPath = api_get_path(WEB_LIBRARY_JS_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.'css/dialog.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"}, {type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.css"}, {type:"stylesheet", src: "'.$webJsPath.'mediaelement/plugins/vrview/vrview.css"},
]);'; ], '.$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) {

@ -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); $template->assign('frame_ready', $frameReady);
$view = $template->get_template('learnpath/view.tpl'); $view = $template->get_template('learnpath/view.tpl');

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

Loading…
Cancel
Save