Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
Created February 21, 2015 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredpalmer/4fe24be04504bb416139 to your computer and use it in GitHub Desktop.
Save jaredpalmer/4fe24be04504bb416139 to your computer and use it in GitHub Desktop.
Better YouTube Video Loads
// Library: Playing YouTube and Google Docs videos when image is clicked
var LibraryVideoPlay = (function() {
subscribeToPageLoad(
"^/lib/.*",
load, unload
);
function load() {
$(".article-video.youtube").click(youtubeVideoClicked);
$(".article-video.gdocs").click(gdocsVideoClicked);
}
function unload() {
}
function youtubeVideoClicked() {
var url = $(this).attr("data-src");
url += "?autohide=1&showinfo=0&autoplay=1";
$(this).html("<iframe src='" + url + "' allowfullscreen></iframe>");
}
function gdocsVideoClicked() {
$(".article-video-login-message").show();
var url = $(this).attr("data-src");
$(this).html("<iframe src='" + url + "'></iframe>");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment