diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index 88e799bddc79a9552ff2b9755fdae78263d2a3bd..d8f0be134f121487a1dbfd29591b1df9250e440a 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -11,12 +11,9 @@ var Stream = { Diaspora.widgets.timeago.updateTimeAgo(); $stream.not(".show").delegate("a.show_post_comments", "click", Stream.toggleComments); //audio linx - $(".stream a[target='_blank']").each(function(){ - if($(this).attr('href').match(/\.mp3$|\.ogg$/)) { - $(this).hide(); - $(this).parent().append("<audio preload='none' src='" + this.href + "' controls='controls'>mom</audio>");} - }); - + // + Stream.setUpAudioLinks(); + Stream.setUpImageLinks(); // comment link form focus $stream.delegate(".focus_comment_textarea", "click", function(e){ @@ -63,6 +60,8 @@ var Stream = { //collapse publisher Publisher.close(); Publisher.clear(); + Stream.setUpImageLinks(); + Stream.setUpAudioLinks(); }); $(".new_status_message").bind('ajax:failure', function(data, html , xhr) { @@ -87,6 +86,23 @@ var Stream = { }); }, + setUpAudioLinks: function(){ + $(".stream a[target='_blank']").each(function(){ + if($(this).attr('href').match(/\.gif$|\.jpg$|\.png$|\.jpeg$/)) { + $(this).hide(); + $(this).parent().append("<img src='" + this.href + "'</img>");} + }); + }, + + setUpImageLinks: function(){ + $(".stream a[target='_blank']").each(function(){ + if($(this).attr('href').match(/\.mp3$|\.ogg$/)) { + $(this).hide(); + $(this).parent().append("<audio preload='none' src='" + this.href + "' controls='controls'>mom</audio>");} + }); + + }, + toggleComments: function(evt) { evt.preventDefault(); var $this = $(this),