diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8e5d4b457..d0f76a986 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -158,7 +158,7 @@ module ApplicationHelper
if options[:youtube]
while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\]+)/)
videoid = youtube[1]
- message.gsub!('youtube.com::'+videoid, 'Youtube: ' + youtube_title(videoid) + '')
+ message.gsub!('youtube.com::'+videoid, 'Youtube: ' + youtube_title(videoid) + '')
end
end
diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js
index 441c0e221..31573cb29 100644
--- a/public/javascripts/stream.js
+++ b/public/javascripts/stream.js
@@ -8,7 +8,7 @@ $(document).ready(function(){
var $stream = $(".stream");
var $publisher = $("#publisher");
// expand all comments on page load
- $(".stream:not('.show')").find('.comments').each(function(index) {
+ $stream.not('.show').find('.comments').each(function(index) {
var comments = $(this);
if(comments.children("li").length > 1) {
var show_comments_toggle = comments.closest("li").find(".show_post_comments");
@@ -33,7 +33,7 @@ $(document).ready(function(){
.closest("form").find(".comment_submit").fadeIn(200);
});
- $(".stream").delegate("textarea.comment_box", "blur", function(evt){
+ $stream.delegate("textarea.comment_box", "blur", function(evt){
var commentBox = $(this);
if( !commentBox.val() ) {
commentBox.attr("rows", 1)
@@ -51,6 +51,49 @@ $(document).ready(function(){
box.toggle();
}
});
+
+ $stream.delegate("a.video-link", "click", function(evt) {
+ evt.preventDefault();
+
+ var $this = $(this),
+ container = document.createElement('div'),
+ $container = $(container).attr("class", "video-container");
+
+ var $videoContainer = $this.siblings("div.video-container");
+ if($videoContainer.length > 0) {
+ $videoContainer.slideUp('fast', function () {
+ $videoContainer.detach();
+ });
+ return;
+ }
+
+ if($("div.video-container").length > 0) {
+ $("div.video-container").slideUp("fast", function() {
+ $(this).detach();
+ });
+ }
+
+ if($this.data("host") === 'youtube.com') {
+ $container.html(
+ 'Watch this video on Youtube
' +
+ ''
+ );
+ } else {
+ $container.html('Invalid videotype '+$this.data("host")+' (ID: '+$this.data("video-id")+')');
+ }
+
+
+
+ $container.hide();
+ this.parentNode.insertBefore(container, this.nextSibling);
+ $container.slideDown('fast');
+
+ $this.click(function() {
+ $container.slideToggle('fast', function () {
+ $(this).detach();
+ });
+ });
+ });
$(".new_status_message").bind('ajax:success', function(data, json, xhr){
json = $.parseJSON(json);
diff --git a/public/javascripts/view.js b/public/javascripts/view.js
index 653d1a1e1..3aa304445 100644
--- a/public/javascripts/view.js
+++ b/public/javascripts/view.js
@@ -3,7 +3,6 @@
* the COPYRIGHT file.
*/
-
$(document).ready(function(){
$('#debug_info').click(function() {
$('#debug_more').toggle('fast');
@@ -115,28 +114,6 @@ $.fn.clearForm = function() {
});
};
-var video_active_container = null;
-
-
-function openVideo(type, videoid, link) {
- var container = document.createElement('div'),
- $container = $(container);
- if(type == 'youtube.com') {
- $container.html('Watch this video on Youtube
');
- } else {
- $container.html('Invalid videotype '+type+' (ID: '+videoid+')');
- }
- if(video_active_container != null) {
- video_active_container.parentNode.removeChild(video_active_container);
- }
- video_active_container = container;
- $container.hide();
- link.parentNode.insertBefore(container, this.nextSibling);
- $container.slideDown('fast', function() { });
- link.onclick = function() { $container.slideToggle('fast', function() { } ); }
-
-
-}
$(".make_profile_photo").live("click", function(evt){