Commit 1041f764 authored by Aaron Wells's avatar Aaron Wells

Cleanup how mediaplayers are handled by the page editor JS

Bug 1397131: Some of the old code here is preventing videojs
from working correctly.

behatnotneeded

Change-Id: Id3d24fdffc4d254019ce0b991d3865b15bec0d74
parent a7de9233
......@@ -1644,12 +1644,12 @@ class BlockInstance {
$file = get_config('wwwroot') . $file;
}
$js .= '$j.getScript("' . $file . '"';
$js .= "jQuery.ajax({url: '{$file}', dataType: 'script', cache:true";
if (is_array($jsfile) && !empty($jsfile['initjs'])) {
// Pass success callback to getScript
$js .= ', function(data) {' . $jsfile['initjs'] . '}';
$js .= ", success: function(data){\n" . $jsfile['initjs'] . "\n}";
}
$js .= ");\n";
$js .= "});\n";
}
return $js;
}
......
......@@ -1033,27 +1033,23 @@
});
}
/**
* This function is called before the modal is opened. In theory it could be used to make changes
* to the display of elements before the modal opens (for things that might interfere with the
* modal.
*
* It's currently empty because everything works fine without it.
*/
function hideMediaPlayers() {
workspace.find('.mediaplayer-container').each(function() {
$(this).height($(this).height()); // retain height while hiding
$('mediaplayer:first', this).hide();
$('object', this).each(function() {
$(this).addClass('in-mediaplayer');
});
});
// Try to find and hide players floating around in text blocks, etc. by looking for object elements
workspace.find('object').each(function() {
if (!$(this).hasClass('in-mediaplayer')) {
var temp = $('<div>').addClass('hidden mediaplayer-placeholder');
$(temp).height($(this).height());
$(this).after(temp);
$(this).addClass('hidden');
$(temp).removeClass('hidden');
}
});
}
/**
* This function is called after the modal is closed. If you have deactivated things using
* hideMediaPlayers, this can be a good place to re-open them.
*
* It is also used as a hacky place to hold other things that should be triggered after the
* modal closes.
*/
function showMediaPlayers() {
if (!config['handheld_device'] && tinyMCE && tinyMCE.activeEditor && tinyMCE.activeEditor.id) {
tinyMCE.execCommand('mceRemoveEditor', false, tinyMCE.activeEditor.id);
......@@ -1061,17 +1057,6 @@
if (config.mathjax && MathJax !== undefined) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
}
workspace.find('.mediaplayer-container').each(function() {
$(this).css({'height': ''});
$('mediaplayer:first', this).show();
$(this).height($(this).height());
});
workspace.find('.mediaplayer-placeholder').each(function() {
$(this).addClass('hidden');
$(this).prev().removeClass('hidden');
$(this).remove();
});
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment