fav by clicking on something yeahhhh

This commit is contained in:
danielgrippi 2012-04-26 18:39:43 -07:00
parent 387e188905
commit c9d0879d3d
6 changed files with 13 additions and 9 deletions

View file

@ -10,8 +10,7 @@ app.views.SmallFrame = app.views.Post.extend({
templateName : "small-frame",
events : {
"click .content" : "goToPost",
"click .fav" : "favoritePost",
"click .content" : "goToOrEditPost",
"click .delete" : "killPost"
},
@ -102,8 +101,11 @@ app.views.SmallFrame = app.views.Post.extend({
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
},
goToPost : function() {
if(app.page.editMode) { return false; }
app.router.navigate(this.model.url(), true)
goToOrEditPost : function() {
if(app.page.editMode) {
this.favoritePost();
} else {
app.router.navigate(this.model.url(), true)
}
}
});

View file

@ -1,6 +1,8 @@
#edit-controls {
display : none;
font-family : Roboto-Bold;
position : fixed;
width : 100%;

View file

@ -1,5 +1,5 @@
<div id="edit-controls">
Edit mode: Make posts bigger by staring them, or delete them by clicking the X
CHANGE A POST'S SIZE BY CLICKING ON IT
</div>
<a href="/" id="home-button">

View file

@ -1,6 +1,5 @@
<div class="content">
<div class=controls>
<span href="#" class="fav {{#if favorite}}faved{{/if}}"></span>
<a href="#" class="delete"></a>
</div>

View file

@ -51,12 +51,13 @@ describe("app.pages.Profile", function(){
beforeEach(function(){
spyOn(this.post, 'toggleFavorite')
spyOn($.fn, "isotope")
this.page.$(".fav").click()
this.page.$(".content").click()
})
it("relayouts the page", function(){
expect($.fn.isotope).toHaveBeenCalledWith("reLayout")
})
it("toggles the favorite status on the model", function(){
expect(this.post.toggleFavorite).toHaveBeenCalled()
})

View file

@ -57,7 +57,7 @@ describe("app.views.SmallFrame", function(){
})
it("redirects", function() {
this.view.goToPost()
this.view.goToOrEditPost()
expect(app.router.navigate).toHaveBeenCalled()
})
})