Permalink
Browse files

Use a play icon for youtube links.

  • Loading branch information...
kdeldycke committed Mar 24, 2013
1 parent e1151e4 commit b837ce9648e354d4f7b1b9b2714c6b606ef949d4
Showing with 23 additions and 2 deletions.
  1. +11 −0 theme/static/css/style.css
  2. BIN theme/static/img/play-button.png
  3. +12 −2 theme/static/js/application.js
View
@@ -106,6 +106,17 @@ a {
}
+.mglass {
+ background-color: rgba(0, 0, 0, 0.3);
+}
+.mglass:hover {
+ opacity: 1;
+}
+#content .video .mglass {
+ background-image: url(/theme/img/play-button.png);
+}
+
+
.masonry {
margin: 0 auto;
}
Binary file not shown.
@@ -40,9 +40,19 @@
});
});
+ // YouTube URL parser. Source: http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex/10315969#10315969
+ function parse_youtube_url(url) {
+ var p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
+ return (url.match(p)) ? RegExp.$1 : false;
+ }
+
// Display an icon overlay for images enclosed in a link in the main content column
- $(function(){
- $("#content a img").mglass();
+ $("#content a img").each(function(i, image){
+ $(image).mglass({opacity: 1,});
+ var image_link = $(image).closest("a");
+ if (parse_youtube_url(image_link.attr("href")) != false) {
+ image_link.addClass("video");
+ };
});
})

0 comments on commit b837ce9

Please sign in to comment.