bilingual function added to banner
This commit is contained in:
parent
636b51d080
commit
0b0669fe96
|
@ -12,46 +12,52 @@ class AdBannersController < ApplicationController
|
|||
private
|
||||
|
||||
def image_widget(adbanner)
|
||||
images = adbanner.ad_images.can_display.collect.with_index do |b,i|
|
||||
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
|
||||
klass = i == 0 ? "active" : ""
|
||||
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
|
||||
{
|
||||
"image_link" => image_link,
|
||||
"title" => b.title,
|
||||
"class" => klass,
|
||||
"height" => adbanner.height,
|
||||
"width" => adbanner.width,
|
||||
"caption" => caption,
|
||||
"context" => b.context,
|
||||
"link" => b.out_link || "#"
|
||||
}
|
||||
images = []
|
||||
adbanner.ad_images.can_display.each_with_index do |b,i|
|
||||
if b.language_enabled.include?(I18n.locale.to_s)
|
||||
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
|
||||
klass = i == 0 ? "active" : ""
|
||||
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
|
||||
images << {
|
||||
"image_link" => image_link,
|
||||
"title" => b.title,
|
||||
"class" => klass,
|
||||
"height" => adbanner.height,
|
||||
"width" => adbanner.width,
|
||||
"caption" => caption,
|
||||
"context" => b.context,
|
||||
"link" => b.out_link || "#"
|
||||
}
|
||||
end
|
||||
end
|
||||
{
|
||||
"extras" => {
|
||||
"ad_fx" => adbanner.ad_fx,
|
||||
"speed" => adbanner.speed,
|
||||
"title" => adbanner.title,
|
||||
"timeout" => adbanner.timeout,
|
||||
"more" => "More"
|
||||
},
|
||||
"images" => images
|
||||
}
|
||||
{
|
||||
"extras" => {
|
||||
"ad_fx" => adbanner.ad_fx,
|
||||
"speed" => adbanner.speed,
|
||||
"title" => adbanner.title,
|
||||
"timeout" => adbanner.timeout,
|
||||
"more" => "More"
|
||||
},
|
||||
"images" => images
|
||||
}
|
||||
end
|
||||
|
||||
def video_widget(adbanner)
|
||||
images = adbanner.ad_images.can_display.collect.with_index do |ad_b,i|
|
||||
image_link = OrbitHelper.is_mobile_view ? ad_b.file.mobile.url : ad_b.file.url
|
||||
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
|
||||
klass = i == 0 ? "active" : ""
|
||||
if ad_b.exchange_item == "1"
|
||||
image_html = "<div class='w-ad-banner__slide #{klass}' data-link='#{ad_b.out_link || "#"}''><img class='w-ad-banner__image' src='#{image_link}'><div class='w-ad-banner__caption_text'>#{ad_b.title}</div></div>"
|
||||
else ad_b.exchange_item == "2"
|
||||
image_html = "<div class='w-ad-banner__slide youtube #{klass}' data-yt-binded='0' data-youtube-id='ytplayer#{i}'><a class='w-ad-banner__slide' href='#{format_url(ad_b.youtube,i)}'>#{ad_b.title}</a><div class='w-ad-banner__caption_text'>#{ad_b.title}</div></div>"
|
||||
images = []
|
||||
adbanner.ad_images.can_display.each_with_index do |ad_b,i|
|
||||
if ad_b.language_enabled.include?(I18n.locale.to_s)
|
||||
image_link = OrbitHelper.is_mobile_view ? ad_b.file.mobile.url : ad_b.file.url
|
||||
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
|
||||
klass = i == 0 ? "active" : ""
|
||||
if ad_b.exchange_item == "1"
|
||||
image_html = "<div class='w-ad-banner__slide #{klass}' data-link='#{ad_b.out_link || "#"}''><img class='w-ad-banner__image' src='#{image_link}'><div class='w-ad-banner__caption_text'>#{ad_b.title}</div></div>"
|
||||
else ad_b.exchange_item == "2"
|
||||
image_html = "<div class='w-ad-banner__slide youtube #{klass}' data-yt-binded='0' data-youtube-id='ytplayer#{i}'><a class='w-ad-banner__slide' href='#{format_url(ad_b.youtube,i)}'>#{ad_b.title}</a><div class='w-ad-banner__caption_text'>#{ad_b.title}</div></div>"
|
||||
end
|
||||
images << {
|
||||
"html" => image_html
|
||||
}
|
||||
end
|
||||
{
|
||||
"html" => image_html
|
||||
}
|
||||
end
|
||||
{
|
||||
"extras" => {
|
||||
|
|
|
@ -14,6 +14,7 @@ class AdImage
|
|||
field :postdate , :type => DateTime, :default => Time.now
|
||||
field :deadline , :type => DateTime
|
||||
field :youtube , :type => String
|
||||
field :language_enabled, :type => Array, :default => ["en","zh_tw"]
|
||||
field :exchange_item
|
||||
LINK_OPEN_TYPES = ["local", "new_window"]
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Link -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:link) %></label>
|
||||
|
@ -88,7 +87,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- language-selection -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:select_language) %></label>
|
||||
<div class="controls">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<label class="checkbox">
|
||||
<%= check_box_tag "ad_image[language_enabled][]", locale, (@ad_image.language_enabled.include?(locale.to_s) rescue false) %>
|
||||
<%= t(locale.to_s) %>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Title-->
|
||||
<div class="control-group">
|
||||
<label for="first_name" class="control-label muted" function="field_label"><%= t("title")%></label>
|
||||
|
|
Loading…
Reference in New Issue