From a58a06a0105351802f078da3fcfac7a510a5367d Mon Sep 17 00:00:00 2001 From: Raphael Sofaer <raphael@joindiaspora.com> Date: Thu, 21 Jul 2011 15:18:09 -0700 Subject: [PATCH] Fix youtube embedder, scale it down into the stream --- public/javascripts/widgets/embedder.js | 24 +++++++++++------------- public/stylesheets/sass/application.sass | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/public/javascripts/widgets/embedder.js b/public/javascripts/widgets/embedder.js index c136ef3609..994da273ff 100644 --- a/public/javascripts/widgets/embedder.js +++ b/public/javascripts/widgets/embedder.js @@ -14,20 +14,20 @@ $.extend(self, { stream: $("#main_stream") }); - + self.ensureDOMStructure(); self.stream.delegate("a.video-link", "click", self.onVideoLinkClicked); self.registerServices(); }); - + this.ensureDOMStructure = function() { var post = self.stream.children(".stream_element:first"), content = post.children(".sm_body").children(".content").children("p"); self.canEmbed = !!content.length; }; - + this.register = function(service, template) { self.services[service] = template; @@ -37,7 +37,7 @@ var template = (typeof self.services[service] === "string") ? self.services[service] : self.services.undefined; - + return $.mustache(template, views); }; @@ -47,10 +47,10 @@ videoContainer = videoLink.closest(".content").children(".video-container"); if (videoContainer.length) { - videoContainer.slideUp("fast", function() { + videoContainer.slideUp("fast", function() { $(this).detach(); }); - + return; } @@ -59,7 +59,7 @@ } container.html( - self.render(service, videoLink.data()) + self.render(videoLink.attr('data-host'), videoLink.data()) ); container.hide() @@ -69,8 +69,8 @@ videoLink.click(function() { videoContainer.slideUp("fast", function() { $(this).detach(); - }); - }); + }); + }); }; this.onVideoLinkClicked = function(evt) { @@ -81,14 +81,12 @@ }; this.registerServices = function() { - var watchVideoOn = Diaspora.widgets.i18n.t("videos.watch"); - self.register("youtube.com", - '<a href="//www.youtube.com/watch?v={{video-id}}{{anchor}}" target="_blank">' + $.mustache(watchVideoOn, { provider: "YouTube" }) + '</a><br />' + + '<a href="//www.youtube.com/watch?v={{video-id}}{{anchor}}" target="_blank">' + Diaspora.widgets.i18n.t("videos.watch", { provider: "YouTube" }) + '</a><br />' + '<iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/{{video-id}}?wmode=opaque{{anchor}}"></iframe>'); self.register("vimeo.com", - '<a href="http://vimeo.com/{{video-id}}">' + $.mustache(watchVideoOn, { provider: "Vimeo" }) + '</a><br />' + + '<a href="http://vimeo.com/{{video-id}}">' + Diaspora.widgets.i18n.t("videos.watch", { provider: "Vimeo" }) + '</a><br />' + '<iframe class="vimeo-player" src="http://player.vimeo.com/video/{{video-id}}"></iframe>'); self.register("undefined", '<p>' + Diaspora.widgets.i18n.t("videos.unknown") + ' - {{host}}</p>'); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 048cfff99e..b02d1881e5 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -299,8 +299,8 @@ ul.as-selections .youtube-player, .vimeo-player :border none - :height 370px - :width 500px + :height 304px + :width 410px .comment .comment_info -- GitLab