youtube cycle fixed for iphone

This commit is contained in:
Harry Bomrah 2015-04-08 13:49:03 +08:00
parent 707dd3a6a4
commit 1880a4f18d
2 changed files with 13 additions and 10 deletions

View File

@ -0,0 +1,2 @@
/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */
!function(a){"use strict";function b(){try{this.playVideo()}catch(a){}}function c(){try{this.pauseVideo()}catch(a){}}var d='<div class=cycle-youtube><iframe width="640" height="360" frameborder="0" allowfullscreen="" data-yt-api-binded="0" src="{{url}}"></iframe></div>';a.extend(a.fn.cycle.defaults,{youtubeAllowFullScreen:!0,youtubeAutostart:!1,youtubeAutostop:!0}),a(document).on("cycle-bootstrap",function(e,f){f.youtube&&(f.hideNonActive=!1,f.container.find(f.slides).each(function(b){if(void 0!==a(this).attr("href")){var c,e=a(this),g=e.attr("href"),h=f.youtubeAllowFullScreen?"true":"false";g+=(/\?/.test(g)?"&":"?")+"enablejsapi=1",f.youtubeAutostart&&f.startingSlide===b&&(g+="&autoplay=1"),c=f.API.tmpl(d,{url:g,allowFullScreen:h}),e.replaceWith(c)}}),f.slides=f.slides.replace(/(\b>?a\b)/,"div.cycle-youtube"),f.youtubeAutostart&&f.container.on("cycle-initialized cycle-after",function(c,d){var e="cycle-initialized"==c.type?d.currSlide:d.nextSlide;a(d.slides[e]).find("object,embed").each(b)}),f.youtubeAutostop&&f.container.on("cycle-before",function(b,d){a(d.slides[d.currSlide]).find("object,embed").each(c)}))})}(jQuery);

View File

@ -17,14 +17,14 @@ class AdBannersController < ApplicationController
klass = i == 0 ? "active" : "" klass = i == 0 ? "active" : ""
caption = i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : "" 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 end
{ {
@ -47,7 +47,7 @@ class AdBannersController < ApplicationController
if ad_b.exchange_item == "1" 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>" 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" 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>" 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>"
end end
{ {
"html" => image_html "html" => image_html
@ -73,6 +73,7 @@ class AdBannersController < ApplicationController
x = p.split("=") x = p.split("=")
url_params[x.first] = x.last url_params[x.first] = x.last
end end
url = "http://www.youtube.com/v/#{url_params["v"]}/?version=3&playerapiid=ytplayer#{index}" # url = "http://www.youtube.com/v/#{url_params["v"]}/?version=3&playerapiid=ytplayer#{index}"
url = "http://www.youtube.com/embed/#{url_params["v"]}"
end end
end end