diff options
| author | czaks <marcin@6irc.net> | 2013-07-20 18:25:58 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-22 19:02:01 -0400 |
| commit | acea5a3cccbc6ffd3fd4fae7f4e9255ded02bee6 (patch) | |
| tree | 18dcc7c7ca18cd078f547d6bf8a1277165c54ca8 | |
| parent | 96f3363a8bd0c001c443b34bb9765c6a4895e48b (diff) | |
youtube.js: make it work with thread expand etc.
| -rw-r--r-- | js/youtube.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/js/youtube.js b/js/youtube.js index ec8c501a..f64d4874 100644 --- a/js/youtube.js +++ b/js/youtube.js @@ -24,12 +24,20 @@ onready(function(){ - $('div.video-container a').click(function() { - var videoID = $(this.parentNode).data('video'); + var do_embed_yt = function(tag) { + $('div.video-container a', tag).click(function() { + var videoID = $(this.parentNode).data('video'); - $(this.parentNode).html('<iframe style="float:left;margin: 10px 20px" type="text/html" width="360" height="270" src="//www.youtube.com/embed/' + videoID + '?autoplay=1" frameborder="0"/>'); + $(this.parentNode).html('<iframe style="float:left;margin: 10px 20px" type="text/html" width="360" height="270" src="//www.youtube.com/embed/' + videoID + '?autoplay=1" frameborder="0"/>'); - return false; - }); + return false; + }); + }; + do_embed_yt(document); + + // allow to work with auto-reload.js, etc. + $(document).bind('new_post', function(e, post) { + do_embed_yt(post); + }); }); |
