adbanner-test/app/controllers/ad_banners_controller.rb

46 lines
1.5 KiB
Ruby
Raw Normal View History

2014-04-11 07:47:33 +00:00
class AdBannersController < ApplicationController
def widget
2014-05-23 05:51:04 +00:00
adbanner = Banner.find(OrbitHelper.widget_custom_value)
2016-02-16 12:21:14 +00:00
images = adbanner.ad_images.can_display.asc(:sort_number,:created_at).collect.with_index do |b,i|
2014-05-29 09:39:10 +00:00
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
2014-05-23 05:51:04 +00:00
klass = i == 0 ? "active" : ""
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
2015-05-11 10:19:57 +00:00
alt_title = (b.title.nil? || b.title == "" ? "ad-banner image" : b.title)
2014-12-17 08:18:54 +00:00
if b.link_open == "new_window"
target = "_blank"
else
2014-12-17 09:22:40 +00:00
target = ""
2014-12-17 08:18:54 +00:00
end
2014-05-23 05:51:04 +00:00
{
2014-05-29 09:39:10 +00:00
"image_link" => image_link,
"image_alt" => "ad banner image",
2015-05-11 10:19:57 +00:00
"title" => b.title,
"alt_title" => alt_title,
2014-05-23 05:51:04 +00:00
"class" => klass,
"height" => adbanner.height,
"width" => adbanner.width,
"caption" => caption,
2015-12-09 17:33:25 +00:00
"context" => (b.context.tr('"',"'") rescue ""),
2014-12-17 08:18:54 +00:00
"link" => b.out_link || "#",
"target" => target
2014-05-23 05:51:04 +00:00
}
end
2015-11-25 13:28:27 +00:00
base_image = adbanner.base_image.nil? ? 1 : adbanner.base_image
2014-05-23 05:51:04 +00:00
{
"extras" => {
2014-04-15 07:51:02 +00:00
"ad_fx" => adbanner.ad_fx,
"speed" => adbanner.speed,
"title" => adbanner.title,
2015-10-12 07:33:45 +00:00
"banner-height" => adbanner.height,
"banner-width" => adbanner.width,
2015-11-25 13:28:27 +00:00
"base_image" => (base_image - 1),
2015-10-06 07:30:59 +00:00
"timeout" => (adbanner.timeout * 1000),
2014-04-11 07:47:33 +00:00
"more" => "More"
2014-05-23 05:51:04 +00:00
},
"images" => images
2014-04-11 07:47:33 +00:00
}
end
end