diaspora/public/javascripts/stream.js
danielgrippi ae6fa5bebb don't use Diaspora widget system or stream.js when backbone is active;
migrating like actions over to backbone; some cleanup; bump jquery to
1.7.1
2012-01-07 14:23:22 -08:00

61 lines
1.4 KiB
JavaScript

/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
var Stream = {
selector: "#main_stream",
nsfw_links: ".shield a",
initialize: function() {
Diaspora.page.directionDetector.updateBinds();
Stream.setUpAudioLinks();
},
initializeLives: function(){
Stream.setUpNsfwLinks();
// reshare button action
$(".reshare_button", this.selector).live("click", function(evt) {
evt.preventDefault();
var button = $(this),
box = button.siblings(".reshare_box");
if (box.length > 0) {
button.toggleClass("active");
box.toggle();
}
});
},
setUpNsfwLinks:function(){
$(this.nsfw_links).click(function(e){
e.preventDefault();
$(this).parent().fadeOut();
});
},
setUpAudioLinks: function() {
$(".stream a[target='_blank']").each(function(r){
var link = $(this);
if(this.href.match(/\.mp3$|\.ogg$/)) {
$("<audio/>", {
preload: "none",
src: this.href,
controls: "controls"
}).appendTo(link.parent());
link.remove();
}
});
}
};
$(document).ready(function() {
if( Diaspora.backboneEnabled() ){ return }
if( $(Stream.selector).length == 0 ) { return }
Stream.initializeLives();
});