Remove stream faces
This commit is contained in:
parent
5b21be845e
commit
6efde34bb8
8 changed files with 1 additions and 109 deletions
|
|
@ -183,10 +183,7 @@ app.Router = Backbone.Router.extend({
|
|||
app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.items});
|
||||
app.shortcuts = app.shortcuts || new app.views.StreamShortcuts({el: $(document)});
|
||||
|
||||
var streamFacesView = new app.views.StreamFaces({collection : app.stream.items});
|
||||
|
||||
$("#main_stream").html(app.page.render().el);
|
||||
$("#selected_aspect_contacts .content").html(streamFacesView.render().el);
|
||||
this._hideInactiveStreamLists();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||
|
||||
app.views.StreamFaces = app.views.Base.extend({
|
||||
|
||||
templateName : "stream-faces",
|
||||
|
||||
className : "stream-faces",
|
||||
|
||||
tooltipSelector : ".avatar",
|
||||
|
||||
initialize : function(){
|
||||
this.updatePeople();
|
||||
app.stream.items.bind("add", this.updatePeople, this);
|
||||
app.stream.items.bind("remove", this.updatePeople, this);
|
||||
},
|
||||
|
||||
presenter : function() {
|
||||
return {people : this.people};
|
||||
},
|
||||
|
||||
updatePeople : function(){
|
||||
if(this.people && this.people.length >= 15) { return }
|
||||
this.people = _(this.collection.models).chain()
|
||||
.map(function(post){ return post.get("author") })
|
||||
.compact()
|
||||
.uniq(false, function(person){ return person.id })
|
||||
.value()
|
||||
.slice(0,15);
|
||||
|
||||
this.render();
|
||||
}
|
||||
});
|
||||
// @license-end
|
||||
|
|
@ -74,7 +74,6 @@
|
|||
|
||||
/* stream */
|
||||
@import 'tag';
|
||||
@import 'stream-faces';
|
||||
@import 'stream';
|
||||
@import 'stream_element';
|
||||
@import 'comments';
|
||||
|
|
|
|||
|
|
@ -79,11 +79,6 @@
|
|||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.stream-faces{
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
img{ margin: 1px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#selected_aspect_contacts .avatar {
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.stream-faces a:hover { text-decoration: none; }
|
||||
|
|
@ -51,12 +51,6 @@
|
|||
.right-sidebar-fixed-sub-background.col-lg-3.visible-lg
|
||||
.right-sidebar-fixed-background.col-md-3.col-lg-2.hidden-sm.hidden-xs
|
||||
.col-md-3.col-lg-2.hidden-xs.hidden-sm.rightbar
|
||||
#selected_aspect_contacts.section
|
||||
.title
|
||||
%h5.stream_title
|
||||
= @stream.title
|
||||
.content
|
||||
|
||||
= render 'shared/right_sections'
|
||||
|
||||
%a.back-to-top#back-to-top{title: "#{t('layouts.application.back_to_top')}", href: "#"}
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
describe("app.views.StreamFaces", function(){
|
||||
beforeEach(function(){
|
||||
var rebeccaBlack = factory.author({name : "Rebecca Black", id : 1492});
|
||||
this.post1 = factory.post({author : rebeccaBlack});
|
||||
this.post2 = factory.post({author : factory.author({name : "John Stamos", id : 1987})});
|
||||
this.post3 = factory.post({author : factory.author({name : "Michelle Tanner", id : 1986})});
|
||||
this.post4 = factory.post({author : factory.author({name : "Barack Obama", id : 2000})});
|
||||
this.post5 = factory.post({author : factory.author({name : "Obi-wan Kenobi", id : 2020})});
|
||||
this.post6 = factory.post({author : rebeccaBlack});
|
||||
this.post7 = factory.post({author : rebeccaBlack});
|
||||
|
||||
app.stream = new app.models.Stream();
|
||||
app.stream.add([this.post1, this.post2, this.post3, this.post4, this.post5, this.post6, this.post7]);
|
||||
this.posts = app.stream.items;
|
||||
|
||||
this.view = new app.views.StreamFaces({collection : this.posts});
|
||||
});
|
||||
|
||||
it("should take them unique", function(){
|
||||
this.view.render();
|
||||
expect(this.view.people.length).toBe(5);
|
||||
});
|
||||
|
||||
it("Finds people that were added to the collection", function() {
|
||||
this.posts.add(factory.post({author : factory.author({name : "Harriet Tubman"})}));
|
||||
expect(this.view.people.length).toBe(6);
|
||||
});
|
||||
|
||||
it("Finds people that were removed from the collection", function() {
|
||||
this.posts.remove([this.post2, this.post3]);
|
||||
expect(this.view.people.length).toBe(3);
|
||||
});
|
||||
|
||||
describe(".render", function(){
|
||||
beforeEach(function(){
|
||||
this.view.render();
|
||||
});
|
||||
|
||||
it("appends the people's avatars", function(){
|
||||
expect(this.view.$("img").length).toBe(5);
|
||||
});
|
||||
|
||||
it("links to the people", function(){
|
||||
expect(this.view.$("a").length).toBe(5);
|
||||
});
|
||||
|
||||
it("rerenders when people are added, but caps to 15 people", function(){
|
||||
var posts = _.map(_.range(20), function(){ return factory.post()});
|
||||
this.posts.reset(posts); //add 20 posts silently to the collection
|
||||
this.posts.add(factory.post()); //trigger an update
|
||||
expect(this.view.$("img").length).toBe(15);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -6,6 +6,7 @@ describe("app.views.StreamPost", function(){
|
|||
this.collection = new app.collections.Posts(posts);
|
||||
this.statusMessage = this.collection.models[0];
|
||||
this.reshare = this.collection.models[1];
|
||||
app.stream = new app.models.Stream();
|
||||
});
|
||||
|
||||
describe("events", function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue