Fix youtube embedder, scale it down into the stream
This commit is contained in:
parent
ae29e2478a
commit
a58a06a010
2 changed files with 13 additions and 15 deletions
|
|
@ -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>');
|
||||
|
|
|
|||
|
|
@ -299,8 +299,8 @@ ul.as-selections
|
|||
|
||||
.youtube-player, .vimeo-player
|
||||
:border none
|
||||
:height 370px
|
||||
:width 500px
|
||||
:height 304px
|
||||
:width 410px
|
||||
|
||||
.comment
|
||||
.comment_info
|
||||
|
|
|
|||
Loading…
Reference in a new issue