move canvas-frame functionality into js sub-class for great justice
This commit is contained in:
parent
777c037e16
commit
481160bdcb
2 changed files with 31 additions and 27 deletions
|
|
@ -5,6 +5,12 @@ app.views.CanvasFrame = app.views.SmallFrame.extend({
|
||||||
SINGLE_COLUMN_WIDTH : 265,
|
SINGLE_COLUMN_WIDTH : 265,
|
||||||
DOUBLE_COLUMN_WIDTH : 560,
|
DOUBLE_COLUMN_WIDTH : 560,
|
||||||
|
|
||||||
|
events : {
|
||||||
|
"click .info" : "goToPost", // the only event copied from SmallFrame
|
||||||
|
"click .content" : "favoritePost",
|
||||||
|
"click .delete" : "killPost"
|
||||||
|
},
|
||||||
|
|
||||||
adjustedImageHeight : function() {
|
adjustedImageHeight : function() {
|
||||||
if(!(this.model.get("photos") || [])[0]) { return }
|
if(!(this.model.get("photos") || [])[0]) { return }
|
||||||
|
|
||||||
|
|
@ -29,5 +35,30 @@ app.views.CanvasFrame = app.views.SmallFrame.extend({
|
||||||
return _.extend(this.smallFramePresenter(), {
|
return _.extend(this.smallFramePresenter(), {
|
||||||
adjustedImageHeight : this.adjustedImageHeight()
|
adjustedImageHeight : this.adjustedImageHeight()
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
favoritePost : function(evt) {
|
||||||
|
if(evt) {
|
||||||
|
/* follow links instead of faving the targeted post */
|
||||||
|
if($(evt.target).is('a')) { return }
|
||||||
|
|
||||||
|
evt.stopImmediatePropagation(); evt.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
var prevDimension = this.dimensionsClass();
|
||||||
|
|
||||||
|
this.model.toggleFavorite({save : this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")})
|
||||||
|
|
||||||
|
this.$el.removeClass(prevDimension)
|
||||||
|
this.render()
|
||||||
|
|
||||||
|
app.page.stream.trigger("reLayout")
|
||||||
|
//trigger moar relayouts in the case of images WHOA GROSS HAX
|
||||||
|
_.delay(function(){app.page.stream.trigger("reLayout")}, 200)
|
||||||
|
},
|
||||||
|
|
||||||
|
killPost : function(){
|
||||||
|
this.destroyModel()
|
||||||
|
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ app.views.SmallFrame = app.views.Post.extend({
|
||||||
templateName : "small-frame/default", // default to fall back to
|
templateName : "small-frame/default", // default to fall back to
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
"click .content" : "favoritePost",
|
|
||||||
"click .delete" : "killPost",
|
|
||||||
"click .info" : "goToPost"
|
"click .info" : "goToPost"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -70,31 +68,6 @@ app.views.SmallFrame = app.views.Post.extend({
|
||||||
return (this.model.get("favorite")) ? "x2 width height" : ""
|
return (this.model.get("favorite")) ? "x2 width height" : ""
|
||||||
},
|
},
|
||||||
|
|
||||||
favoritePost : function(evt) {
|
|
||||||
if(evt) {
|
|
||||||
/* follow links instead of faving the targeted post */
|
|
||||||
if($(evt.target).is('a')) { return }
|
|
||||||
|
|
||||||
evt.stopImmediatePropagation(); evt.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
var prevDimension = this.dimensionsClass();
|
|
||||||
|
|
||||||
this.model.toggleFavorite({save : this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")})
|
|
||||||
|
|
||||||
this.$el.removeClass(prevDimension)
|
|
||||||
this.render()
|
|
||||||
|
|
||||||
app.page.stream.trigger("reLayout")
|
|
||||||
//trigger moar relayouts in the case of images WHOA GROSS HAX
|
|
||||||
_.delay(function(){app.page.stream.trigger("reLayout")}, 200)
|
|
||||||
},
|
|
||||||
|
|
||||||
killPost : function(){
|
|
||||||
this.destroyModel()
|
|
||||||
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
|
|
||||||
},
|
|
||||||
|
|
||||||
goToPost : function(evt) {
|
goToPost : function(evt) {
|
||||||
if(evt) { evt.stopImmediatePropagation(); }
|
if(evt) { evt.stopImmediatePropagation(); }
|
||||||
app.setPreload('post',this.model.attributes)
|
app.setPreload('post',this.model.attributes)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue