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:
@@ -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);
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
<% if CurrentUser.user.blacklisted_tags.present? %>
|
||||
<meta name="blacklisted-tags" content="<%= CurrentUser.user.blacklisted_tags.gsub(/(?:\r|\n)+/, ",") %>">
|
||||
<% end %>
|
||||
<%= javascript_pack_tag "application" %>
|
||||
|
||||
<%# XXX hack to only load Ruffle on Flash posts %>
|
||||
<% if controller_name == "posts" && action_name == "show" && @post.is_flash? %>
|
||||
<%= javascript_pack_tag "application", "flash" %>
|
||||
<% else %>
|
||||
<%= javascript_pack_tag "application" %>
|
||||
<% end %>
|
||||
|
||||
<%= stylesheet_pack_tag "application" %>
|
||||
<% if CurrentUser.user.custom_style.present? && params.fetch(:css, "true").truthy? %>
|
||||
<%= stylesheet_link_tag custom_style_users_path(md5: Digest::MD5.hexdigest(CurrentUser.user.custom_style)), media: "screen" %>
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
<%= content_tag(:object, :width => post.image_width, :height => post.image_height) do %>
|
||||
<%= tag :params, :name => "movie", :value => post.tagged_file_url %>
|
||||
<%= tag :embed, :src => post.tagged_file_url, :width => post.image_width, :height => post.image_height, :allowScriptAccess => "never" %>
|
||||
<% end %>
|
||||
<div class="ruffle-container" data-swf="<%= post.tagged_file_url %>"></div>
|
||||
|
||||
<p><%= link_to "Save this flash (right click and save)", post.tagged_file_url %></p>
|
||||
|
||||
<%= javascript_pack_tag "flash" %>
|
||||
|
||||
Reference in New Issue
Block a user