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

View file

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

View file

@ -1,5 +1,5 @@
<div id="edit-controls"> <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> </div>
<a href="/" id="home-button"> <a href="/" id="home-button">

View file

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

View file

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

View file

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