ruffle: fix issue with ruffle falsely triggering keyboard shortcuts.

Fix issue mentioned in 55980c6fb with Javascript spazzing out on Flash
posts and randomly triggering keyboard shortcuts.

The bug was calling `javascript_pack_tag` twice. This caused the
runtime Javascript chunk to be loaded twice, caused a lot of Javascript
errors that somehow resulted in keyboard shortcuts being triggered.

The fix is to combine both calls into `javascript_pack_tag "application", "flash"`.

hxxps://github.com.rails.webpacker.issues.2932
This commit is contained in:
evazion
2021-03-31 22:10:04 -05:00
parent 946b4cc960
commit fff68e1d16
3 changed files with 23 additions and 7 deletions

View File

@@ -35,6 +35,7 @@ Post.initialize_all = function() {
this.initialize_post_image_resize_links();
this.initialize_recommended();
this.initialize_ugoira_player();
this.initialize_ruffle_player();
}
if ($("#c-posts #a-show, #c-uploads #a-new").length) {
@@ -380,6 +381,19 @@ Post.initialize_ugoira_player = function() {
}
};
Post.initialize_ruffle_player = function() {
if (!window.RufflePlayer) {
return;
}
let ruffle = window.RufflePlayer.newest();
let player = ruffle.createPlayer();
let $container = $(".ruffle-container[data-swf]");
let src = $container.attr("data-swf");
$container.get(0).appendChild(player);
player.load(src);
};
Post.resize_ugoira_controls = function() {
var $img = $("#image");
var width = Math.max($img.width(), 350);