youtube video added
This commit is contained in:
parent
3c2b4d3fd2
commit
53fb0e12ab
|
@ -1,20 +1,57 @@
|
||||||
class AdBannersController < ApplicationController
|
class AdBannersController < ApplicationController
|
||||||
def widget
|
def widget
|
||||||
adbanner = Banner.find(OrbitHelper.widget_custom_value)
|
adbanner = Banner.find(OrbitHelper.widget_custom_value)
|
||||||
images = adbanner.ad_images.can_display.collect.with_index do |b,i|
|
widget = OrbitHelper.get_current_widget
|
||||||
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
|
if widget.widget_type == "ad_banner_widget2_video"
|
||||||
klass = i == 0 ? "active" : ""
|
return video_widget(adbanner)
|
||||||
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
|
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,
|
"image_link" => image_link,
|
||||||
"title" => b.title,
|
"title" => b.title,
|
||||||
"class" => klass,
|
"class" => klass,
|
||||||
"height" => adbanner.height,
|
"height" => adbanner.height,
|
||||||
"width" => adbanner.width,
|
"width" => adbanner.width,
|
||||||
"caption" => caption,
|
"caption" => caption,
|
||||||
"context" => b.context,
|
"context" => b.context,
|
||||||
"link" => b.out_link || "#"
|
"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
|
end
|
||||||
{
|
{
|
||||||
"extras" => {
|
"extras" => {
|
||||||
|
@ -27,4 +64,15 @@ class AdBannersController < ApplicationController
|
||||||
"images" => images
|
"images" => images
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Admin::AdBannersController < OrbitAdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@banners = Banner.all
|
@banners = Banner.all
|
||||||
|
@categories = @module_app.categories.enabled.collect{|c|[c.title, c.id]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -2,6 +2,7 @@ class Banner
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include OrbitTag::Taggable
|
include OrbitTag::Taggable
|
||||||
|
include OrbitCategory::Categorizable
|
||||||
|
|
||||||
field :ad_fx, type: String
|
field :ad_fx, type: String
|
||||||
field :height, type: Integer
|
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' %>
|
<%= 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>
|
<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.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>
|
||||||
</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,
|
:priority=>1,
|
||||||
:active_for_action=>{'admin/ad_banners'=>"index"},
|
:active_for_action=>{'admin/ad_banners'=>"index"},
|
||||||
:available_for => 'users'
|
: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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue