MS DC; you can now kill a post on your profile.
This commit is contained in:
parent
b2ab11944e
commit
7346921473
11 changed files with 76 additions and 52 deletions
BIN
app/assets/images/buttons/delete.png
Normal file
BIN
app/assets/images/buttons/delete.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
app/assets/images/buttons/delete_hover.png
Normal file
BIN
app/assets/images/buttons/delete_hover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
|
|
@ -8,6 +8,7 @@ app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMi
|
|||
},
|
||||
|
||||
renderTemplate : function() {
|
||||
this.$el.empty()
|
||||
this.stream.items.each(_.bind(function(post){
|
||||
this.$el.append(this.createPostView(post).render().el);
|
||||
}, this))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
app.views.SmallFrame = app.views.Base.extend({
|
||||
//= require "./post_view"
|
||||
|
||||
app.views.SmallFrame = app.views.Post.extend({
|
||||
|
||||
SINGLE_COLUMN_WIDTH : 265,
|
||||
DOUBLE_COLUMN_WIDTH : 560,
|
||||
|
|
@ -9,7 +11,8 @@ app.views.SmallFrame = app.views.Base.extend({
|
|||
|
||||
events : {
|
||||
"click .content" : "goToPost",
|
||||
"click .fav" : "goToPost"
|
||||
"click .fav" : "favoritePost",
|
||||
"click .delete" : "killPost"
|
||||
},
|
||||
|
||||
subviews : {
|
||||
|
|
@ -93,8 +96,13 @@ app.views.SmallFrame = app.views.Base.extend({
|
|||
_.delay(function(){app.page.stream.trigger("reLayout")}, 500)
|
||||
},
|
||||
|
||||
killPost : function(){
|
||||
this.destroyModel()
|
||||
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
|
||||
},
|
||||
|
||||
goToPost : function() {
|
||||
if(app.page.editMode) { this.favoritePost(); return false; }
|
||||
if(app.page.editMode) { return false; }
|
||||
app.router.navigate(this.model.url(), true)
|
||||
}
|
||||
});
|
||||
|
|
@ -8,12 +8,6 @@ app.views.StreamObject = app.views.Base.extend({
|
|||
}
|
||||
|
||||
this.model.destroy();
|
||||
this.slideAndRemove();
|
||||
},
|
||||
|
||||
slideAndRemove : function() {
|
||||
$(this.el).slideUp(400, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ app.views.StreamPost = app.views.Post.extend({
|
|||
})
|
||||
},
|
||||
|
||||
remove : function() {
|
||||
$(this.el).slideUp(400, _.bind(function(){this.$el.remove()}, this));
|
||||
return this
|
||||
},
|
||||
|
||||
hidePost : function(evt) {
|
||||
if(evt) { evt.preventDefault(); }
|
||||
if(!confirm(Diaspora.I18n.t('confirm_dialog'))) { return }
|
||||
|
|
|
|||
|
|
@ -102,13 +102,44 @@ body {
|
|||
}
|
||||
}
|
||||
|
||||
.fav {
|
||||
.controls{
|
||||
position : absolute;
|
||||
z-index : 100;
|
||||
top : 10px;
|
||||
right : 10px;
|
||||
|
||||
display : none;
|
||||
|
||||
.edit-mode & {
|
||||
display : inline-block;
|
||||
}
|
||||
|
||||
a, span {
|
||||
display : inline-block;
|
||||
background-size : 30px 30px;
|
||||
height : 30px;
|
||||
width : 30px;
|
||||
text-decoration : none;
|
||||
}
|
||||
|
||||
.delete {
|
||||
background-image : image_url('buttons/delete.png');
|
||||
|
||||
&:hover {
|
||||
background-image : image_url('buttons/delete_hover.png');
|
||||
}
|
||||
}
|
||||
|
||||
.fav {
|
||||
background-image : image_url('buttons/star_not_faved.png');
|
||||
|
||||
&.faved, &:hover {
|
||||
background-image : image_url('buttons/star_faved.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.info {
|
||||
@include transition(bottom);
|
||||
@include box-shadow(0,-1px,3px,rgba(0,0,0,0.3));
|
||||
|
|
|
|||
|
|
@ -18,40 +18,12 @@
|
|||
padding : 10px 0;
|
||||
}
|
||||
|
||||
.canvas-frame .fav {
|
||||
display : none;
|
||||
|
||||
background-image : image_url('buttons/star_not_faved.png');
|
||||
background-size : 30px 30px;
|
||||
height : 30px;
|
||||
width : 30px;
|
||||
|
||||
&.faved {
|
||||
background-image : image_url('buttons/star_faved.png');
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration : none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* functionality under edit mode */
|
||||
.edit-mode {
|
||||
#edit-controls {
|
||||
@include opacity(1);
|
||||
}
|
||||
|
||||
.canvas-frame .fav {
|
||||
display : block;
|
||||
}
|
||||
|
||||
.canvas-frame {
|
||||
.info {
|
||||
display : none
|
||||
}
|
||||
}
|
||||
|
||||
#edit-mode-toggle.control {
|
||||
@include opacity(1);
|
||||
}
|
||||
|
|
@ -94,5 +66,4 @@
|
|||
@include opacity(0.8);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
<div class="content">
|
||||
|
||||
<span href="#" class="fav {{#if favorite}}faved{{/if}}"></span>
|
||||
<div class=controls>
|
||||
<span href="#" class="fav {{#if favorite}}faved{{/if}}"></span>
|
||||
<a href="#" class="delete"></a>
|
||||
</div>
|
||||
|
||||
{{#if photos}}
|
||||
<div class="image-container">
|
||||
|
|
|
|||
|
|
@ -61,6 +61,27 @@ describe("app.pages.Profile", function(){
|
|||
expect(this.post.toggleFavorite).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
context("clicking delete", function(){
|
||||
beforeEach(function () {
|
||||
spyOn(window, "confirm").andReturn(true);
|
||||
this.page.render()
|
||||
})
|
||||
|
||||
it("kills the model", function(){
|
||||
spyOn(this.post, "destroy")
|
||||
this.page.$(".canvas-frame:first a.delete").click()
|
||||
expect(this.post.destroy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("removes the frame", function(){
|
||||
spyOn($.fn, "remove").andCallThrough()
|
||||
expect(this.page.$(".canvas-frame").length).toBe(1)
|
||||
this.page.$(".canvas-frame:first a.delete").click()
|
||||
waitsFor(function(){ return $.fn.remove.wasCalled })
|
||||
runs(function(){ expect(this.page.$(".canvas-frame").length).toBe(0) })
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
describe("edit mode", function(){
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ describe("app.views.SmallFrame", function(){
|
|||
|
||||
describe("redirecting to a post", function(){
|
||||
beforeEach(function(){
|
||||
app.page = {editMode : false}
|
||||
app.page = { editMode : false }
|
||||
app.router = new app.Router()
|
||||
spyOn(app.router, "navigate")
|
||||
})
|
||||
|
|
@ -60,14 +60,5 @@ describe("app.views.SmallFrame", function(){
|
|||
this.view.goToPost()
|
||||
expect(app.router.navigate).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("doesn't redirect if the page is in edit mode, and instead favorites the post", function() {
|
||||
app.page = {editMode : true}
|
||||
|
||||
spyOn(this.view, "favoritePost")
|
||||
this.view.goToPost()
|
||||
expect(app.router.navigate).not.toHaveBeenCalled()
|
||||
expect(this.view.favoritePost).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue