Fix bug for rails 4.2.

This commit is contained in:
BoHung Chiu 2023-07-05 09:42:03 +08:00
parent cfe0fd9c5a
commit d49edd789e
1 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,9 @@
class AdBannersController < ApplicationController class AdBannersController < ApplicationController
def self.custom_widget_data def self.custom_widget_data
ac = ActionController::Base.new ac = ActionController::Base.new
ac.render_to_string("ad_banners/custom_widget_data",:locals=>{:@custom_data_field=>@custom_data_field,:@field_name=>@field_name}) ac.instance_variable_set(:@custom_data_field, @custom_data_field)
ac.instance_variable_set(:@field_name, @field_name)
ac.render_to_string("ad_banners/custom_widget_data")
end end
def widget def widget
adbanner = Banner.find(OrbitHelper.widget_custom_value) adbanner = Banner.find(OrbitHelper.widget_custom_value)
@ -71,8 +73,9 @@ class AdBannersController < ApplicationController
def video_widget(adbanner) def video_widget(adbanner)
subpart = OrbitHelper.get_current_widget subpart = OrbitHelper.get_current_widget
custom_data_field = subpart.custom_data_field || {} custom_data_field = subpart.custom_data_field || {}
@autoplay_video = custom_data_field[:autoplay_video] rescue "0" data_autoplay = custom_data_field[:autoplay_video] rescue "0"
@hide_video_tools = custom_data_field[:hide_video_tools] == "1" rescue false @is_autoplay_video = (data_autoplay == "1")
@hide_video_tools = (custom_data_field[:hide_video_tools] == "1" rescue false)
images = [] images = []
has_jplayer = false has_jplayer = false
adbanner.ad_images.can_display.asc(:sort_number).each_with_index do |ad_b,i| adbanner.ad_images.can_display.asc(:sort_number).each_with_index do |ad_b,i|
@ -108,6 +111,9 @@ class AdBannersController < ApplicationController
video_webm_url = ad_b.video_file_webm.url rescue nil video_webm_url = ad_b.video_file_webm.url rescue nil
@file_poster = ad_b.video_snapshot.url rescue nil @file_poster = ad_b.video_snapshot.url rescue nil
title = (banner_title.blank? ? File.basename(video_url) : banner_title) title = (banner_title.blank? ? File.basename(video_url) : banner_title)
@autoplay_video = (@is_autoplay_video && i == 0)
@apply_autoplay_script = @is_autoplay_video
@is_frontend = true
image_html = "<div class=\"w-ad-banner__slide w-ba-banner__slide #{klass} jplayer_slide\" image_html = "<div class=\"w-ad-banner__slide w-ba-banner__slide #{klass} jplayer_slide\"
data-link=\"#{ad_b.out_link || "#"}\" data-link=\"#{ad_b.out_link || "#"}\"
data-cycle-title=\"#{banner_title_escape}\" data-cycle-title=\"#{banner_title_escape}\"
@ -115,9 +121,9 @@ class AdBannersController < ApplicationController
data-overlay-template=\"<h3>#{banner_title_escape}</h3><p>#{context}</p>\" data-overlay-template=\"<h3>#{banner_title_escape}</h3><p>#{context}</p>\"
data-target=\"#{target}\" data-target=\"#{target}\"
style=\"height: 100%;\" style=\"height: 100%;\"
data-autoplay=\"#{@autoplay_video}\" data-autoplay=\"#{data_autoplay}\"
> >
#{ render_to_string(partial: "admin/ad_images/jplayer",locals:{i: (subpart.id.to_s+i.to_s),file_name: title,file_url: video_url,file_webm_url: video_webm_url,:@autoplay_video=>(@autoplay_video == "1" && i == 0),:@apply_autoplay_script=>true,:@hide_video_tools=>@hide_video_tools,:@is_frontend=>true,:@file_poster=>@file_poster}, layout: false).to_str } #{ render_to_string(partial: "admin/ad_images/jplayer",locals:{i: (subpart.id.to_s+i.to_s),file_name: title,file_url: video_url,file_webm_url: video_webm_url}, layout: false).to_str }
</div>" </div>"
has_jplayer = true has_jplayer = true
elsif ad_b.exchange_item == "2" elsif ad_b.exchange_item == "2"
@ -130,7 +136,7 @@ class AdBannersController < ApplicationController
data-cycle-desc=\"#{context}\" data-cycle-desc=\"#{context}\"
data-overlay-template=\"<h3>#{banner_title_escape}</h3><p>#{context}</p>\" data-overlay-template=\"<h3>#{banner_title_escape}</h3><p>#{context}</p>\"
data-target=\"#{target}\" data-target=\"#{target}\"
data-autoplay=\"#{@autoplay_video}\" data-autoplay=\"#{data_autoplay}\"
> >
<div style=\"padding-bottom: 56.25%;position: relative;height: 0;\"> <div style=\"padding-bottom: 56.25%;position: relative;height: 0;\">
<iframe height=\"100%\" width=\"100%\" <iframe height=\"100%\" width=\"100%\"