added language option for adbanner pro

This commit is contained in:
Harry Bomrah 2016-05-18 16:29:39 +08:00
parent 7cf9796abc
commit ac93c3de49
3 changed files with 40 additions and 23 deletions

View File

@ -1,7 +1,9 @@
class AdBannersController < ApplicationController
def widget
adbanner = Banner.find(OrbitHelper.widget_custom_value)
images = adbanner.ad_images.can_display.asc(:sort_number,:created_at).collect.with_index do |b,i|
images = []
adbanner.ad_images.can_display.asc(:sort_number,:created_at).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>' : ""
@ -13,7 +15,7 @@ class AdBannersController < ApplicationController
target = ""
end
{
images << {
"image_link" => image_link,
"image_alt" => "ad banner image",
"title" => b.title,
@ -27,6 +29,7 @@ class AdBannersController < ApplicationController
"target" => target
}
end
end
base_image = adbanner.base_image.nil? ? 1 : adbanner.base_image
{
"extras" => {

View File

@ -14,6 +14,7 @@ class AdImage
field :postdate , :type => DateTime, :default => Time.now
field :deadline , :type => DateTime
field :sort_number, :type => Integer
field :language_enabled, :type => Array, :default => ["en","zh_tw"]
LINK_OPEN_TYPES = ["local", "new_window"]

View File

@ -105,6 +105,19 @@
</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>
</div>
</div>