From 1880a4f18d9359e05bf015ad4d8b7c3cc0a29392 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 8 Apr 2015 13:49:03 +0800 Subject: [PATCH] youtube cycle fixed for iphone --- .../cycle2/jquery.cycle2.video.min.js | 2 ++ app/controllers/ad_banners_controller.rb | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/cycle2/jquery.cycle2.video.min.js diff --git a/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js b/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js new file mode 100644 index 0000000..c47c840 --- /dev/null +++ b/app/assets/javascripts/cycle2/jquery.cycle2.video.min.js @@ -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='
';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); \ No newline at end of file diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index bf022c1..ec5f971 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -17,14 +17,14 @@ class AdBannersController < ApplicationController klass = i == 0 ? "active" : "" caption = i == 0 ? '
' : "" { - "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 { @@ -47,7 +47,7 @@ class AdBannersController < ApplicationController if ad_b.exchange_item == "1" image_html = "
" else ad_b.exchange_item == "2" - image_html = "
#{ad_b.title}
" + image_html = "
#{ad_b.title}
" end { "html" => image_html @@ -73,6 +73,7 @@ class AdBannersController < ApplicationController x = p.split("=") url_params[x.first] = x.last 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