youtube video added
This commit is contained in:
parent
3c2b4d3fd2
commit
53fb0e12ab
|
@ -1,20 +1,57 @@
|
|||
class AdBannersController < ApplicationController
|
||||
def widget
|
||||
adbanner = Banner.find(OrbitHelper.widget_custom_value)
|
||||
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>' : ""
|
||||
widget = OrbitHelper.get_current_widget
|
||||
if widget.widget_type == "ad_banner_widget2_video"
|
||||
return video_widget(adbanner)
|
||||
else
|
||||
return image_widget(adbanner)
|
||||
end
|
||||
end
|
||||
|
||||
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 || "#"
|
||||
"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
|
||||
{
|
||||
"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>"
|
||||
else ad_b.exchange_item == "2"
|
||||
image_html = "<div class='w-ad-banner__slide youtube #{klass}' data-youtube-id='ytplayer#{i}'><a class='w-ad-banner__slide' href='#{format_url(ad_b.youtube,i)}'>#{ad_b.title}</a></div>"
|
||||
end
|
||||
{
|
||||
"html" => image_html
|
||||
}
|
||||
end
|
||||
{
|
||||
"extras" => {
|
||||
|
@ -27,4 +64,15 @@ class AdBannersController < ApplicationController
|
|||
"images" => images
|
||||
}
|
||||
end
|
||||
|
||||
def format_url(url,index)
|
||||
uri = URI.parse(url)
|
||||
ps = uri.query.split("&")
|
||||
url_params = {}
|
||||
ps.each do |p|
|
||||
x = p.split("=")
|
||||
url_params[x.first] = x.last
|
||||
end
|
||||
url = "http://www.youtube.com/v/#{url_params["v"]}/?version=3&playerapiid=ytplayer#{index}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ class Admin::AdBannersController < OrbitAdminController
|
|||
|
||||
def index
|
||||
@banners = Banner.all
|
||||
@categories = @module_app.categories.enabled.collect{|c|[c.title, c.id]}
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -2,6 +2,7 @@ class Banner
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
|
||||
field :ad_fx, type: String
|
||||
field :height, type: Integer
|
||||
|
|
|
@ -10,3 +10,6 @@
|
|||
<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %>
|
||||
<span class="banner_set">H:</span>
|
||||
<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %>
|
||||
|
||||
<%= f.label :category_id, t('ad_banner.categories') %>
|
||||
<%= f.select :category_id, @categories, {} %>
|
||||
|
|
|
@ -42,5 +42,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
|
@ -21,6 +21,14 @@ module AdBanner
|
|||
:priority=>1,
|
||||
:active_for_action=>{'admin/ad_banners'=>"index"},
|
||||
:available_for => 'users'
|
||||
|
||||
context_link 'categories',
|
||||
:link_path=>"admin_module_app_categories_path" ,
|
||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ad_banner').id}",
|
||||
:priority=>3,
|
||||
:active_for_action=>{'admin/ad_banners'=>'categories'},
|
||||
:active_for_category => 'AdBanner',
|
||||
:available_for => 'managers'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue