mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Fixed Youtube videos appearing on top of compose panel (props to @hrobertson)
This commit is contained in:
parent
4863c4517a
commit
8d47215ea5
4 changed files with 14 additions and 5 deletions
|
@ -37,6 +37,11 @@ module Oneboxer
|
|||
var.gsub! /https?:\/\//, '//' if var.is_a? String
|
||||
end
|
||||
|
||||
# Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top
|
||||
def append_embed_wmode(var)
|
||||
var.gsub! /(src="[^"]+)/, '\1&wmode=opaque"' if var.is_a? String
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def initialize(url, opts={})
|
||||
|
|
|
@ -2,12 +2,12 @@ require_dependency 'oneboxer/base_onebox'
|
|||
|
||||
module Oneboxer
|
||||
class FlashVideoOnebox < BaseOnebox
|
||||
|
||||
|
||||
matcher /^https?:\/\/.*\.(swf|flv)$/
|
||||
|
||||
def onebox
|
||||
if SiteSetting.enable_flash_video_onebox
|
||||
"<object width='100%' height='100%'><param name='#{@url}' value='#{@url}'><embed src='#{@url}' width='100%' height='100%'></embed></object>"
|
||||
"<object width='100%' height='100%' wmode='opaque'><param name='#{@url}' value='#{@url}'><embed src='#{@url}' width='100%' height='100%' wmode='opaque'></embed></object>"
|
||||
else
|
||||
"<a href='#{@url}'>#{@url}</a>"
|
||||
end
|
||||
|
|
|
@ -8,8 +8,12 @@ module Oneboxer
|
|||
end
|
||||
|
||||
def onebox
|
||||
# Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant
|
||||
super.each { |entry| BaseOnebox.replace_agnostic entry }
|
||||
super.each do |entry|
|
||||
# Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant
|
||||
BaseOnebox.replace_agnostic entry
|
||||
# Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top
|
||||
BaseOnebox.append_embed_wmode entry
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe Oneboxer::FlashVideoOnebox do
|
|||
|
||||
it "generates a flash video" do
|
||||
expect(@o.onebox).to match_html(
|
||||
"<object width='100%' height='100%'><param name='http://player.56.com/v_OTMyNTk1MzE.swf' value='http://player.56.com/v_OTMyNTk1MzE.swf'><embed src='http://player.56.com/v_OTMyNTk1MzE.swf' width='100%' height='100%'></embed></object>"
|
||||
"<object width='100%' height='100%' wmode='opaque'><param name='http://player.56.com/v_OTMyNTk1MzE.swf' value='http://player.56.com/v_OTMyNTk1MzE.swf'><embed src='http://player.56.com/v_OTMyNTk1MzE.swf' width='100%' height='100%' wmode='opaque'></embed></object>"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue