remove embedder
This commit is contained in:
parent
cff3f6ea49
commit
81fc5b28da
3 changed files with 0 additions and 136 deletions
|
|
@ -1,80 +0,0 @@
|
|||
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
* licensed under the Affero General Public License version 3 or later. See
|
||||
* the COPYRIGHT file.
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
var Embedder = function() {
|
||||
var self = this;
|
||||
this.services = {};
|
||||
|
||||
this.subscribe("widget/ready", function(evt, contentElement) {
|
||||
self.contentElement = contentElement;
|
||||
|
||||
self.contentElement.delegate("a.video-link", "click", self.embedVideo);
|
||||
self.registerServices();
|
||||
});
|
||||
|
||||
this.register = function(service, template) {
|
||||
self.services[service] = template;
|
||||
};
|
||||
|
||||
this.render = function(service, views) {
|
||||
var template = (typeof self.services[service] === "string")
|
||||
? self.services[service]
|
||||
: self.services.undefined;
|
||||
|
||||
return $.mustache(template, views);
|
||||
};
|
||||
|
||||
this.embedVideo = function(evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
var videoLink = $(this),
|
||||
host = videoLink.data("host"),
|
||||
container = $("<div/>", { "class": "video-container" }),
|
||||
videoContainer = self.contentElement.children(".video-container");
|
||||
|
||||
if (videoContainer.length) {
|
||||
videoContainer.slideUp("fast", function() {
|
||||
$(this).detach();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($("div.video-container").length) {
|
||||
$("div.video-container").slideUp("fast", function() { $(this).detach(); });
|
||||
}
|
||||
|
||||
container.html(
|
||||
self.render(host, videoLink.data())
|
||||
);
|
||||
|
||||
container.hide()
|
||||
.insertAfter(videoLink.parent())
|
||||
.slideDown("fast");
|
||||
|
||||
videoLink.click(function() {
|
||||
videoContainer.slideUp("fast", function() {
|
||||
$(this).detach();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.registerServices = function() {
|
||||
self.register("youtube.com",
|
||||
'<a href="https://www.youtube.com/watch?v={{videoId}}{{anchor}}" target="_blank">' + Diaspora.I18n.t("videos.watch", { provider: "YouTube" }) + '</a><br />' +
|
||||
'<iframe class="youtube-player" type="text/html" src="https://www.youtube.com/embed/{{videoId}}?wmode=opaque{{anchor}}"></iframe>');
|
||||
|
||||
self.register("vimeo.com",
|
||||
'<a href="http://vimeo.com/{{video-id}}">' + Diaspora.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.I18n.t("videos.unknown") + ' - {{host}}</p>');
|
||||
};
|
||||
};
|
||||
|
||||
Diaspora.Widgets.Embedder = Embedder;
|
||||
})();
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
$.extend(self, {
|
||||
commentForm: self.instantiate("CommentForm", element.find("form.new_comment")),
|
||||
commentStream: self.instantiate("CommentStream", element.find(".comment_stream")),
|
||||
embedder: self.instantiate("Embedder", element.find("div.content")),
|
||||
likes: self.instantiate("Likes", element.find(".likes.on_post .likes_container:first")),
|
||||
lightBox: self.instantiate("Lightbox", element),
|
||||
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
* licensed under the Affero General Public License version 3 or later. See
|
||||
* the COPYRIGHT file.
|
||||
*/
|
||||
|
||||
describe("Diaspora.Widgets.Embedder", function() {
|
||||
var embedder;
|
||||
|
||||
beforeEach(function() {
|
||||
spec.loadFixture("aspects_index_with_posts");
|
||||
embedder = Diaspora.BaseWidget.instantiate("Embedder", $(".stream_element .content"));
|
||||
});
|
||||
|
||||
describe("services", function() {
|
||||
it("is an object containing all the supported services", function() {
|
||||
expect(typeof embedder.services === "object").toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe("register", function() {
|
||||
it("adds a service and it's template to embedder.services", function() {
|
||||
expect(typeof embedder.services["ohaibbq"] === "undefined").toBeTruthy();
|
||||
embedder.register("ohaibbq", "sup guys");
|
||||
expect(typeof embedder.services["ohaibbq"] === "undefined").toBeFalsy();
|
||||
});
|
||||
});
|
||||
describe("render", function() {
|
||||
beforeEach(function() {
|
||||
embedder.registerServices();
|
||||
});
|
||||
it("renders the specified mustache template", function() {
|
||||
var template = embedder.render("youtube.com", {"video-id": "asdf"});
|
||||
expect(template.length > 0).toBeTruthy();
|
||||
expect(typeof template === "string").toBeTruthy();
|
||||
});
|
||||
it("renders the 'undefined' template if the service is not found", function() {
|
||||
var template = embedder.render("yoimmafakeservice", {host: "yo"});
|
||||
expect(template).toEqual(embedder.render("undefined", {host: "yo"}));
|
||||
});
|
||||
});
|
||||
|
||||
describe("embed", function() {
|
||||
beforeEach(function() {
|
||||
spec.loadFixture("aspects_index_with_video_post");
|
||||
});
|
||||
xit("attaches embedVideo to a.video-link'", function() {
|
||||
spyOn(embedder, "embedVideo");
|
||||
$("a.video-link").click();
|
||||
expect(embedder.embedVideo).toHaveBeenCalled();
|
||||
});
|
||||
xit("shows the video when the link is clicked", function() {
|
||||
$("a.video-link").click();
|
||||
// expect video to appear! like magic!
|
||||
})
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue